uppy/src/core/Translator.test.js
Rich Willars 540c02b6b0 Add jest tests
Adds tests for src/core/Utils

Ports translator tests to jest

Adds tests for core/index

Added code coverage report

Adds tests for core/UppySocket

Adds tests to src/core and cleanup of test directory

Switched from import to require as the project supports node v4

Runs tests using Babel for backwards compatibilty

Adds src/core state tests

Adds src/core reset & close tests

Updates stagnant snapshot

Adds tests for preprocessors and postprocessors in src/core/Core.js

Adds tests for uploaders and metadata in src/core/Core

Adds tests for adding and removing files in src/core/Core

Adds test for getFile
2017-09-08 17:18:58 +01:00

38 lines
1.2 KiB
JavaScript

import Core from '../../src/core/index.js'
import russian from '../../src/locales/ru_RU.js'
import english from '../../src/locales/en_US.js'
describe('core/translator', () => {
describe('translate', () => {
it('should translate a string', () => {
const core = new Core({ locale: russian })
expect(core.translator.translate('chooseFile')).toEqual('Выберите файл')
})
})
describe('interpolation', () => {
it('should interpolate a string', () => {
const core = new Core({ locale: english })
expect(
core.translator.translate('youHaveChosen', { fileName: 'img.jpg' })
).toEqual('You have chosen: img.jpg')
})
})
describe('pluralization', () => {
it('should translate a string', () => {
const core = new Core({ locale: russian })
expect(
core.translator.translate('filesChosen', { smart_count: '18' })
).toEqual('Выбрано 18 файлов')
expect(
core.translator.translate('filesChosen', { smart_count: '1' })
).toEqual('Выбран 1 файл')
expect(
core.translator.translate('filesChosen', { smart_count: '0' })
).toEqual('Выбрано 0 файлов')
})
})
})