angular-unit-testing-helpers
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -25,2 +25,4 @@ jasmine.pp = function(obj) { | ||
this.without = Some.very('long').service('call').without('promise'); | ||
this.property = Some.short('chain').withProperty; | ||
} | ||
@@ -42,3 +44,4 @@ | ||
responseValue = 'someValue', | ||
withoutValue = 'someOtherValue'; | ||
withoutValue = 'someOtherValue', | ||
withPropertyValue = 'someProperty'; | ||
@@ -57,2 +60,3 @@ beforeEach(module('controllerWithTestServ')); | ||
mockedSome.addMethod('very').addMethod('service').addMethod('without', withoutValue); | ||
mockedSome.addMethod('short').addProperty('withProperty', withPropertyValue); | ||
}); | ||
@@ -113,2 +117,12 @@ | ||
describe('Some short call', function() { | ||
it('should call very with "chain"', function() { | ||
expect(mockedSome.short).toHaveBeenCalledWith('chain'); | ||
}); | ||
it('should set withProperty to the property', function() { | ||
expect(someController.property).toBe(withPropertyValue); | ||
}); | ||
}); | ||
describe('create method', function() { | ||
@@ -115,0 +129,0 @@ var someObject = { |
@@ -21,2 +21,4 @@ function someController(SomeService, Alerts, Some) { | ||
this.without = Some.very('long').service('call').without('promise'); | ||
this.property = Some.short('chain').withProperty; | ||
} | ||
@@ -49,3 +51,5 @@ | ||
withoutValue = 'someOtherValue', | ||
withPropertyValue = 'someProperty', | ||
veryArgument, serviceArgument, withArgument, withoutArgument, successCallbackSome, | ||
shortArgument, | ||
mockedSome = { | ||
@@ -73,2 +77,8 @@ very: function(veryArg) { | ||
} | ||
}, | ||
short: function(shortArg) { | ||
shortArgument = shortArg | ||
return { | ||
withProperty: withPropertyValue | ||
} | ||
} | ||
@@ -147,2 +157,12 @@ }; | ||
describe('Some short call', function() { | ||
it('should call very with "chain"', function() { | ||
expect(shortArgument).toBe('chain'); | ||
}); | ||
it('should set withProperty to the property', function() { | ||
expect(someController.property).toBe(withPropertyValue); | ||
}); | ||
}); | ||
describe('create method', function() { | ||
@@ -149,0 +169,0 @@ var someObject = { |
{ | ||
"name": "angular-unit-testing-helpers", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "A collection of helper functions for writing AngularJS unit tests.", | ||
@@ -29,13 +29,13 @@ "main": "test-helpers.js", | ||
"devDependencies": { | ||
"angular": "1.5.0-rc.0", | ||
"angular-mocks": "^1.4.8", | ||
"jasmine-core": "^2.3.4", | ||
"karma": "^0.13.15", | ||
"karma-chrome-launcher": "^0.2.1", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-ng-html2js-preprocessor": "^0.2.0", | ||
"karma-phantomjs2-launcher": "^0.4.0", | ||
"phantomjs": "^2.1.3" | ||
"angular": "1.5.7", | ||
"angular-mocks": "1.5.7", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^1.1.1", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-jasmine": "^1.0.2", | ||
"karma-ng-html2js-preprocessor": "^1.0.0", | ||
"karma-phantomjs2-launcher": "^0.5.0", | ||
"phantomjs": "^2.1.7" | ||
} | ||
} |
@@ -15,2 +15,3 @@ [![Build Status](https://travis-ci.org/dakolech/angular-unit-testing-helpers.svg?branch=master)](https://travis-ci.org/dakolech/angular-unit-testing-helpers) | ||
- [addPromise](#addpromise) | ||
- [addProperty](#addproperty) | ||
- [TestServ examples](#testserv-examples) | ||
@@ -189,2 +190,28 @@ - [TestElement documentation](#testelement-documentation) | ||
### addProperty: | ||
```javascript | ||
var someService = new TestServ(); | ||
someService.addProperty(name, returnedValue); | ||
``` | ||
`addProperty` will add a property to the someService with returnedValue as a value. | ||
You can also construct chaining methods calls, for example: | ||
```javascript | ||
var someService = new TestServ(); | ||
someService.addProperty('someProperty', propertyValue).addProperty('someOtherProperty', otherPropertyValue); | ||
``` | ||
More in examples. | ||
Implementation: | ||
```javascript | ||
addProperty: function(name, returnedValue) { | ||
this[name] = returnedValue; | ||
return this; | ||
} | ||
``` | ||
**[Back to top](#table-of-contents)** | ||
@@ -191,0 +218,0 @@ |
@@ -34,2 +34,7 @@ window.TestServ = function(name) { | ||
return this; | ||
}, | ||
addProperty: function(name, returnedValue) { | ||
this[name] = returnedValue; | ||
return this; | ||
} | ||
@@ -36,0 +41,0 @@ }; |
Sorry, the diff of this file is not supported yet
96463
2227
776