[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant-backoffice] 03/03: mocking local storage in tests
From: |
gnunet |
Subject: |
[taler-merchant-backoffice] 03/03: mocking local storage in tests |
Date: |
Sat, 08 Jan 2022 11:04:08 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository merchant-backoffice.
commit 5de299e258fecb2893b44bca28ab0f1052e23c90
Author: ms <ms@taler.net>
AuthorDate: Sat Jan 8 11:03:56 2022 +0100
mocking local storage in tests
---
packages/bank/build-bank-translations.sh | 3 +++
packages/bank/tests/__tests__/homepage.js | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/packages/bank/build-bank-translations.sh
b/packages/bank/build-bank-translations.sh
index 8258efe..85c8ad0 100755
--- a/packages/bank/build-bank-translations.sh
+++ b/packages/bank/build-bank-translations.sh
@@ -2,6 +2,9 @@
set -eu
+# NOTE: the <Translate> node somehow didn't get
+# the strings extracted. Only i18n`` did
+
function build {
POTGEN=node_modules/@gnu-taler/pogen/bin/pogen
PACKAGE_NAME=$1
diff --git a/packages/bank/tests/__tests__/homepage.js
b/packages/bank/tests/__tests__/homepage.js
index 458bc2a..0145522 100644
--- a/packages/bank/tests/__tests__/homepage.js
+++ b/packages/bank/tests/__tests__/homepage.js
@@ -7,6 +7,14 @@ import { waitFor, cleanup, render, fireEvent, screen } from
'@testing-library/pr
import expect from 'expect';
import fetchMock from "jest-fetch-mock";
+/**
+ * This mock makes the translator always return the
+ * english string. It didn't work within the 'beforeAll'
+ * function...
+ */
+jest.mock("../../src/i18n")
+const i18n = require("../../src/i18n")
+i18n.useTranslator.mockImplementation(() => function(arg) {return arg})
beforeAll(() => {
Object.defineProperty(window, 'location', {
@@ -15,6 +23,10 @@ beforeAll(() => {
pathname: "/demobanks/default"
}
})
+ // Invalidating local storage: makes it more difficult
+ // to isolate the individual tests, and it doesn't really
+ // participate in the SPA logic.
+ global.Storage.prototype.setItem = jest.fn((key, value) => {})
})
/**
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.