Skip to content

Commit

Permalink
Add Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
tohosaku committed Apr 7, 2020
1 parent bd8fde6 commit 04a5806
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions tests/unit/defaults.spec.js
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()
})
})

0 comments on commit 04a5806

Please sign in to comment.