Closed padsbanger closed 11 years ago
Hello, can you explain me something ?
In controllers testing pattern you have something like this:
var myCtrl;
// Initialize the controller and scope beforeEach(function () { // Load the controller's module module('myApp');
// create contreoller inject(function ($controller,) { scope = {}; myCtrl = $controller('myCtrl', { $scope: scope }); });
});
// Now time for test Can you explaing why this test is passing
it('should exist', function () { expect(!!myCtrl).toBe(true); });
// and this one
it('should exist', function () { expect(myCtrl).toBe(true); });
// is throwing an error like this:
Expected { } to be true. Error: Expected { } to be true.
Isnt something like this !!true === true, actuall true ?
!! is just a simple way to convert to a boolean. So if the controller object was created it would be true, and if the value of myCtrl null or undefined etc. then it will be false.
!!
myCtrl
Ok, cool tip, thanks :)
Hello, can you explain me something ?
In controllers testing pattern you have something like this:
var myCtrl;
// Initialize the controller and scope beforeEach(function () { // Load the controller's module module('myApp');
});
// Now time for test Can you explaing why this test is passing
it('should exist', function () { expect(!!myCtrl).toBe(true); });
// and this one
it('should exist', function () { expect(myCtrl).toBe(true); });
// is throwing an error like this:
Isnt something like this !!true === true, actuall true ?