angular-unit-testing-helpers
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -64,3 +64,3 @@ // Karma configuration | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
browsers: ['PhantomJS2'], | ||
@@ -67,0 +67,0 @@ |
{ | ||
"name": "angular-unit-testing-helpers", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A collection of helper functions for writing AngularJS unit tests.", | ||
@@ -37,6 +37,5 @@ "main": "test-helpers.js", | ||
"karma-ng-html2js-preprocessor": "^0.2.0", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"karma-phantomjs2-launcher": "^0.3.2", | ||
"karma-phantomjs2-launcher": "^0.4.0", | ||
"phantomjs": "^1.9.19" | ||
} | ||
} |
@@ -566,3 +566,3 @@ [![Build Status](https://travis-ci.org/dakolech/angular-unit-testing-helpers.svg?branch=master)](https://travis-ci.org/dakolech/angular-unit-testing-helpers) | ||
`define` will define a model with `attributes` for creating factories. `name` should be unique. It should be called before any create action. The best solution is to define models in seperate folder and inject it at the beginning of the `karma.config` file (but after `test-helpers`). | ||
`define` will define a model with `attributes` for creating factories (it can be also a `sequence`). `name` should be unique. It should be called before any create action. The best solution is to define models in seperate folder and inject it at the beginning of the `karma.config` file (but after `test-helpers`). | ||
@@ -615,3 +615,3 @@ Example: | ||
```javascript | ||
users = TestFactory.createList('user', 3 { | ||
users = TestFactory.createList('user', 3, { | ||
name: 'John', | ||
@@ -618,0 +618,0 @@ pet: { |
@@ -192,13 +192,17 @@ window.TestServ = function(name) { | ||
if (model) { | ||
if (attributes) { | ||
for (var property in attributes) { | ||
if (attributes.hasOwnProperty(property)) { | ||
model[property] = attributes[property]; | ||
if (typeof model === 'function') { | ||
model = model(); | ||
} else { | ||
if (attributes) { | ||
for (var property in attributes) { | ||
if (attributes.hasOwnProperty(property)) { | ||
model[property] = attributes[property]; | ||
} | ||
} | ||
} | ||
} | ||
for (var property in model) { | ||
if (model.hasOwnProperty(property) && typeof model[property] === 'function') { | ||
model[property] = model[property](); | ||
for (var property in model) { | ||
if (model.hasOwnProperty(property) && typeof model[property] === 'function') { | ||
model[property] = model[property](); | ||
} | ||
} | ||
@@ -227,3 +231,3 @@ } | ||
for (var property in model) { | ||
if (model.hasOwnProperty(property) && typeof model[property] === 'function') { | ||
if (model.hasOwnProperty(property) && typeof model !== 'function' && typeof model[property] === 'function') { | ||
model[property].clear(); | ||
@@ -234,3 +238,7 @@ } | ||
for (i; i < number; i++) { | ||
list.push(angular.copy(model)); | ||
if (typeof model === 'function') { | ||
list.push(angular.copy(model())); | ||
} else { | ||
list.push(angular.copy(model)); | ||
} | ||
}; | ||
@@ -237,0 +245,0 @@ |
87593
10
40
2047