Skip to content

Commit e12f320

Browse files
committedJan 17, 2021
i think i got it
1 parent 937d783 commit e12f320

File tree

6 files changed

+498
-304
lines changed

6 files changed

+498
-304
lines changed
 

‎.babelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"plugins": [
44
"@babel/plugin-syntax-class-properties",
55
"@babel/plugin-syntax-jsx",
6-
"react-html-attrs"
6+
"react-html-attrs",
7+
"istanbul"
78
]
89
}

‎.coveralls.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
service-name: travis-ci
2-
repo_token: vgY2Lq1R7eqlkcmpp4wU32xZI7JskTACs
2+
repo_token: 5tBngUO90HTikmfFGI6ve2w7sVSau3N9K

‎package-lock.json

+338-151
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@babel/plugin-syntax-jsx": "^7.12.1",
1616
"@babel/register": "7.12.10",
1717
"babel-plugin-react-html-attrs": "^2.1.0",
18-
"chai": "^4.1.2",
18+
"chai": "^4.2.0",
1919
"coveralls": "^3.1.0",
2020
"css-loader": "^4.3.0",
2121
"enzyme": "^3.2.0",
@@ -26,7 +26,7 @@
2626
"html-webpack-plugin": "2.30.1",
2727
"ignore-styles": "^5.0.1",
2828
"jsdom": "^16.4.0",
29-
"mocha": "^4.0.1",
29+
"mocha": "^8.2.1",
3030
"moment": "^2.29.1",
3131
"node": "^10.23.0",
3232
"node-sass": "^4.14.1",
@@ -40,7 +40,7 @@
4040
"react-select": "^1.1.0",
4141
"react-test-renderer": "^16.14.0",
4242
"sass-loader": "^10.1.1",
43-
"sinon": "^4.5.0",
43+
"sinon": "^9.2.3",
4444
"style-loader": "^1.3.0",
4545
"webpack": "^4.46.0",
4646
"webpack-bundle-analyzer": "^3.9.0",
@@ -60,9 +60,9 @@
6060
"modules:debug": "./docker/debug.sh",
6161
"modules:tree": "webpack --config webpack/webpack.config.js --json ",
6262
"modules:size-analyzer": "webpack --config webpack/webpack.config.js --json | webpack-bundle-size-analyzer",
63-
"test": "NODE_ENV=test npm run test:unit && npm run test:coverage",
63+
"test": "npm run test:coverage",
6464
"test:unit": "NODE_ENV=test nyc mocha test/**/*-test.js",
65-
"test:coverage": "NODE_ENV=test nyc report --reporter=text-lcov | coveralls",
65+
"test:coverage": "NODE_ENV=test nyc --reporter=text-lcov mocha test/**/*-test.js | coveralls",
6666
"test:watch": "NODE_ENV=test nyc mocha -w test/**/*-test.js",
6767
"lint": "NODE_ENV=test ./node_modules/.bin/eslint src",
6868
"lint-fixup": "NODE_ENV=test ./node_modules/.bin/eslint src --ext .js,.jsx --fix"

‎test/testHelpers/requireSources.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import register from "ignore-styles"
2-
register([".sass", ".scss"])
3-
import "./../../src/js/index"
1+
import register from 'ignore-styles';
2+
register(['.sass', '.scss']);
3+
import './../../src/js/index';
44

55
import Adapter from 'enzyme-adapter-react-16';
66
import { configure } from 'enzyme';
77
import jsdom from 'jsdom';
88

99
//https://stackoverflow.com/questions/46896639/ensure-a-dom-environment-is-loaded-for-enzyme
1010
function setUpDomEnvironment() {
11-
const { JSDOM } = jsdom;
12-
const dom = new JSDOM('<!doctype html><html><body></body></html>');
13-
const { window } = dom;
11+
const { JSDOM } = jsdom;
12+
const dom = new JSDOM('<!doctype html><html><body></body></html>');
13+
const { window } = dom;
1414

15-
global.window = window;
16-
global.document = window.document;
17-
global.navigator = {
18-
userAgent: 'node.js',
19-
};
20-
copyProps(window, global);
15+
global.window = window;
16+
global.document = window.document;
17+
global.navigator = {
18+
userAgent: 'node.js'
19+
};
20+
copyProps(window, global);
2121
}
2222

