Skip to content

Commit

Permalink
feat(star wars): add test fixtures for intergration tests.
Browse files Browse the repository at this point in the history
The fixtures for testing `counterfeit` promises have been added.
These fixtures consist of a module called `starWars`, that includes the
following classes:

* DeflectorShield
* DeathStar

The `DeflectorShield` service exposes one public method called `reboot`.
This asynchronous operation returns a promise.

The `DeathStar` factory exposes a public method called
`rebootDeflectorShield`. This operation delegates to
`DeflectorShield#reboot` and interfaces with the promise that is
returned.
  • Loading branch information
mattfreer committed Nov 14, 2014
1 parent c97e03f commit 260ca54
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"author": {
"name": "Matt Freer"
},

"private": true,

"devDependencies": {
"angular": "~1.3.1",
"angular-mocks": "~1.3.1"
"angular-mocks": "~1.3.1",
"angular-resource": "~1.3.2"
}
}
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = function(config) {
files: [
"node_modules/chai/chai.js",
"src/vendor/angular/angular.js",
"src/vendor/angular-resource/angular-resource.js",
"src/vendor/angular-mocks/angular-mocks.js",
"dist/counterfeit.js",
"test/**/*.js"
Expand Down
34 changes: 34 additions & 0 deletions test/counterfeit_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function(expect, describe, it, angular, sinon) {
"use strict";

var starWars = angular.module("starWars", ["ngResource"]);

starWars.service('DeflectorShield', function($resource) {
return $resource({}, null, {
"reboot": {
method: "PUT",
url: "/starwars/deflector_shield/reboot"
}
});
});

starWars.factory('DeathStar', function(DeflectorShield) {
var status, shieldStatus;

shieldStatus = function(msg) {
status = msg;
};

return {
rebootDeflectorShield: function() {
DeflectorShield.reboot().$promise.then(
shieldStatus, shieldStatus, shieldStatus);
},

shieldStatus: function() {
return status;
},
}
});

})(chai.expect, describe, it, angular, sinon);

0 comments on commit 260ca54

Please sign in to comment.