-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bundle): ensure that dependencies are added in order
fixes #378
- Loading branch information
1 parent
2cd3c56
commit 51a2cce
Showing
4 changed files
with
132 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
const Utils = require('../../../lib/build/utils'); | ||
|
||
describe('the Utils.runSequentially function', () => { | ||
it('calls the callback function for all items', (d) => { | ||
let items = [{ name: 'first' }, { name: 'second' }]; | ||
let cb = jasmine.createSpy('cb').and.returnValue(Promise.resolve()); | ||
Utils.runSequentially(items, cb) | ||
.then(() => { | ||
expect(cb.calls.count()).toBe(2); | ||
expect(cb.calls.argsFor(0)[0].name).toBe('first'); | ||
expect(cb.calls.argsFor(1)[0].name).toBe('second'); | ||
d(); | ||
}); | ||
}); | ||
|
||
it('runs in sequence', (d) => { | ||
let items = [{ name: 'first' }, { name: 'second' }, { name: 'third' }]; | ||
let cb = jasmine.createSpy('cb').and.callFake((item) => { | ||
return new Promise(resolve => { | ||
if (item.name === 'first' || item.name === 'second') { | ||
setTimeout(() => resolve(), 200); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
Utils.runSequentially(items, cb) | ||
.then(() => { | ||
expect(cb.calls.argsFor(0)[0].name).toBe('first'); | ||
expect(cb.calls.argsFor(1)[0].name).toBe('second'); | ||
expect(cb.calls.argsFor(2)[0].name).toBe('third'); | ||
d(); | ||
}); | ||
}); | ||
|
||
it('handles empty items array', (done) => { | ||
let items = []; | ||
Utils.runSequentially(items, () => {}) | ||
.catch(e => { | ||
done.fail(e, '', 'expected no error'); | ||
throw e; | ||
}) | ||
.then(() => { | ||
done(); | ||
}); | ||
}); | ||
}); |