2323
function copyProps(src, target) {
24-
const props = Object.getOwnPropertyNames(src)
25-
.filter(prop => typeof target[prop] === 'undefined')
26-
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
27-
Object.defineProperties(target, props);
24+
const props = Object.getOwnPropertyNames(src)
25+
.filter(prop => typeof target[prop] === 'undefined')
26+
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
27+
Object.defineProperties(target, props);
2828
}
2929

3030
setUpDomEnvironment();
3131

32-
configure({ adapter: new Adapter() })
32+
configure({ adapter: new Adapter() });
+135-129
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
import React from "react"
2-
import { shallow, render, mount } from "enzyme"
3-
import { expect } from "chai"
1+
import React from 'react';
2+
import { shallow, render, mount } from 'enzyme';
3+
import { expect } from 'chai';
44

5-
import JsonObject from "./../../../../../src/js/components/DataTypes/Object"
5+
import JsonObject from './../../../../../src/js/components/DataTypes/Object';
66

7-
describe("<JsonObject />", function() {
8-
const rjvId = 1
7+
describe('<JsonObject />', function () {
8+
const rjvId = 1;
99

10-
it("Object component should have a data type label", function() {
10+
it('Object component should have a data type label', function () {
1111
let src = {
1212
test: true
13-
}
13+
};
1414
const wrapper = shallow(
1515
<JsonObject
1616
src={src}
17-
namespace={["root"]}
17+
namespace={['root']}
1818
rjvId={rjvId}
1919
theme="rjv-default"
2020
indentWidth={1}
2121
depth={1}
2222
displayDataTypes={true}
2323
type="object"
2424
/>
25-
)
26-
expect(wrapper.find(".object-key-val")).to.have.length(1)
27-
})
25+
);
26+
expect(wrapper.find('.object-key-val')).to.have.length(1);
27+
});
2828

29-
it("Object mount, multiple data type labels", function() {
29+
it('Object mount, multiple data type labels', function () {
3030
let src = {
3131
bool: true, //should have label
3232
int: 5, //should have label
33-
str: "test", //should have label
33+
str: 'test', //should have label
3434
nan: NaN,
3535
null: null,
3636
undefined: undefined,
37-
func: function() {}, //should have label
37+
func: function () {}, //should have label
3838
float: 1.325, //should have label
3939
arr: [
4040
1, //should have label
@@ -45,11 +45,11 @@ describe("<JsonObject />", function() {
4545
},
4646
empty_arr: [],
4747
empty_obj: {}
48-
}
48+
};
4949
const wrapper = render(
5050
<JsonObject
5151
src={src}
52-
namespace={["root"]}
52+
namespace={['root']}
5353
rjvId={rjvId}
5454
theme="rjv-default"
5555
indentWidth={1}
@@ -58,19 +58,19 @@ describe("<JsonObject />", function() {
5858
displayDataTypes={true}
5959
type="object"
6060
/>
61-
)
62-
expect(wrapper.find(".data-type-label")).to.have.length(8)
63-
})
61+
);
62+
expect(wrapper.find('.data-type-label')).to.have.length(8);
63+
});
6464

65-
it("Object mount, no data type labels when collapsed", function() {
65+
it('Object mount, no data type labels when collapsed', function () {
6666
let src = {
6767
bool: true, //should have label
6868
int: 5, //should have label
69-
str: "test", //should have label
69+
str: 'test', //should have label
7070
nan: NaN,
7171
null: null,
7272
undefined: undefined,
73-
func: function() {}, //should have label
73+
func: function () {}, //should have label
7474
float: 1.325, //should have label
7575
arr: [
7676
1, //should have label
@@ -79,11 +79,11 @@ describe("<JsonObject />", function() {
7979
obj: {
8080
test: true //should have label
8181
}
82-
}
82+
};
8383
const wrapper = render(
8484
<JsonObject
8585
src={src}
86-
namespace={["root"]}
86+
namespace={['root']}
8787
rjvId={rjvId}
8888
theme="rjv-default"
8989
indentWidth={1}
@@ -92,18 +92,18 @@ describe("<JsonObject />", function() {
9292
collapsed={true}
9393
type="object"
9494
/>
95-
)
96-
expect(wrapper.find(".data-type-label")).to.have.length(0)
97-
})
95+
);
96+
expect(wrapper.find('.data-type-label')).to.have.length(0);
97+
});
9898

99-
it("Array mount expanded", function() {
99+
it('Array mount expanded', function () {
100100
let src = {
101-
arr1: [("arr2": ["test"])]
102-
}
101+
arr1: [('arr2': ['test'])]
102+
};
103103
const wrapper = render(
104104
<JsonObject
105105
src={src}
106-
namespace={["arr_test"]}
106+
namespace={['arr_test']}
107107
name="test"
108108
rjvId={rjvId}
109109
theme="rjv-default"
@@ -113,19 +113,19 @@ describe("<JsonObject />", function() {
113113
displayDataTypes={true}
114114
type="array"
115115
/>
116-
)
117-
expect(wrapper.find(".expanded-icon")).to.have.length(2)
118-
expect(wrapper.find(".collapsed-icon")).to.have.length(0)
119-
})
116+
);
117+
expect(wrapper.find('.expanded-icon')).to.have.length(2);
118+
expect(wrapper.find('.collapsed-icon')).to.have.length(0);
119+
});
120120

121-
it("Array mount collapsed", function() {
121+
it('Array mount collapsed', function () {
122122
let src = {
123-
arr1: [("arr2": ["test"])]
124-
}
123+
arr1: [('arr2': ['test'])]
124+
};
125125
const wrapper = render(
126126
<JsonObject
127127
src={src}
128-
namespace={["arr_test"]}
128+
namespace={['arr_test']}
129129
name="test"
130130
rjvId={rjvId}
131131
theme="rjv-default"
@@ -134,19 +134,19 @@ describe("<JsonObject />", function() {
134134
depth={1}
135135
type="array"
136136
/>
137-
)
138-
expect(wrapper.find(".expanded-icon")).to.have.length(0)
139-
expect(wrapper.find(".collapsed-icon")).to.have.length(1)
140-
})
137+
);
138+
expect(wrapper.find('.expanded-icon')).to.have.length(0);
139+
expect(wrapper.find('.collapsed-icon')).to.have.length(1);
140+
});
141141

142-
it("Array mount collapsed circle", function() {
142+
it('Array mount collapsed circle', function () {
143143
let src = {
144-
arr1: [("arr2": ["test"])]
145-
}
144+
arr1: [('arr2': ['test'])]
145+
};
146146
const wrapper = render(
147147
<JsonObject
148148
src={src}
149-
namespace={["arr_test"]}
149+
namespace={['arr_test']}
150150
name="test"
151151
rjvId={rjvId}
152152
theme="rjv-default"
@@ -155,19 +155,19 @@ describe("<JsonObject />", function() {
155155
depth={1}
156156
type="array"
157157
/>
158-
)
159-
expect(wrapper.find(".expanded-icon")).to.have.length(0)
160-
expect(wrapper.find(".collapsed-icon")).to.have.length(1)
161-
})
158+
);
159+
expect(wrapper.find('.expanded-icon')).to.have.length(0);
160+
expect(wrapper.find('.collapsed-icon')).to.have.length(1);
161+
});
162162

163-
it("Array mount collapsed square", function() {
163+
it('Array mount collapsed square', function () {
164164
let src = {
165-
arr1: [("arr2": ["test"])]
166-
}
165+
arr1: [('arr2': ['test'])]
166+
};
167167
const wrapper = render(
168168
<JsonObject
169169
src={src}
170-
namespace={["arr_test"]}
170+
namespace={['arr_test']}
171171
name="test"
172172
rjvId={rjvId}
173173
theme="rjv-default"
@@ -177,19 +177,19 @@ describe("<JsonObject />", function() {
177177
iconStyle="square"
178178
type="array"
179179
/>
180-
)
181-
expect(wrapper.find(".expanded-icon")).to.have.length(0)
182-
expect(wrapper.find(".collapsed-icon")).to.have.length(1)
183-
})
180+
);
181+
expect(wrapper.find('.expanded-icon')).to.have.length(0);
182+
expect(wrapper.find('.collapsed-icon')).to.have.length(1);
183+
});
184184

185-
it("Array mount collapsed triangle", function() {
185+
it('Array mount collapsed triangle', function () {
186186
let src = {
187-
arr1: [("arr2": ["test"])]
188-
}
187+
arr1: [('arr2': ['test'])]
188+
};
189189
const wrapper = render(
190190
<JsonObject
191191
src={src}
192-
namespace={["arr_test"]}
192+
namespace={['arr_test']}
193193
name="test"
194194
rjvId={rjvId}
195195
theme="rjv-default"
@@ -199,172 +199,178 @@ describe("<JsonObject />", function() {
199199
iconStyle="triangle"
200200
type="array"
201201
/>
202-
)
203-
expect(wrapper.find(".expanded-icon")).to.have.length(0)
204-
expect(wrapper.find(".collapsed-icon")).to.have.length(1)
205-
})
202+
);
203+
expect(wrapper.find('.expanded-icon')).to.have.length(0);
204+
expect(wrapper.find('.collapsed-icon')).to.have.length(1);
205+
});
206206

207-
it("non-empty object should be expanded", function() {
208-
let src = { test: true }
207+
it('non-empty object should be expanded', function () {
208+
let src = { test: true };
209209

210210
const wrapper = shallow(
211211
<JsonObject
212212
src={src}
213213
theme="rjv-default"
214-
namespace={["root"]}
214+
namespace={['root']}
215215
collapsed={false}
216216
/>
217-
)
218-
expect(wrapper.state("expanded")).to.equal(true)
219-
})
217+
);
218+
expect(wrapper.state('expanded')).to.equal(true);
219+
});
220220

221-
it("empty object should not be expanded", function() {
222-
let src = {}
221+
it('empty object should not be expanded', function () {
222+
let src = {};
223223

224224
const wrapper = shallow(
225225
<JsonObject
226226
src={src}
227227
theme="rjv-default"
228-
namespace={["root"]}
228+
namespace={['root']}
229229
rjvId={rjvId}
230230
collapsed={false}
231231
/>
232-
)
233-
expect(wrapper.state("expanded")).to.equal(false)
234-
})
232+
);
233+
expect(wrapper.state('expanded')).to.equal(false);
234+
});
235235

236-
it("non-empty array should be expanded", function() {
237-
let src = [1, 2, 3]
236+
it('non-empty array should be expanded', function () {
237+
let src = [1, 2, 3];
238238

239239
const wrapper = shallow(
240240
<JsonObject
241241
src={src}
242242
theme="rjv-default"
243-
namespace={["root"]}
243+
namespace={['root']}
244244
rjvId={rjvId}
245245
collapsed={false}
246246
/>
247-
)
248-
expect(wrapper.state("expanded")).to.equal(true)
249-
})
247+
);
248+
expect(wrapper.state('expanded')).to.equal(true);
249+
});
250250

251-
it("empty array should not be expanded", function() {
252-
let src = []
251+
it('empty array should not be expanded', function () {
252+
let src = [];
253253

254254
const wrapper = shallow(
255255
<JsonObject
256256
src={src}
257257
theme="rjv-default"
258-
namespace={["root"]}
258+
namespace={['root']}
259259
collapsed={false}
260+
indentWidth={1}
260261
/>
261-
)
262-
expect(wrapper.state("expanded")).to.equal(false)
263-
})
262+
);
263+
expect(wrapper.state('expanded')).to.equal(false);
264+
});
264265

265-
it("non-empty array should have ellipsis", function() {
266-
let src = [1, 2, 3]
266+
it('non-empty array should have ellipsis', function () {
267+
let src = [1, 2, 3];
267268

268269
const wrapper = render(
269270
<JsonObject
270271
src={src}
271272
theme="rjv-default"
272-
namespace={["root"]}
273+
namespace={['root']}
273274
rjvId={rjvId}
274275
collapsed={true}
276+
indentWidth={1}
275277
/>
276-
)
278+
);
277279

278-
expect(wrapper.find(".node-ellipsis")).to.have.length(1)
279-
})
280+
expect(wrapper.find('.node-ellipsis')).to.have.length(1);
281+
});
280282

281-
it("empty array should not have ellipsis", function() {
282-
let src = []
283+
it('empty array should not have ellipsis', function () {
284+
let src = [];
283285

284286
const wrapper = render(
285287
<JsonObject
286288
src={src}
287289
theme="rjv-default"
288-
namespace={["root"]}
290+
namespace={['root']}
289291
rjvId={rjvId}
290292
collapsed={true}
293+
indentWidth={1}
291294
/>
292-
)
295+
);
293296

294-
expect(wrapper.find(".node-ellipsis")).to.have.length(0)
295-
})
297+
expect(wrapper.find('.node-ellipsis')).to.have.length(0);
298+
});
296299

297-
it("should collapse at shouldCollapse logic", function() {
298-
let src = { prop1: 1, prop2: 2, prop3: 3 }
300+
it('should collapse at shouldCollapse logic', function () {
301+
let src = { prop1: 1, prop2: 2, prop3: 3 };
299302

300303
const wrapper = shallow(
301304
<JsonObject
302305
src={src}
303306
theme="rjv-default"
304-
namespace={["root"]}
307+
namespace={['root']}
305308
collapsed={false}
306309
shouldCollapse={() => true}
307310
/>
308-
)
311+
);
309312

310-
expect(wrapper.state("expanded")).to.equal(false)
311-
})
313+
expect(wrapper.state('expanded')).to.equal(false);
314+
});
312315

