forked from daniellmb/angular-test-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pattern(constant): add initial testing patterns
- Loading branch information
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Unit Testing AngularJS Constants | ||
|
||
##### Testing Patterns | ||
|
||
* [Suggested Setup](#suggested-constant-unit-test-setup-) | ||
* Patterns | ||
* [be my expected value](#be-my-expected-value-) | ||
* Have a good pattern? | ||
* *[pull request welcome!](../#contributing-test-patterns)* | ||
|
||
###### [Example](../example) implementation of these testing patterns | ||
|
||
####Suggested Constant Unit Test Setup [↑](#testing-patterns) | ||
```CoffeeScript | ||
# CoffeeScript | ||
describe 'Constant: myConst', -> | ||
myConst = null | ||
|
||
beforeEach -> | ||
# Load the constant's module | ||
module 'myApp' | ||
|
||
# Inject in angular constructs otherwise, | ||
# you would need to inject these into each test | ||
inject (_myConst_) -> | ||
myConst = _myConst_ | ||
|
||
it 'should exist', -> | ||
expect(!!myConst).toBe yes | ||
|
||
describe 'the constant', -> | ||
# Add specs | ||
``` | ||
|
||
```JavaScript | ||
// JavaScript | ||
describe('Constant: myConst', function () { | ||
var myConst; | ||
|
||
beforeEach(function () { | ||
// Load the constant's module | ||
module('myApp'); | ||
|
||
// Inject in angular constructs otherwise, | ||
// you would need to inject these into each test | ||
inject(function (_myConst_) { | ||
myConst = _myConst_; | ||
}); | ||
}); | ||
|
||
it('should exist', function () { | ||
expect(!!myConst).toBe(true); | ||
}); | ||
|
||
describe('the constant', function () { | ||
// Add specs | ||
}); | ||
}); | ||
``` | ||
|
||
####My constant should: | ||
|
||
#####be my expected value [↑](#testing-patterns) | ||
```CoffeeScript | ||
# CoffeeScript | ||
it 'should be my expected value', -> | ||
expect(myConst).toBe(42) | ||
``` | ||
|
||
```JavaScript | ||
// JavaScript | ||
it('should return my expected value', function () { | ||
expect(myConst).toBe(42); | ||
}); | ||
``` | ||
|
||
|
||
|