Skip to content

Commit

Permalink
feat(CounterfeitPromise): add raw property
Browse files Browse the repository at this point in the history
A new public property `raw` has been added to `CounterfeitPromise`. This
property references the promise object associated with the internal
deferred object.

Developers may find it useful to use `raw` if they have a requirement
to override an object property that is a promise in a testing
environment. Contrast this to the requirement to stub a function that
returns a promise, where you would use `counterfeit.stub`.
  • Loading branch information
mattfreer committed Nov 18, 2014
1 parent b3161b4 commit fa129b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dist/counterfeit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ counterfeit.factory("CounterfeitPromise", function() {
var $timeout, $q;

function CounterfeitPromise() {
this.deferred = undefined;
this.raw = undefined;
this._injectDependecies();
this.reset();
}
Expand All @@ -26,6 +28,7 @@ counterfeit.factory("CounterfeitPromise", function() {

CounterfeitPromise.prototype.reset = function() {
this.deferred = $q.defer();
this.raw = this.deferred.promise;
return this.deferred.promise;
};
// ------------------------------
Expand Down
2 changes: 1 addition & 1 deletion dist/counterfeit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ counterfeit.factory("CounterfeitPromise", function() {
var $timeout, $q;

function CounterfeitPromise() {
this.deferred = undefined;
this.raw = undefined;
this._injectDependecies();
this.reset();
}
Expand All @@ -22,6 +24,7 @@ counterfeit.factory("CounterfeitPromise", function() {

CounterfeitPromise.prototype.reset = function() {
this.deferred = $q.defer();
this.raw = this.deferred.promise;
return this.deferred.promise;
};
// ------------------------------
Expand Down

0 comments on commit fa129b4

Please sign in to comment.