313-
it("should expand based on shouldCollapse logic", function() {
314-
let src = { prop1: 1, prop2: 2, prop3: 3 }
316+
it('should expand based on shouldCollapse logic', function () {
317+
let src = { prop1: 1, prop2: 2, prop3: 3 };
315318

316319
const wrapper = shallow(
317320
<JsonObject
318321
src={src}
319322
theme="rjv-default"
320-
namespace={["root"]}
323+
namespace={['root']}
321324
collapsed={false}
322325
shouldCollapse={() => false}
326+
indentWidth={1}
323327
/>
324-
)
328+
);
325329

326-
expect(wrapper.state("expanded")).to.equal(true)
327-
})
328-
it("sort object keys", () => {
330+
expect(wrapper.state('expanded')).to.equal(true);
331+
});
332+
it('sort object keys', () => {
329333
let src = {
330334
d: 'd',
331335
b: 'b',
332336
a: 'a',
333-
c: 'c',
334-
}
337+
c: 'c'
338+
};
335339

336340
const wrapper = render(
337341
<JsonObject
338342
src={src}
339343
theme="rjv-default"
340-
namespace={["root"]}
344+
namespace={['root']}
341345
sortKeys={true}
342346
collapsed={false}
343347
shouldCollapse={() => false}
344348
quotesOnKeys={true}
349+
indentWidth={1}
345350
/>
346-
)
351+
);
347352
expect(wrapper.text()).to.equal('"":{"a":"a""b":"b""c":"c""d":"d"}');
348-
})
353+
});
349354

350-
it("do not sort object keys", () => {
355+
it('do not sort object keys', () => {
351356
let src = {
352357
d: 'd',
353358
b: 'b',
354359
a: 'a',
355-
c: 'c',
356-
}
360+
c: 'c'
361+
};
357362

358363
const wrapper = render(
359364
<JsonObject
360365
src={src}
361366
theme="rjv-default"
362-
namespace={["root"]}
367+
namespace={['root']}
363368
collapsed={false}
364369
shouldCollapse={() => false}
365370
quotesOnKeys={true}
371+
indentWidth={1}
366372
/>
367-
)
373+
);
368374
expect(wrapper.text()).to.equal('"":{"d":"d""b":"b""a":"a""c":"c"}');
369-
})
370-
})
375+
});
376+
});

0 commit comments

Comments
 (0)
Please sign in to comment.