|
| 1 | +/// <reference types="cypress" /> |
| 2 | +import * as React from 'react' |
| 3 | +import i18n from './i18n' |
| 4 | +import { LocalizedComponent } from './LocalizedComponent' |
| 5 | +import { mount } from 'cypress-react-unit-test' |
| 6 | +import { I18nextProvider } from 'react-i18next' |
| 7 | + |
| 8 | +describe('i18n', () => { |
| 9 | + const localizedMount = (node, { locale }) => { |
| 10 | + mount( |
| 11 | + <I18nextProvider i18n={i18n.cloneInstance({ lng: locale })}> |
| 12 | + {node} |
| 13 | + </I18nextProvider>, |
| 14 | + ) |
| 15 | + } |
| 16 | + |
| 17 | + it('Plural in en', () => { |
| 18 | + localizedMount(<LocalizedComponent count={15} name="Josh" />, { |
| 19 | + locale: 'en', |
| 20 | + }) |
| 21 | + |
| 22 | + cy.contains('Hello Josh, you have 15 unread messages.') |
| 23 | + }) |
| 24 | + |
| 25 | + it('Single in en', () => { |
| 26 | + localizedMount(<LocalizedComponent count={1} name="Josh" />, { |
| 27 | + locale: 'en', |
| 28 | + }) |
| 29 | + |
| 30 | + cy.contains('Hello Josh, you have 1 unread message.') |
| 31 | + }) |
| 32 | + |
| 33 | + it('Plural in ru', () => { |
| 34 | + localizedMount(<LocalizedComponent count={15} name="Костя" />, { |
| 35 | + locale: 'ru', |
| 36 | + }) |
| 37 | + |
| 38 | + cy.contains('Привет, Костя, y тебя 15 непрочитанных сообщений.') |
| 39 | + }) |
| 40 | + |
| 41 | + it('Single in ru', () => { |
| 42 | + localizedMount(<LocalizedComponent count={1} name="Костя" />, { |
| 43 | + locale: 'ru', |
| 44 | + }) |
| 45 | + |
| 46 | + cy.contains('Привет, Костя, y тебя 1 непрочитанное сообщение.') |
| 47 | + }) |
| 48 | +}) |
0 commit comments