forked from jdorn/json-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jdorn#710 from tohosaku/fix_lang
Fixed a bug that language customization did not reflect.
- Loading branch information
Showing
2 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
/* | ||
Stub test file | ||
TODO: Write unit tests for all interfaces | ||
*/ | ||
import { defaults } from '../../src/defaults' | ||
|
||
import { defaults } from '../../src/defaults'; | ||
describe('defaults', () => { | ||
it('should be an object', () => { | ||
expect(typeof defaults).toBe('object') | ||
}) | ||
|
||
it('should have standard properties defined', () => { | ||
expect(typeof (defaults.themes)).toBe('object') | ||
expect(typeof (defaults.templates)).toBe('object') | ||
expect(typeof (defaults.iconlibs)).toBe('object') | ||
expect(typeof (defaults.editors)).toBe('object') | ||
expect(typeof (defaults.languages)).toBe('object') | ||
expect(Array.isArray(defaults.resolvers)).toBe(true) | ||
expect(Array.isArray(defaults.custom_validators)).toBe(true) | ||
}) | ||
}) | ||
|
||
describe("defaults", function() { | ||
it("should be an object", function(){ | ||
expect(typeof defaults).toBe("object"); | ||
}); | ||
it("should have standard properties defined", function(){ | ||
expect(typeof(defaults.themes)).toBe("object"); | ||
expect(typeof(defaults.templates)).toBe("object"); | ||
expect(typeof(defaults.iconlibs)).toBe("object"); | ||
expect(typeof(defaults.editors)).toBe("object"); | ||
expect(typeof(defaults.languages)).toBe("object"); | ||
expect(Array.isArray(defaults.resolvers)).toBe(true); | ||
expect(Array.isArray(defaults.custom_validators)).toBe(true); | ||
}); | ||
}); | ||
describe('languages test', () => { | ||
beforeEach(() => { | ||
defaults.languages.es = { | ||
error_notset: 'propiedad debe existir' | ||
} | ||
defaults.language = 'es' | ||
}) | ||
|
||
it('should translate other language', () => { | ||
expect(defaults.translate('error_notset')).toBe('propiedad debe existir') | ||
}) | ||
|
||
it('should return default message. if no translation', () => { | ||
expect(defaults.translate('error_notempty')).toBe('Value required') | ||
}) | ||
|
||
it('throw error to unknown translate string', () => { | ||
expect(() => defaults.translate('unknown_message')).toThrow() | ||
}) | ||
}) |