-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.test.js
More file actions
52 lines (40 loc) · 1.35 KB
/
Copy pathruntime.test.js
File metadata and controls
52 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const assert = require('chai').assert;
const Packer = require('../index.js');
describe('Packer Runtime', function() {
let input, output, packer;
let genInput = () => {
return {
deep : { test : { id : 100 } },
};
}
beforeEach(() => {
input = genInput();
packer = new Packer();
});
describe('#take()', () => {
it('should return number of store position', () => {
const pos = packer.take(input);
assert.typeOf(pos, 'number');
});
it('should return equal pos on second taking the same object', () => {
const pos1 = packer.take(input);
const pos2 = packer.take(input);
assert.equal(pos1, pos2);
});
});
describe('#give()', () => {
it('should return object by name', () => {
packer.take(input, 'data');
assert.deepEqual(packer.give('data'), genInput());
});
it('should return object by pos', () => {
const pos = packer.take(input, 'data');
assert.deepEqual(packer.give(pos), input);
});
it('should return null if the give limit is over', () => {
let pos = packer.take(input);
assert.typeOf(packer.give(pos), 'object');
assert.typeOf(packer.give(pos), 'null');
});
});
});