Migrate KeyboardShortcut tests from Enzyme to RTL (#9405)
* Migrate tests from Enzyme to RTL * Fix languageHandler tests Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
aa9f8eac52
commit
4c8b4116eb
5 changed files with 1082 additions and 281 deletions
|
@ -100,6 +100,16 @@ describe('languageHandler', function() {
|
|||
],
|
||||
];
|
||||
|
||||
let oldNodeEnv;
|
||||
beforeAll(() => {
|
||||
oldNodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = "test";
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
process.env.NODE_ENV = oldNodeEnv;
|
||||
});
|
||||
|
||||
describe('when translations exist in language', () => {
|
||||
beforeEach(function(done) {
|
||||
stubClient();
|
||||
|
@ -115,7 +125,7 @@ describe('languageHandler', function() {
|
|||
}).then(done);
|
||||
});
|
||||
|
||||
it.each(testCasesEn)("%s", async (_d, translationString, variables, tags, result) => {
|
||||
it.each(testCasesEn)("%s", (_d, translationString, variables, tags, result) => {
|
||||
expect(_t(translationString, variables, tags)).toEqual(result);
|
||||
});
|
||||
|
||||
|
@ -137,9 +147,9 @@ describe('languageHandler', function() {
|
|||
});
|
||||
|
||||
describe('for a non-en language', () => {
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
await setLanguage('lv');
|
||||
setLanguage('lv');
|
||||
// counterpart doesnt expose any way to restore default config
|
||||
// missingEntryGenerator is mocked in the root setup file
|
||||
// reset to default here
|
||||
|
@ -178,7 +188,7 @@ describe('languageHandler', function() {
|
|||
});
|
||||
it.each(pluralCases)(
|
||||
"%s",
|
||||
async (_d, translationString, variables, tags, result) => {
|
||||
(_d, translationString, variables, tags, result) => {
|
||||
expect(_t(translationString, variables, tags)).toEqual(result);
|
||||
},
|
||||
);
|
||||
|
@ -192,7 +202,7 @@ describe('languageHandler', function() {
|
|||
});
|
||||
it.each(pluralCases)(
|
||||
"%s and translates with fallback locale, attributes fallback locale",
|
||||
async (_d, translationString, variables, tags, result) => {
|
||||
(_d, translationString, variables, tags, result) => {
|
||||
expect(_tDom(translationString, variables, tags)).toEqual(<span lang="en">{ result }</span>);
|
||||
},
|
||||
);
|
||||
|
@ -203,7 +213,7 @@ describe('languageHandler', function() {
|
|||
describe('_t', () => {
|
||||
it.each(testCasesEn)(
|
||||
"%s and translates with fallback locale",
|
||||
async (_d, translationString, variables, tags, result) => {
|
||||
(_d, translationString, variables, tags, result) => {
|
||||
expect(_t(translationString, variables, tags)).toEqual(result);
|
||||
},
|
||||
);
|
||||
|
@ -212,7 +222,7 @@ describe('languageHandler', function() {
|
|||
describe('_tDom()', () => {
|
||||
it.each(testCasesEn)(
|
||||
"%s and translates with fallback locale, attributes fallback locale",
|
||||
async (_d, translationString, variables, tags, result) => {
|
||||
(_d, translationString, variables, tags, result) => {
|
||||
expect(_tDom(translationString, variables, tags)).toEqual(<span lang="en">{ result }</span>);
|
||||
},
|
||||
);
|
||||
|
@ -221,12 +231,12 @@ describe('languageHandler', function() {
|
|||
});
|
||||
|
||||
describe('when languages dont load', () => {
|
||||
it('_t', async () => {
|
||||
it('_t', () => {
|
||||
const STRING_NOT_IN_THE_DICTIONARY = "a string that isn't in the translations dictionary";
|
||||
expect(_t(STRING_NOT_IN_THE_DICTIONARY, {}, undefined)).toEqual(STRING_NOT_IN_THE_DICTIONARY);
|
||||
});
|
||||
|
||||
it('_tDom', async () => {
|
||||
it('_tDom', () => {
|
||||
const STRING_NOT_IN_THE_DICTIONARY = "a string that isn't in the translations dictionary";
|
||||
expect(_tDom(STRING_NOT_IN_THE_DICTIONARY, {}, undefined)).toEqual(
|
||||
<span lang="en">{ STRING_NOT_IN_THE_DICTIONARY }</span>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue