From 3dd9aa86e05f6a19888d13b2149315a4e1c80d02 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Mon, 12 Dec 2022 09:03:31 +0100 Subject: [PATCH] update tests --- package-lock.json | 48 +++++++++---------- package.json | 4 +- .../custom-types/Translation.test.tsx | 5 -- .../custom-types/useTranslation.test.tsx | 16 +++---- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index abf6f9920..a909d7861 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "12.1.1", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.20.6", "html-parse-stringify": "^3.0.1" }, "devDependencies": { @@ -45,7 +45,7 @@ "eslint-plugin-react": "^7.16.0", "eslint-plugin-testing-library": "^3.10.1", "husky": "^3.0.3", - "i18next": "^22.0.1", + "i18next": "^22.4.2", "jest": "^24.8.0", "jest-cli": "^24.8.4", "lint-staged": "^8.1.3", @@ -1814,11 +1814,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", - "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.6.tgz", + "integrity": "sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==", "dependencies": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.13.11" }, "engines": { "node": ">=6.9.0" @@ -8113,9 +8113,9 @@ } }, "node_modules/i18next": { - "version": "22.0.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.0.1.tgz", - "integrity": "sha512-CRbtl6urEcIDbIzP4sGoPf9YuDNto1JgCRsfdvcVUOPb8nPAQ0azhPZiSdD5AFg/Erb58+/nDRmhm8bzVyjABQ==", + "version": "22.4.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.2.tgz", + "integrity": "sha512-5gRrkgJRxqsNMJWLZbcby60NuZjD5WtA8Yap7DmP42ccrzksaXpT11JC5505IWHqGoywuESSAgtlif2awtQF7A==", "dev": true, "funding": [ { @@ -8132,7 +8132,7 @@ } ], "dependencies": { - "@babel/runtime": "^7.17.2" + "@babel/runtime": "^7.20.6" } }, "node_modules/iconv-lite": { @@ -13005,9 +13005,9 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", - "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "node_modules/regenerator-transform": { "version": "0.14.5", @@ -16539,11 +16539,11 @@ } }, "@babel/runtime": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.19.4.tgz", - "integrity": "sha512-EXpLCrk55f+cYqmHsSR+yD/0gAIMxxA9QK9lnQWzhMCvt+YmoBN7Zx94s++Kv0+unHk39vxNO8t+CMA2WSS3wA==", + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.6.tgz", + "integrity": "sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==", "requires": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.13.11" } }, "@babel/runtime-corejs3": { @@ -21522,12 +21522,12 @@ } }, "i18next": { - "version": "22.0.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.0.1.tgz", - "integrity": "sha512-CRbtl6urEcIDbIzP4sGoPf9YuDNto1JgCRsfdvcVUOPb8nPAQ0azhPZiSdD5AFg/Erb58+/nDRmhm8bzVyjABQ==", + "version": "22.4.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.4.2.tgz", + "integrity": "sha512-5gRrkgJRxqsNMJWLZbcby60NuZjD5WtA8Yap7DmP42ccrzksaXpT11JC5505IWHqGoywuESSAgtlif2awtQF7A==", "dev": true, "requires": { - "@babel/runtime": "^7.17.2" + "@babel/runtime": "^7.20.6" } }, "iconv-lite": { @@ -25453,9 +25453,9 @@ } }, "regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", - "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "regenerator-transform": { "version": "0.14.5", diff --git a/package.json b/package.json index 0be97cc5a..ea0d531ee 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "url": "https://github.com/i18next/react-i18next.git" }, "dependencies": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.20.6", "html-parse-stringify": "^3.0.1" }, "devDependencies": { @@ -78,7 +78,7 @@ "eslint-plugin-react": "^7.16.0", "eslint-plugin-testing-library": "^3.10.1", "husky": "^3.0.3", - "i18next": "^22.0.1", + "i18next": "^22.4.2", "jest": "^24.8.0", "jest-cli": "^24.8.4", "lint-staged": "^8.1.3", diff --git a/test/typescript/custom-types/Translation.test.tsx b/test/typescript/custom-types/Translation.test.tsx index 4012b53b2..b867c32fb 100644 --- a/test/typescript/custom-types/Translation.test.tsx +++ b/test/typescript/custom-types/Translation.test.tsx @@ -36,11 +36,6 @@ function expectErrorWhenKeyNotInNamespace() { return {(t) => <>{t('fake')}}; } -function expectErrorWhenUsingArrayNamespaceAndUnscopedKey() { - // @ts-expect-error - return {(t) => <>{t('foo')}}; -} - function expectErrorWhenUsingArrayNamespaceAndWrongKey() { // @ts-expect-error return {(t) => <>{t('custom:fake')}}; diff --git a/test/typescript/custom-types/useTranslation.test.tsx b/test/typescript/custom-types/useTranslation.test.tsx index 55b6e9fa9..e52193625 100644 --- a/test/typescript/custom-types/useTranslation.test.tsx +++ b/test/typescript/custom-types/useTranslation.test.tsx @@ -22,7 +22,9 @@ function arrayNamespace() { return ( <> {t('alternate:baz')} + {t('baz', { ns: 'alternate' })} {t('custom:foo')} + {t('foo', { ns: 'custom' })} ); } @@ -33,7 +35,9 @@ function readonlyArrayNamespace() { return ( <> {t('alternate:baz')} + {t('baz', { ns: 'alternate' })} {t('custom:foo')} + {t('foo', { ns: 'custom' })} ); } @@ -47,7 +51,7 @@ function deepKeyPrefixOption() { const [t] = useTranslation('alternate', { keyPrefix: 'foobar.deep' }); return ( <> - {t('deeper').deeeeeper} + {t('deeper', { returnObjects: true }).deeeeeper} {t('deeper.deeeeeper')} ); @@ -75,16 +79,12 @@ function expectErrorWhenKeyNotInNamespace() { return <>{t('fake')}; } -function expectErrorWhenUsingArrayNamespaceAndUnscopedKey() { - const [t] = useTranslation(['custom']); - // @ts-expect-error - return <>{t('foo')}; -} - function expectErrorWhenUsingArrayNamespaceAndWrongKey() { const [t] = useTranslation(['custom']); // @ts-expect-error - return <>{t('custom:fake')}; + <>{t('custom:fake')}; + // @ts-expect-error + return <>{t('fake', { ns: 'custom' })}; } function expectErrorWhenUsingWrongKeyPrefixOption() {