UNPKG

3.44 kBJSXView Raw
1const React = require('react');
2const { expect } = require('chai');
3const {
4 getComponent,
5 BinaryValue,
6 CodeValue,
7 DateValue,
8 Value,
9 DoubleValue,
10 Int32Value,
11 KeyValue,
12 RegexValue,
13 DBRefValue,
14 StringValue
15} = require('../');
16
17describe('#getComponent', () => {
18 context('when the type is Binary', () => {
19 it('returns a binary value component', () => {
20 expect(getComponent('Binary')).to.deep.equal(BinaryValue);
21 });
22 });
23
24 context('when the type is Code', () => {
25 it('returns a code value component', () => {
26 expect(getComponent('Code')).to.deep.equal(CodeValue);
27 });
28 });
29
30 context('when the type is Date', () => {
31 it('returns a date value component', () => {
32 expect(getComponent('Date')).to.deep.equal(DateValue);
33 });
34 });
35
36 context('when the type is Decimal128', () => {
37 it('returns an element value component', () => {
38 expect(getComponent('Decimal128')).to.deep.equal(Value);
39 });
40 });
41
42 context('when the type is Double', () => {
43 it('returns a double value component', () => {
44 expect(getComponent('Double')).to.deep.equal(DoubleValue);
45 });
46 });
47
48 context('when the type is Int32', () => {
49 it('returns an int32 value component', () => {
50 expect(getComponent('Int32')).to.deep.equal(Int32Value);
51 });
52 });
53
54 context('when the type is Int64', () => {
55 it('returns an element value component', () => {
56 expect(getComponent('Int64')).to.deep.equal(Value);
57 });
58 });
59
60 context('when the type is MaxKey', () => {
61 it('returns an element key value component', () => {
62 expect(getComponent('MaxKey')).to.deep.equal(KeyValue);
63 });
64 });
65
66 context('when the type is MinKey', () => {
67 it('returns an element key value component', () => {
68 expect(getComponent('MinKey')).to.deep.equal(KeyValue);
69 });
70 });
71
72 context('when the type is ObjectId', () => {
73 it('returns an element value component', () => {
74 expect(getComponent('ObjectId')).to.deep.equal(Value);
75 });
76 });
77
78 context('when the type is String', () => {
79 it('returns an element value component', () => {
80 expect(getComponent('String')).to.deep.equal(StringValue);
81 });
82 });
83
84 context('when the type is a BSONRegExp', () => {
85 it('returns an element regex component', () => {
86 expect(getComponent('BSONRegExp')).to.deep.equal(RegexValue);
87 });
88 });
89
90 context('when the type is Symbol', () => {
91 it('returns an element value component', () => {
92 expect(getComponent('Symbol')).to.deep.equal(Value);
93 });
94 });
95
96 context('when the type is Timestamp', () => {
97 it('returns an element value component', () => {
98 expect(getComponent('Timestamp')).to.deep.equal(Value);
99 });
100 });
101
102 context('when the type is Undefined', () => {
103 it('returns an element value component', () => {
104 expect(getComponent('Undefined')).to.deep.equal(Value);
105 });
106 });
107
108 context('when the type is Null', () => {
109 it('returns an element value component', () => {
110 expect(getComponent('Null')).to.deep.equal(Value);
111 });
112 });
113
114 context('when the type is Boolean', () => {
115 it('returns an element value component', () => {
116 expect(getComponent('Boolean')).to.deep.equal(Value);
117 });
118 });
119
120 context('when the type is DBRef', () => {
121 it('returns an element dbref value component', () => {
122 expect(getComponent('DBRef')).to.deep.equal(DBRefValue);
123 });
124 });
125});