|
1 |
| -/* |
2 |
| -Stub test file |
3 |
| -TODO: Write unit tests for all interfaces |
4 |
| -*/ |
| 1 | +import { defaults } from '../../src/defaults' |
5 | 2 |
|
6 |
| -import { defaults } from '../../src/defaults'; |
| 3 | +describe('defaults', () => { |
| 4 | + it('should be an object', () => { |
| 5 | + expect(typeof defaults).toBe('object') |
| 6 | + }) |
7 | 7 |
|
| 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 | +}) |
8 | 18 |
|
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