2018-12-09 01:17:33 +08:00
|
|
|
import {expect} from 'chai';
|
2019-12-10 17:44:35 +08:00
|
|
|
import {TaskQue} from '../../../../../src/backend/model/threading/TaskQue';
|
2018-12-09 01:17:33 +08:00
|
|
|
|
|
|
|
describe('TaskQue', () => {
|
|
|
|
|
|
|
|
it('should be empty', () => {
|
|
|
|
const tq = new TaskQue<number, number>();
|
|
|
|
expect(tq.isEmpty()).to.be.equal(true);
|
|
|
|
tq.add(2);
|
|
|
|
expect(tq.isEmpty()).to.be.equal(false);
|
|
|
|
tq.ready(tq.get());
|
|
|
|
expect(tq.isEmpty()).to.be.equal(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should get', () => {
|
|
|
|
const tq = new TaskQue<number, number>();
|
|
|
|
tq.add(2);
|
|
|
|
expect(tq.get().data).to.be.equal(2);
|
|
|
|
expect(tq.get).to.throw();
|
|
|
|
});
|
|
|
|
it('should set ready', () => {
|
|
|
|
const tq = new TaskQue<number, number>();
|
|
|
|
tq.add(2);
|
|
|
|
const task = tq.get();
|
|
|
|
tq.ready(task);
|
2018-12-22 07:09:07 +08:00
|
|
|
expect(tq.isEmpty()).to.be.equal(true);
|
2019-12-24 19:22:25 +08:00
|
|
|
expect(tq.ready.bind(tq, task)).to.be.throw('Job does not exist');
|
2018-12-09 01:17:33 +08:00
|
|
|
});
|
|
|
|
});
|