Skip to content

Commit c43f198

Browse files
committed
Add spec files for all files
Started adding test cases, every file at the least will have confirmation that the imported item from the file being tested is of the correct type.
1 parent d897b1e commit c43f198

16 files changed

+528
-275
lines changed

.mocha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
--require babel-polyfill
33
--reporter spec
44
--watch-extensions js
5-
src/lib/*.spec.js
5+
src/**/*.spec.js

.mocha.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
--recursive
44
--reporter markdown
55
--watch-extensions js
6-
src/lib/*.spec.js
6+
src/**/*.spec.js

dist/json-schema-form-core.js

Lines changed: 28 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/json-schema-form-core.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/canonical-title-map.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export default function(titleMap: Array<any>, originalEnum?: any) {
77
originalEnum.forEach((value) => {
88
canonical.push({ name: titleMap[value], value });
99
});
10-
} else {
10+
}
11+
else {
1112
Object.keys(titleMap).forEach((value) => {
1213
canonical.push({ name: titleMap[value], value });
1314
});

src/lib/canonical-title-map.spec.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import chai from 'chai';
2+
import { describe, it} from 'mocha';
3+
import canonicalTitleMap from './canonical-title-map';
4+
5+
chai.should();
6+
7+
describe('canonical-title-map.js', () => {
8+
it('should hold a normalisation function for enums and titleMaps to generate titleMaps', () => {
9+
canonicalTitleMap.should.be.an('function');
10+
});
11+
12+
describe('canonicalTitleMap', () => {
13+
const enumeration = [ 'Joker', 'Riddler', 'Bane', 'Penguin', 'Cat Woman' ];
14+
const titlemap = [
15+
{ 'name': 'Joker', 'value': 'Joker' },
16+
{ 'name': 'Riddler', 'value': 'Riddler' },
17+
{ 'name': 'Bane', 'value': 'Bane' },
18+
{ 'name': 'Penguin', 'value': 'Penguin' },
19+
{ 'name': 'Cat Woman', 'value': 'Cat Woman' }
20+
];
21+
const titlemapObj = {
22+
'Joker': 'Joker',
23+
'Riddler': 'Riddler',
24+
'Bane': 'Bane',
25+
'Penguin': 'Penguin',
26+
'Cat Woman': 'Cat Woman'
27+
};
28+
29+
it('should return a titleMap for a titleMap object with original enum', () => {
30+
let result = canonicalTitleMap(titlemapObj, enumeration);
31+
result.should.be.deep.equal(titlemap);
32+
});
33+
34+
it('should return a titleMap for a titleMap list with original enum', () => {
35+
let result = canonicalTitleMap(titlemap, enumeration);
36+
result.should.be.deep.equal(titlemap);
37+
});
38+
39+
it('should return a titleMap for a titleMap object without enum', () => {
40+
let result = canonicalTitleMap(titlemapObj);
41+
result.should.be.deep.equal(titlemap);
42+
});
43+
44+
it('should return a titleMap for a titleMap list without enum', () => {
45+
let result = canonicalTitleMap(titlemap);
46+
result.should.be.deep.equal(titlemap);
47+
});
48+
49+
it('should return a titleMap for a titleMap object with original enum, returning "undefined" name if the enum value is not found', () => {
50+
enumeration.push('Mr Freeze');
51+
let result = canonicalTitleMap(titlemapObj, enumeration);
52+
titlemap.push({
53+
"name": undefined,
54+
"value": "Mr Freeze"
55+
})
56+
result.should.be.deep.equal(titlemap);
57+
});
58+
});
59+
});

src/lib/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)