dman
dman

Reputation: 11064

Webcomponent Tester - How to assert a function not to be called?

Using Polymer 1.* and webcomponent tester...

I have spy(alert, 'open') and expect(alert.open).to.have.not.been.called;. How can I assert a function is not called? Right now this. If I inverse it with expect(alert.open).to.have.been.called;, it also fails.

I tried .calledCount(0) and it defaults to has not been called which fails.

The spy is good, it's just complaining ether way that it is not asserted and test fails.

Upvotes: 0

Views: 135

Answers (1)

daKmoR
daKmoR

Reputation: 1864

You should expect on the spy itself

const myElement = fixture('my-element');
const openSpy = sinon.spy(myElement, 'open');
//myElement.doSomethingThatShouldNotTriggerOpen();
openSpy.should.have.callCount(0);

Upvotes: 1

Related Questions