This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('triple', function () { | |
| it('Triples the value passed to it', function () { | |
| expect(triple(3)).toEqual(9); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('myService', function () { | |
| beforeEach(module('MyModule')); | |
| it('Contains property "myProperty"', inject(function (myService) { | |
| expect(myService.myProperty).not.toBeUndefined(); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Group by module | |
| describe('MyModule', function () { | |
| // Initialise the module for each test | |
| beforeEach(module('MyModule')); | |
| // Group by service | |
| describe('myService', function () { | |
| var service; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('Calls anotherService.anotherMethod()', inject(function (myService, anotherService) { | |
| spyOn(anotherService, 'anotherMethod'); | |
| myService.myMethod({}); | |
| expect(anotherService.anotherMethod).toHaveBeenCalled(); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| beforeEach(inject(function (anotherService) { | |
| spyOn(anotherService, 'anotherMethod'); | |
| })); | |
| it('Calls anotherService.anotherMethod() during construction', inject(function (myService) { | |
| expect(anotherService.anotherMethod).toHaveBeenCalled(); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('Capitalises strings', inject(function (capitaliseFilter) { | |
| expect(capitaliseFilter('abcd')).toEqual('Abcd'); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('Capitalises strings', inject(function ($filter) { | |
| expect($filter('capitalise')('abcd')).toEqual('Abcd'); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('Attaches the scope to itself', inject(function ($controller) { | |
| var fakeScope = {}; | |
| var ctrl = $controller('MyCtrl', "$scope": fakeScope}); | |
| expect(ctrl.scope).toBe(fakeScope); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('Attaches the scope to itself', inject(function ($controller, $rootScope) { | |
| var scope = $rootScope.$new(); | |
| var ctrl = $controller('MyCtrl', "$scope": scope}); | |
| expect(ctrl.scope).toBe(scope); | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('MyCtrl', function () { | |
| var ctrl, scope, service; | |
| beforeEach(inject(function ($controller, $rootScope, myService) { | |
| service = myService; | |
| scope = $rootScope.$new(); | |
| ctrl = $controller('MyCtrl', {"$scope": scope, "myService": service}); | |
| })); | |
| describe('doSomething()', function () { |
OlderNewer