Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b5f205965 |
@@ -42,8 +42,8 @@ test("a flash message's timer does not fire after cleanupPopup()", async () => {
|
|||||||
await wait(FLASH_MS * 5);
|
await wait(FLASH_MS * 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
// A boot onto a screen whose requests no mocked module answers: they reach the
|
// A boot onto a screen that sends a request no mocked module answers: that
|
||||||
// boot's fetch() stub, never the internet
|
// request reaches the boot's fetch() stub, never the internet
|
||||||
// (https://git.eeqj.de/sneak/AutistMask/issues/559).
|
// (https://git.eeqj.de/sneak/AutistMask/issues/559).
|
||||||
function restoringOnto(view, viewData) {
|
function restoringOnto(view, viewData) {
|
||||||
return unversionedValidProfile({
|
return unversionedValidProfile({
|
||||||
|
|||||||
@@ -261,10 +261,14 @@ async function settle() {
|
|||||||
async function bootPopup(stored, options) {
|
async function bootPopup(stored, options) {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
|
||||||
// Three of the modules that reach the network. None is on the path under
|
// The RPC requests made through src/shared/balances.js go through Node's
|
||||||
// test; all would make the suite hit the internet. Every other request,
|
// own http and https modules, not fetch(), so the fetch() stub below would
|
||||||
// such as the transaction screen's Blockscout lookup and the Etherscan
|
// not stop them, which is why that module stays mocked.
|
||||||
// lookup in src/shared/etherscanLabels.js, meets the fetch() stub below.
|
// src/shared/prices.js and src/shared/transactions.js send their requests
|
||||||
|
// through fetch(), and their mocks answer with no prices and no
|
||||||
|
// transactions. Every request the page still sends, such as the
|
||||||
|
// transaction screen's Blockscout lookup and the Etherscan lookup in
|
||||||
|
// src/shared/etherscanLabels.js, meets the fetch() stub.
|
||||||
jest.doMock("../../src/shared/prices", () => ({
|
jest.doMock("../../src/shared/prices", () => ({
|
||||||
prices: {},
|
prices: {},
|
||||||
refreshPrices: jest.fn(async () => {}),
|
refreshPrices: jest.fn(async () => {}),
|
||||||
@@ -338,8 +342,8 @@ async function bootPopup(stored, options) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Every fetch() the page makes fails, as it does elsewhere in the suite,
|
// Every fetch() the page makes fails, as it does elsewhere in the suite,
|
||||||
// instead of reaching the internet. A new stub per boot, so its calls are
|
// instead of reaching the internet. A new stub per boot, so the calls it
|
||||||
// that boot's requests. Put back by cleanupPopup().
|
// records start with that boot. Put back by cleanupPopup().
|
||||||
globalThis.fetch = jest.fn(() => {
|
globalThis.fetch = jest.fn(() => {
|
||||||
throw new Error("tests must not perform network requests");
|
throw new Error("tests must not perform network requests");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user