Skip to content

Commit 04a5806

Browse files
author
tohosaku
committed
Add Unit Test
1 parent bd8fde6 commit 04a5806

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

tests/unit/defaults.spec.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
/*
2-
Stub test file
3-
TODO: Write unit tests for all interfaces
4-
*/
1+
import { defaults } from '../../src/defaults'
52

6-
import { defaults } from '../../src/defaults';
3+
describe('defaults', () => {
4+
it('should be an object', () => {
5+
expect(typeof defaults).toBe('object')
6+
})
77

8+
it('should have standard properties defined', () => {
9+
expect(typeof (defaults.themes)).toBe('object')
10+
expect(typeof (defaults.templates)).toBe('object')
11+
expect(typeof (defaults.iconlibs)).toBe('object')
12+
expect(typeof (defaults.editors)).toBe('object')
13+
expect(typeof (defaults.languages)).toBe('object')
14+
expect(Array.isArray(defaults.resolvers)).toBe(true)
15+
expect(Array.isArray(defaults.custom_validators)).toBe(true)
16+
})
17+
})
818

9-
describe("defaults", function() {
10-
it("should be an object", function(){
11-
expect(typeof defaults).toBe("object");
12-
});
13-
it("should have standard properties defined", function(){
14-
expect(typeof(defaults.themes)).toBe("object");
15-
expect(typeof(defaults.templates)).toBe("object");
16-
expect(typeof(defaults.iconlibs)).toBe("object");
17-
expect(typeof(defaults.editors)).toBe("object");
18-
expect(typeof(defaults.languages)).toBe("object");
19-
expect(Array.isArray(defaults.resolvers)).toBe(true);
20-
expect(Array.isArray(defaults.custom_validators)).toBe(true);
21-
});
22-
});
19+
describe('languages test', () => {
20+
beforeEach(() => {
21+
defaults.languages.es = {
22+
error_notset: 'propiedad debe existir'
23+
}
24+
defaults.language = 'es'
25+
})
26+
27+
it('should translate other language', () => {
28+
expect(defaults.translate('error_notset')).toBe('propiedad debe existir')
29+
})
30+
31+
it('should return default message. if no translation', () => {
32+
expect(defaults.translate('error_notempty')).toBe('Value required')
33+
})
34+
35+
it('throw error to unknown translate string', () => {
36+
expect(() => defaults.translate('unknown_message')).toThrow()
37+
})
38+
})

0 commit comments

Comments
 (0)