Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

expanded async specs

  • Loading branch information...
commit faed1485024de1079e88a3ab72fc314f6754dc0c 1 parent c5ad1ee
@rjz authored
Showing with 57 additions and 25 deletions.
  1. +1 −1  package.json
  2. +56 −24 spec/Generator.spec.js
View
2  package.json
@@ -9,7 +9,7 @@
}
, "repository": {
"type": "git"
- , "url": "github.com/rjz/forge"
+ , "url": "https://github.com/rjz/node-forge"
}
, "keywords": [
"generator"
View
80 spec/Generator.spec.js
@@ -13,30 +13,62 @@ describe('Generator', function () {
expect(child instanceof Generator).toBeTruthy();
});
- it('queues methods', function () {
-
- var a = 'a',
- b = 'b',
- c = 'c';
-
- var spy = jasmine.createSpy();
-
- var child = new (Generator.extend({
- key: 'child',
- create: function () {
- this.foobar(a, b, c);
- },
- foobar: function (a, b, c) {
- this.queue(function () {
- spy(a, b, c);
- });
- }
- }));
-
- child.create();
- child.run();
-
- expect(spy).toHaveBeenCalledWith(a, b, c);
+ describe('queue', function () {
+
+ var a = 'a',
+ b = 'b',
+ c = 'c';
+
+ var spy, child;
+
+ beforeEach(function() {
+ spy = jasmine.createSpy();
+
+ child = new (Generator.extend({
+ key: 'child',
+ create: function () {
+ this.foo(a, b, c);
+ this.bar(c, b, a);
+ },
+ foo: function (a, b, c) {
+ this.queue(function (result) {
+ spy(a, b, c);
+ result();
+ });
+ },
+ bar: function (c, b, a) {
+ this.queue(function (result) {
+ expect(spy).toHaveBeenCalledWith(a, b, c);
+ spy(c, b, a);
+ result();
+ });
+ }
+ }));
+ });
+
+ it('queues methods', function () {
+ child.create();
+ expect(child.q.length).toEqual(2);
+
+ child.run();
+ expect(spy).toHaveBeenCalledWith(c, b, a);
+ expect(spy.callCount).toEqual(2);
+ });
+
+ it('stops running on error', function () {
+ child.foo = function (a, b, c) {
+ this.queue(function (result) {
+ spy(a, b, c);
+ result('error!');
+ });
+ };
+
+ child.create();
+ expect(child.q.length).toEqual(2);
+
+ child.run();
+ expect(spy.callCount).toEqual(1);
+ });
});
it('can invoke other generators', function () {
Please sign in to comment.
Something went wrong with that request. Please try again.