mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
test: 💍 add tests for format method update
This commit is contained in:
parent
b8c8ba8b22
commit
0c8cc1292f
|
@ -5,6 +5,7 @@ import {
|
||||||
getLocaleDictionary,
|
getLocaleDictionary,
|
||||||
$dictionary,
|
$dictionary,
|
||||||
} from '../../src/client/stores/dictionary'
|
} from '../../src/client/stores/dictionary'
|
||||||
|
import { $format } from '../../src/client/stores/format'
|
||||||
|
|
||||||
test('defineMessages returns the identity of its first argument', () => {
|
test('defineMessages returns the identity of its first argument', () => {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
|
@ -47,3 +48,26 @@ describe('waiting for a locale to load', () => {
|
||||||
expect(getLocaleDictionary('pt')).toMatchObject({ foo: 'foo' })
|
expect(getLocaleDictionary('pt')).toMatchObject({ foo: 'foo' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('changing locale', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
init({ fallbackLocale: 'en' })
|
||||||
|
})
|
||||||
|
|
||||||
|
test('format store is updated when locale changes', () => {
|
||||||
|
const fn = jest.fn()
|
||||||
|
const cancel = $format.subscribe(fn)
|
||||||
|
|
||||||
|
$locale.set('pt')
|
||||||
|
expect(fn).toHaveBeenCalledTimes(2)
|
||||||
|
cancel()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('format store is updated when dictionary changes', () => {
|
||||||
|
const fn = jest.fn()
|
||||||
|
const cancel = $format.subscribe(fn)
|
||||||
|
$dictionary.set({})
|
||||||
|
expect(fn).toHaveBeenCalledTimes(2)
|
||||||
|
cancel()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user