From 86aac28fd8d32c00ea3b0df7cc4824afd7ec5b21 Mon Sep 17 00:00:00 2001 From: Richard Lindner Date: Thu, 28 Sep 2023 14:14:01 +0200 Subject: [PATCH] Fix/inline snapshot indent (#30) * re-do jest indents with snapshot patch * add script to remove all inline snapshots * linter --- package.json | 1 + patches/jest-snapshot+29.7.0.patch | 32 +++ .../featureToggles.integration.test.js | 260 +++++++++--------- test/logger.test.js | 174 ++++++------ test/shared/cache.test.js | 74 ++--- 5 files changed, 287 insertions(+), 254 deletions(-) create mode 100644 patches/jest-snapshot+29.7.0.patch diff --git a/package.json b/package.json index f9228f3..0d0d42e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ ], "scripts": { "test": "jest", + "test:remove-inline-snapshots": "npx replace '\\.toMatchInlineSnapshot\\(\\s*`[\\s\\S]*?`\\s*\\);' '.toMatchInlineSnapshot();' test -r --include='*.test.js'", "lint": "npm run prettier && npm run eslint", "lint:ci": "npm run prettier:ci && npm run eslint:ci", "eslint": "eslint --fix .", diff --git a/patches/jest-snapshot+29.7.0.patch b/patches/jest-snapshot+29.7.0.patch new file mode 100644 index 0000000..2ee8c04 --- /dev/null +++ b/patches/jest-snapshot+29.7.0.patch @@ -0,0 +1,32 @@ +diff --git a/node_modules/jest-snapshot/build/InlineSnapshots.js b/node_modules/jest-snapshot/build/InlineSnapshots.js +index 3481ad9..3c227dd 100644 +--- a/node_modules/jest-snapshot/build/InlineSnapshots.js ++++ b/node_modules/jest-snapshot/build/InlineSnapshots.js +@@ -193,11 +193,24 @@ const saveSnapshotsForFile = (snapshots, sourceFilePath, rootDir, prettier) => { + + // A hack to prevent unexpected line breaks in the generated code + node.loc.end.line = node.loc.start.line; ++ const codeParts = generate(node, { ++ retainLines: true ++ }).code.trim().split("\n"); ++ const codeIndented = codeParts ++ .map((part, index) => { ++ switch (index) { ++ case 0: ++ return part; ++ case codeParts.length - 1: ++ return " ".repeat(node.loc.start.column) + part; ++ default: ++ return " ".repeat(node.loc.start.column + 2) + part; ++ } ++ }) ++ .join("\n"); + return ( + sourceSoFar.slice(0, node.start) + +- generate(node, { +- retainLines: true +- }).code.trim() + ++ codeIndented + + sourceSoFar.slice(node.end) + ); + }, diff --git a/test/integration-local/featureToggles.integration.test.js b/test/integration-local/featureToggles.integration.test.js index c3a0841..fa61d4c 100644 --- a/test/integration-local/featureToggles.integration.test.js +++ b/test/integration-local/featureToggles.integration.test.js @@ -259,29 +259,29 @@ describe("local integration test", () => { expect(featureTogglesLoggerSpy.error).toHaveBeenCalledTimes(0); expect(featureTogglesLoggerSpy.info.mock.calls).toMatchInlineSnapshot(` - [ - [ - "finished initialization with %i feature toggle%s with %s", - 8, - "s", - "NO_REDIS", - ], - ] - `); + [ + [ + "finished initialization with %i feature toggle%s with %s", + 8, + "s", + "NO_REDIS", + ], + ] + `); expect(featureTogglesLoggerSpy.warning).toHaveBeenCalledTimes(0); expect(featureTogglesLoggerSpy.error).toHaveBeenCalledTimes(0); expect(redisWrapperLoggerSpy.info).toHaveBeenCalledTimes(0); expect(redisWrapperLoggerSpy.warning.mock.calls).toMatchInlineSnapshot(` - [ - [ - "%s | %O", - "caught error event: connect ECONNREFUSED 127.0.0.1:6379", - { - "clientName": "main", - }, - ], - ] - `); + [ + [ + "%s | %O", + "caught error event: connect ECONNREFUSED 127.0.0.1:6379", + { + "clientName": "main", + }, + ], + ] + `); }); it("getFeatureValue, changeFeatureValue without scopes", async () => { @@ -295,22 +295,22 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, newValue)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "rootValue": 9, - } - `); + { + "rootValue": 9, + } + `); expect(getFeatureValue(FEATURE.E)).toEqual(newValue); expect(featureTogglesLoggerSpy.info.mock.calls).toMatchInlineSnapshot(` - [ - [ - "finished initialization with %i feature toggle%s with %s", - 8, - "s", - "NO_REDIS", - ], - ] - `); + [ + [ + "finished initialization with %i feature toggle%s with %s", + 8, + "s", + "NO_REDIS", + ], + ] + `); expect(featureTogglesLoggerSpy.warning).toHaveBeenCalledTimes(0); expect(featureTogglesLoggerSpy.error).toHaveBeenCalledTimes(0); expect(redisWrapperLoggerSpy.info).toHaveBeenCalledTimes(0); @@ -385,12 +385,12 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, scopeNewValue, scopeMap)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "scopedValues": { - "component::c1##tenant::t1": 3, - }, - } - `); + { + "scopedValues": { + "component::c1##tenant::t1": 3, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(rootOldValue); @@ -398,13 +398,13 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, superScopeNewValue, superScopeMap)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "scopedValues": { - "component::c1##tenant::t1": 3, - "tenant::t1": 2, - }, - } - `); + { + "scopedValues": { + "component::c1##tenant::t1": 3, + "tenant::t1": 2, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(superScopeNewValue); @@ -412,14 +412,14 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, subScopeNewValue, subScopeMap)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "scopedValues": { - "component::c1##layer::l1##tenant::t1": 4, - "component::c1##tenant::t1": 3, - "tenant::t1": 2, - }, - } - `); + { + "scopedValues": { + "component::c1##layer::l1##tenant::t1": 4, + "component::c1##tenant::t1": 3, + "tenant::t1": 2, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(subScopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(superScopeNewValue); @@ -427,30 +427,30 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, rootNewValue)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "rootValue": 1, - "scopedValues": { - "component::c1##layer::l1##tenant::t1": 4, - "component::c1##tenant::t1": 3, - "tenant::t1": 2, - }, - } - `); + { + "rootValue": 1, + "scopedValues": { + "component::c1##layer::l1##tenant::t1": 4, + "component::c1##tenant::t1": 3, + "tenant::t1": 2, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(subScopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(superScopeNewValue); expect(getFeatureValue(FEATURE.E)).toEqual(rootNewValue); expect(featureTogglesLoggerSpy.info.mock.calls).toMatchInlineSnapshot(` - [ - [ - "finished initialization with %i feature toggle%s with %s", - 8, - "s", - "NO_REDIS", - ], - ] - `); + [ + [ + "finished initialization with %i feature toggle%s with %s", + 8, + "s", + "NO_REDIS", + ], + ] + `); expect(featureTogglesLoggerSpy.warning).toHaveBeenCalledTimes(0); expect(featureTogglesLoggerSpy.error).toHaveBeenCalledTimes(0); expect(redisWrapperLoggerSpy.info).toHaveBeenCalledTimes(0); @@ -474,15 +474,15 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, subScopeNewValue, subScopeMap)).toBeUndefined(); expect(await changeFeatureValue(FEATURE.E, rootNewValue)).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "rootValue": 1, - "scopedValues": { - "component::c1##layer::l1##tenant::t1": 4, - "component::c1##tenant::t1": 3, - "tenant::t1": 2, - }, - } - `); + { + "rootValue": 1, + "scopedValues": { + "component::c1##layer::l1##tenant::t1": 4, + "component::c1##tenant::t1": 3, + "tenant::t1": 2, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(subScopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(superScopeNewValue); @@ -490,14 +490,14 @@ describe("local integration test", () => { expect(await changeFeatureValue(FEATURE.E, scopeNewValue, scopeMap, { clearSubScopes: true })).toBeUndefined(); expect(stateFromInfo(getFeatureInfo(FEATURE.E))).toMatchInlineSnapshot(` - { - "rootValue": 1, - "scopedValues": { - "component::c1##tenant::t1": 3, - "tenant::t1": 2, - }, - } - `); + { + "rootValue": 1, + "scopedValues": { + "component::c1##tenant::t1": 3, + "tenant::t1": 2, + }, + } + `); expect(getFeatureValue(FEATURE.E, subScopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, scopeMap)).toEqual(scopeNewValue); expect(getFeatureValue(FEATURE.E, superScopeMap)).toEqual(superScopeNewValue); @@ -511,15 +511,15 @@ describe("local integration test", () => { expect(getFeatureValue(FEATURE.E)).toEqual(rootOldValue); expect(featureTogglesLoggerSpy.info.mock.calls).toMatchInlineSnapshot(` - [ - [ - "finished initialization with %i feature toggle%s with %s", - 8, - "s", - "NO_REDIS", - ], - ] - `); + [ + [ + "finished initialization with %i feature toggle%s with %s", + 8, + "s", + "NO_REDIS", + ], + ] + `); expect(featureTogglesLoggerSpy.warning).toHaveBeenCalledTimes(0); expect(featureTogglesLoggerSpy.error).toHaveBeenCalledTimes(0); expect(redisWrapperLoggerSpy.info).toHaveBeenCalledTimes(0); @@ -592,41 +592,41 @@ describe("local integration test", () => { expect(await validateFeatureValue(FEATURE.C, "")).toMatchInlineSnapshot(`[]`); registerFeatureValueValidation(FEATURE.C, failingValidator1); expect(await validateFeatureValue(FEATURE.C, "")).toMatchInlineSnapshot(` - [ - { - "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", - "errorMessageValues": [ - "failingValidator1", - "", - "bla1", - ], - "featureKey": "test/feature_c", - }, - ] - `); + [ + { + "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", + "errorMessageValues": [ + "failingValidator1", + "", + "bla1", + ], + "featureKey": "test/feature_c", + }, + ] + `); registerFeatureValueValidation(FEATURE.C, failingValidator2); expect(await validateFeatureValue(FEATURE.C, "")).toMatchInlineSnapshot(` - [ - { - "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", - "errorMessageValues": [ - "failingValidator1", - "", - "bla1", - ], - "featureKey": "test/feature_c", - }, - { - "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", - "errorMessageValues": [ - "failingValidator2", - "", - "bla2", - ], - "featureKey": "test/feature_c", - }, - ] - `); + [ + { + "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", + "errorMessageValues": [ + "failingValidator1", + "", + "bla1", + ], + "featureKey": "test/feature_c", + }, + { + "errorMessage": "registered validator "{0}" failed for value "{1}" with error {2}", + "errorMessageValues": [ + "failingValidator2", + "", + "bla2", + ], + "featureKey": "test/feature_c", + }, + ] + `); }); }); }); diff --git a/test/logger.test.js b/test/logger.test.js index 267dfef..454b23d 100644 --- a/test/logger.test.js +++ b/test/logger.test.js @@ -77,31 +77,31 @@ describe("logger test", () => { await featureToggles.initializeFeatures({ config: mockConfig }); expect(processStreamSpy.stdout.mock.calls.map(cleanupTextLogCalls)).toMatchInlineSnapshot(` -[ - [ - "88:88:88.888 | WARN | /test | FeatureTogglesError: found invalid fallback values during initialization -{ - validationErrors: '[{"featureKey":"test/feature_b","errorMessage":"registered validator \\\\"{0}\\\\" failed for value \\\\"{1}\\\\" with error {2}","errorMessageValues":["mockConstructor",1,"bad validator"]}]' -}", - ], - [ - "88:88:88.888 | INFO | /test | finished initialization with 9 feature toggles with CF_REDIS", - ], -] -`); + [ + [ + "88:88:88.888 | WARN | /test | FeatureTogglesError: found invalid fallback values during initialization + { + validationErrors: '[{"featureKey":"test/feature_b","errorMessage":"registered validator \\\\"{0}\\\\" failed for value \\\\"{1}\\\\" with error {2}","errorMessageValues":["mockConstructor",1,"bad validator"]}]' + }", + ], + [ + "88:88:88.888 | INFO | /test | finished initialization with 9 feature toggles with CF_REDIS", + ], + ] + `); expect(processStreamSpy.stderr.mock.calls.map(cleanupTextLogCalls)).toMatchInlineSnapshot(` -[ - [ - "88:88:88.888 | ERROR | /test | FeatureTogglesError: error during registered validator: bad validator -caused by: Error: bad validator -{ - validator: 'mockConstructor', - featureKey: 'test/feature_b', - value: 1 -}", - ], -] -`); + [ + [ + "88:88:88.888 | ERROR | /test | FeatureTogglesError: error during registered validator: bad validator + caused by: Error: bad validator + { + validator: 'mockConstructor', + featureKey: 'test/feature_b', + value: 1 + }", + ], + ] + `); }); it("check json logging for invalid fallback values during initialization", async () => { @@ -115,22 +115,22 @@ caused by: Error: bad validator const logStderrCalls = processStreamSpy.stderr.mock.calls.map(cleanupJsonLogCalls); const logStdoutCalls = processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls); expect(logStderrCalls).toMatchInlineSnapshot(` -[ - [ - "{"level":"error","msg":"FeatureTogglesError: error during registered validator: bad validator\\ncaused by: Error: bad validator\\n{\\n validator: 'mockConstructor',\\n featureKey: 'test/feature_b',\\n value: 1\\n}","type":"log","layer":"/test"}", - ], -] -`); + [ + [ + "{"level":"error","msg":"FeatureTogglesError: error during registered validator: bad validator\\ncaused by: Error: bad validator\\n{\\n validator: 'mockConstructor',\\n featureKey: 'test/feature_b',\\n value: 1\\n}","type":"log","layer":"/test"}", + ], + ] + `); expect(logStdoutCalls).toMatchInlineSnapshot(` -[ - [ - "{"level":"warn","msg":"FeatureTogglesError: found invalid fallback values during initialization\\n{\\n validationErrors: '[{\\"featureKey\\":\\"test/feature_b\\",\\"errorMessage\\":\\"registered validator \\\\\\\\\\"{0}\\\\\\\\\\" failed for value \\\\\\\\\\"{1}\\\\\\\\\\" with error {2}\\",\\"errorMessageValues\\":[\\"mockConstructor\\",1,\\"bad validator\\"]}]'\\n}","type":"log","layer":"/test"}", - ], - [ - "{"level":"info","msg":"finished initialization with 9 feature toggles with CF_REDIS","type":"log","layer":"/test"}", - ], -] -`); + [ + [ + "{"level":"warn","msg":"FeatureTogglesError: found invalid fallback values during initialization\\n{\\n validationErrors: '[{\\"featureKey\\":\\"test/feature_b\\",\\"errorMessage\\":\\"registered validator \\\\\\\\\\"{0}\\\\\\\\\\" failed for value \\\\\\\\\\"{1}\\\\\\\\\\" with error {2}\\",\\"errorMessageValues\\":[\\"mockConstructor\\",1,\\"bad validator\\"]}]'\\n}","type":"log","layer":"/test"}", + ], + [ + "{"level":"info","msg":"finished initialization with 9 feature toggles with CF_REDIS","type":"log","layer":"/test"}", + ], + ] + `); const [registerValidatorError] = logStderrCalls.map(([log]) => JSON.parse(log)); const [initializeError] = logStdoutCalls.map(([log]) => JSON.parse(log)); expect(registerValidatorError.msg).toContain("bad validator"); @@ -142,10 +142,10 @@ caused by: Error: bad validator logger = new Logger("", { format: FORMAT.TEXT }); logger.info("some info"); expect(processStreamSpy.stdout.mock.calls.map(cleanupTextLogCalls)[0]).toMatchInlineSnapshot(` -[ - "88:88:88.888 | INFO | some info", -] -`); + [ + "88:88:88.888 | INFO | some info", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(1); }); @@ -153,10 +153,10 @@ caused by: Error: bad validator logger = new Logger(layer, { format: FORMAT.JSON }); logger.info("some info"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[0]).toMatchInlineSnapshot(` -[ - "{"level":"info","msg":"some info","type":"log","layer":"/test"}", -] -`); + [ + "{"level":"info","msg":"some info","type":"log","layer":"/test"}", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(1); }); @@ -164,10 +164,10 @@ caused by: Error: bad validator logger = new Logger(layer, { format: FORMAT.TEXT }); logger.info("some info"); expect(processStreamSpy.stdout.mock.calls.map(cleanupTextLogCalls)[0]).toMatchInlineSnapshot(` -[ - "88:88:88.888 | INFO | /test | some info", -] -`); + [ + "88:88:88.888 | INFO | /test | some info", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(1); }); @@ -176,10 +176,10 @@ caused by: Error: bad validator logger = new Logger(layer); logger.info("some info"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[0]).toMatchInlineSnapshot(` -[ - "{"level":"info","msg":"some info","type":"log","layer":"/test"}", -] -`); + [ + "{"level":"info","msg":"some info","type":"log","layer":"/test"}", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(1); }); @@ -193,19 +193,19 @@ caused by: Error: bad validator expect(processStreamSpy.stderr.mock.calls.length).toBe(0); logger.warning("some warning"); expect(processStreamSpy.stdout.mock.calls.map(cleanupTextLogCalls)[0]).toMatchInlineSnapshot(` -[ - "88:88:88.888 | WARN | /test | some warning", -] -`); + [ + "88:88:88.888 | WARN | /test | some warning", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(1); expect(processStreamSpy.stderr.mock.calls.length).toBe(0); processStreamSpy.stdout.mockClear(); logger.error("some error"); expect(processStreamSpy.stderr.mock.calls.map(cleanupTextLogCalls)[0]).toMatchInlineSnapshot(` -[ - "88:88:88.888 | ERROR | /test | some error", -] -`); + [ + "88:88:88.888 | ERROR | /test | some error", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(0); expect(processStreamSpy.stderr.mock.calls.length).toBe(1); Reflect.deleteProperty(process.env, ENV.LOG_LEVEL); @@ -222,10 +222,10 @@ caused by: Error: bad validator expect(processStreamSpy.stderr.mock.calls.length).toBe(0); logger.error("some error"); expect(processStreamSpy.stderr.mock.calls.map(cleanupTextLogCalls)[0]).toMatchInlineSnapshot(` -[ - "88:88:88.888 | ERROR | /test | some error", -] -`); + [ + "88:88:88.888 | ERROR | /test | some error", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(0); expect(processStreamSpy.stderr.mock.calls.length).toBe(1); Reflect.deleteProperty(process.env, ENV.LOG_LEVEL); @@ -235,10 +235,10 @@ caused by: Error: bad validator logger = new Logger(layer, { format: FORMAT.JSON }); logger.error(new VError("bla error")); expect(processStreamSpy.stderr.mock.calls.map(cleanupJsonLogCalls)[0]).toMatchInlineSnapshot(` -[ - "{"level":"error","msg":"VError: bla error","type":"log","layer":"/test"}", -] -`); + [ + "{"level":"error","msg":"VError: bla error","type":"log","layer":"/test"}", + ] + `); expect(processStreamSpy.stderr.mock.calls.length).toBe(1); }); @@ -251,28 +251,28 @@ caused by: Error: bad validator logger.info("base"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[i++]).toMatchInlineSnapshot(` -[ - "{"level":"info","msg":"base","type":"log","layer":"/test"}", -] -`); + [ + "{"level":"info","msg":"base","type":"log","layer":"/test"}", + ] + `); childLogger.info("child"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[i++]).toMatchInlineSnapshot(` -[ - "{"isChild":true,"level":"info","msg":"child","type":"log","layer":"/test"}", -] -`); + [ + "{"isChild":true,"level":"info","msg":"child","type":"log","layer":"/test"}", + ] + `); siblingLogger.info("sibling"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[i++]).toMatchInlineSnapshot(` -[ - "{"isSibling":true,"level":"info","msg":"sibling","type":"log","layer":"/test"}", -] -`); + [ + "{"isSibling":true,"level":"info","msg":"sibling","type":"log","layer":"/test"}", + ] + `); childChildLogger.info("child child"); expect(processStreamSpy.stdout.mock.calls.map(cleanupJsonLogCalls)[i++]).toMatchInlineSnapshot(` -[ - "{"isChild":true,"isChildChild":true,"level":"info","msg":"child child","type":"log","layer":"/test"}", -] -`); + [ + "{"isChild":true,"isChildChild":true,"level":"info","msg":"child child","type":"log","layer":"/test"}", + ] + `); expect(processStreamSpy.stdout.mock.calls.length).toBe(i); }); }); diff --git a/test/shared/cache.test.js b/test/shared/cache.test.js index c747d7b..6a825df 100644 --- a/test/shared/cache.test.js +++ b/test/shared/cache.test.js @@ -58,22 +58,22 @@ describe("cache", () => { expect(await cache.get("c with cbA")).toBe("c with cbA"); expect(await cache._dataSettled()).toMatchInlineSnapshot(` - { - "": "empty", - "a": "a", - "a with cb": "a with cb", - "a with cbA": "a with cbA", - "a##b": "ab", - "a##b##c": "abc", - "b": "b", - "b with cb": "b with cb", - "b with cbA": "b with cbA", - "c": "c", - "c with cb": "c with cb", - "c with cbA": "c with cbA", - "d": "d", - } - `); + { + "": "empty", + "a": "a", + "a with cb": "a with cb", + "a with cbA": "a with cbA", + "a##b": "ab", + "a##b##c": "abc", + "b": "b", + "b with cb": "b with cb", + "b with cbA": "b with cbA", + "c": "c", + "c with cb": "c with cb", + "c with cbA": "c with cbA", + "d": "d", + } + `); }); test("getSetCb/getSetCbAsync", async () => { @@ -88,11 +88,11 @@ describe("cache", () => { expect(cbAsyncSpy).toHaveBeenCalledTimes(1); expect(await cache._dataSettled()).toMatchInlineSnapshot(` - { - "a": "a result", - "b": "b result", - } - `); + { + "a": "a result", + "b": "b result", + } + `); }); test("count/delete/clear", async () => { @@ -356,22 +356,22 @@ describe("cache", () => { expect(await cache.get("c with cbA")).toBe("c with cbA"); expect(await cache._dataSettled()).toMatchInlineSnapshot(` - { - "": "empty", - "a": "a", - "a with cb": "a with cb", - "a with cbA": "a with cbA", - "a##b": "ab", - "a##b##c": "abc", - "b": "b", - "b with cb": "b with cb", - "b with cbA": "b with cbA", - "c": "c", - "c with cb": "c with cb", - "c with cbA": "c with cbA", - "d": "d", - } - `); + { + "": "empty", + "a": "a", + "a with cb": "a with cb", + "a with cbA": "a with cbA", + "a##b": "ab", + "a##b##c": "abc", + "b": "b", + "b with cb": "b with cb", + "b with cbA": "b with cbA", + "c": "c", + "c with cb": "c with cb", + "c with cbA": "c with cbA", + "d": "d", + } + `); }); test("has/get/set/setCb/setCbAsync with low limit", async () => {