From 0c8cc1292f833caaaac51c8e69de6a8d2ce5232c Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Fri, 29 Nov 2019 18:39:20 -0300 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20tests=20for=20form?= =?UTF-8?q?at=20method=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/client/index.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/client/index.test.ts b/test/client/index.test.ts index 5da3394..63e28da 100644 --- a/test/client/index.test.ts +++ b/test/client/index.test.ts @@ -5,6 +5,7 @@ import { getLocaleDictionary, $dictionary, } from '../../src/client/stores/dictionary' +import { $format } from '../../src/client/stores/format' test('defineMessages returns the identity of its first argument', () => { const obj = {} @@ -47,3 +48,26 @@ describe('waiting for a locale to load', () => { 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() + }) +})