Last active
January 4, 2016 15:19
-
-
Save rolaveric/8640009 to your computer and use it in GitHub Desktop.
AngularJS Unit Test: Service, complex
This file contains 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; | |
// Setup for each test | |
beforeEach(inject(function (myService) { | |
// Every test I'm going to want an instance of "myService" | |
service = myService; | |
})); | |
// Tests for the newly constructed service | |
it('Contains property "myProperty"', function () { | |
expect(service.myProperty).not.toBeUndefined(); | |
}); | |
// Grouping tests by method | |
describe('myMethod(input)', function () { | |
it('Returns the input', function () { | |
var a = {}; | |
expect(service.myMethod(a)).toBe(a); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment