-
Notifications
You must be signed in to change notification settings - Fork 7
/
spec.jsx
35 lines (29 loc) · 845 Bytes
/
spec.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import { mount } from 'enzyme';
import { i18n } from '@shopgate/engage/core';
import I18n from '../../index';
jest.unmock('@shopgate/engage/core/helpers/i18n');
describe('<Translate />', () => {
const locales = {
greeting: 'Hello {name}',
};
i18n.init({
locales,
lang: 'en-US',
});
describe('Given the component was mounted to the DOM', () => {
let renderedElement;
it('should match snapshot', () => {
renderedElement = mount((
<I18n.Provider>
<I18n.Text string="greeting" params={{ name: 'Test' }} />
</I18n.Provider>
));
expect(renderedElement).toMatchSnapshot();
});
it('should render translated text', () => {
const text = renderedElement.find(I18n.Text).text();
expect(text).toBe('Hello Test');
});
});
});