|
| 1 | +require.config({ |
| 2 | + paths: { |
| 3 | + tehanu: '../node_modules/tehanu/dist/index.min', |
| 4 | + tape: '../node_modules/tehanu-repo-tape/dist/index.min', |
| 5 | + teas: '../node_modules/tehanu-teas/dist/index.min', |
| 6 | + underscore: '../node_modules/underscore/underscore-umd-min', |
| 7 | + jquery: '../node_modules/jquery//dist/jquery.min', |
| 8 | + asynctaskqueue: '../asynctaskqueue-min' |
| 9 | + }, |
| 10 | + deps: ['tehanu', 'teas', 'asynctaskqueue', 'tape'], |
| 11 | + callback: ({ factory, run }, { strictEqual }, AsyncTaskQueue, reporter) => { |
| 12 | + const test = factory('AsyncTaskQueue') |
| 13 | + |
| 14 | + const { Task } = AsyncTaskQueue.prototype |
| 15 | + |
| 16 | + test('constructor', function() { |
| 17 | + const worker = function () {} |
| 18 | + const task = new Task(worker) |
| 19 | + strictEqual(task.worker, worker, 'worker should be stored') |
| 20 | + }) |
| 21 | + |
| 22 | + test('promise', function() { |
| 23 | + const task = new Task(function () {}) |
| 24 | + const promise = task.promise() |
| 25 | + strictEqual(promise.state(), 'pending', 'promise should be pending initially') |
| 26 | + task.deferred.resolve() |
| 27 | + strictEqual(promise.state(), 'resolved', 'earlier promise should be resolved') |
| 28 | + strictEqual(task.promise().state(), 'resolved', 'new promise should be resolved') |
| 29 | + }) |
| 30 | + |
| 31 | + run({ reporter }) |
| 32 | + } |
| 33 | +}) |
0 commit comments