-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNumber.spec.js
43 lines (34 loc) · 1.32 KB
/
Number.spec.js
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
// ---------------------------------------------------------------------------------------------------------------------
// Unit Tests for the Number class.
// ---------------------------------------------------------------------------------------------------------------------
const { expect } = require('chai');
const parser = require('../lib/parser');
const Num = require('../lib/Number');
// ---------------------------------------------------------------------------------------------------------------------
describe('Number Class', () =>
{
let number;
beforeEach(() =>
{
number = new Num(3);
});
it('can be converted to json', () =>
{
expect(JSON.stringify(number)).to.equal('{"type":"number","value":3}');
});
it('can be converted to a parsable string', () =>
{
expect(number.toString()).to.equal('3');
expect(parser.parse(number.toString())).to.deep.equal(number);
});
describe('#eval()', () =>
{
it('returns itself with the value populated', () =>
{
const results = number.eval();
// Ensure we populated value correctly
expect(results.value).to.equal(3);
});
});
});
// ---------------------------------------------------------------------------------------------------------------------