1 |
|
2 |
|
3 |
|
4 | import { expect } from 'chai';
|
5 | import Value from './value';
|
6 |
|
7 | describe('Value', () => {
|
8 | const fieldValue = 'India';
|
9 | const fieldName = 'Country';
|
10 | const rawDate = 31516200000;
|
11 | const formattedDate = '1970-01-01';
|
12 | const anotherFieldName = 'Ranking';
|
13 | let value;
|
14 | let anotherValue;
|
15 |
|
16 | beforeEach(() => {
|
17 | value = new Value(fieldValue, fieldValue, fieldName);
|
18 | anotherValue = new Value(formattedDate, rawDate, anotherFieldName);
|
19 | });
|
20 |
|
21 | it('should hold primitive value of a field cell', () => {
|
22 | expect(value.value).to.equal(fieldValue);
|
23 | expect(value.formattedValue).to.equal(fieldValue);
|
24 | expect(value.internalValue).to.equal(fieldValue);
|
25 | expect(value.field).to.equal(fieldName);
|
26 |
|
27 | expect(anotherValue.value).to.equal(formattedDate);
|
28 | expect(anotherValue.formattedValue).to.equal(formattedDate);
|
29 | expect(anotherValue.internalValue).to.equal(rawDate);
|
30 | expect(anotherValue.field).to.equal(anotherFieldName);
|
31 | });
|
32 |
|
33 | describe('#toString', () => {
|
34 | it('should return human readable string of the field value', () => {
|
35 | expect(value.toString()).to.equal(String(fieldValue));
|
36 | expect(anotherValue.toString()).to.equal(String(formattedDate));
|
37 | });
|
38 | });
|
39 |
|
40 | describe('#valueOf', () => {
|
41 | it('should return the field value', () => {
|
42 | expect(value.valueOf()).to.equal(fieldValue);
|
43 | expect(anotherValue.valueOf()).to.equal(formattedDate);
|
44 | });
|
45 | });
|
46 | });
|