Skip to content

Commit

Permalink
Merge pull request #4 from elliotchi/patch-1
Browse files Browse the repository at this point in the history
Changes Promise.run to run in order placed in queue
  • Loading branch information
taylorhakes committed May 15, 2017
2 parents a82147a + e493d4c commit cea0843
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PromiseMock.run = function run(count) {
}

while(runTimes > 0 && PromiseMock.waiting.length > 0) {
PromiseMock.waiting.pop()();
PromiseMock.waiting.shift()();
runTimes--;
}
};
Expand Down
8 changes: 4 additions & 4 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Promise mock', function() {
Promise.reject().catch(function() {
done = true;
});
Promise.run();
Promise.run(2);
expect(done).toBe(true);
});
it('multiple runs', function() {
Expand All @@ -95,7 +95,7 @@ describe('Promise mock', function() {
}).catch(function() {
done = true;
});
Promise.run();
Promise.run(2);
expect(done).toBe(false);
Promise.run();
expect(done).toBe(true);
Expand All @@ -106,7 +106,7 @@ describe('Promise mock', function() {
}).then(function() {
done = true;
});
Promise.run();
Promise.run(2);
expect(done).toBe(false);
Promise.run();
expect(done).toBe(true);
Expand All @@ -119,7 +119,7 @@ describe('Promise mock', function() {
}).then(function() {
done = false;
});
Promise.run();
Promise.run(2);
expect(done).toBe(false);
Promise.run();
expect(done).toBe(true);
Expand Down

0 comments on commit cea0843

Please sign in to comment.