1 | const React = require('react');
|
2 | const { Decimal128 } = require('bson');
|
3 | const { expect } = require('chai');
|
4 | const { shallow } = require('enzyme');
|
5 | const { Value } = require('../');
|
6 |
|
7 | describe('<Value /> (rendering Decimal128)', () => {
|
8 | context('when the decimal is a number', () => {
|
9 | const value = Decimal128.fromString('19992.12321');
|
10 | const component = shallow(<Value type="Decimal128" value={value} />);
|
11 |
|
12 | it('sets the base class', () => {
|
13 | expect(component.hasClass('element-value')).to.equal(true);
|
14 | });
|
15 |
|
16 | it('sets the type class', () => {
|
17 | expect(component.hasClass('element-value-is-decimal128')).to.equal(true);
|
18 | });
|
19 |
|
20 | it('sets the title', () => {
|
21 | expect(component.props().title).to.equal('19992.12321');
|
22 | });
|
23 |
|
24 | it('sets the value', () => {
|
25 | expect(component.text()).to.equal('19992.12321');
|
26 | });
|
27 | });
|
28 |
|
29 | context('when the decimal is a valid string', () => {
|
30 | const value = Decimal128.fromString('Infinity');
|
31 | const component = shallow(<Value type="Decimal128" value={value} />);
|
32 |
|
33 | it('sets the base class', () => {
|
34 | expect(component.hasClass('element-value')).to.equal(true);
|
35 | });
|
36 |
|
37 | it('sets the type class', () => {
|
38 | expect(component.hasClass('element-value-is-decimal128')).to.equal(true);
|
39 | });
|
40 |
|
41 | it('sets the title', () => {
|
42 | expect(component.props().title).to.equal('Infinity');
|
43 | });
|
44 |
|
45 | it('sets the value', () => {
|
46 | expect(component.text()).to.equal('Infinity');
|
47 | });
|
48 | });
|
49 | });
|