javascript - How can I test if function have not been called? -



javascript - How can I test if function have not been called? -

i'm testing router , have 2 functions, , need test if first function called , sec not. there method tohavebeencalled there no method test if function not called. how can test that?

i have code this:

class="lang-js prettyprint-override">var args, controller, router; beforeeach(function() { controller = { foo: function(name, id) { args = [].slice.call(arguments); }, bar: function(name) { } }; spyon(controller, "foo").and.callthrough(); spyon(controller, "bar").and.callthrough(); router = new route(); router.match('/foo/bar/{{id}}--{{name}}', controller.foo); router.match('/foo/baz/{{id}}--{{name}}', controller.bar); router.exec('/foo/bar/10--hello'); }); it('foo route shuld called', function() { expect(controller.foo).tohavebeencalled(); }); it('bar route shoud not called', function() { // how test if bar not called? });

use not operator:

expect(controller.bar).not.tohavebeencalled();

javascript jasmine

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -