Comparing version 1.2.2 to 1.2.3
@@ -31,4 +31,4 @@ import { equal } from 'assert' | ||
reset() | ||
// const { main: withoutStub } = await import('./file-under-test.js') | ||
// equal(withoutStub, 'processed foo') | ||
const { main: withoutStub } = await import('./file-under-test.js') | ||
equal(withoutStub, 'processed foo--', 'Replacements were not reset') | ||
process.stdout.write('\x1B[32mAcceptance test passed\x1B[0m') |
@@ -13,2 +13,7 @@ import { FibbleState } from './state.js' | ||
} | ||
reset() { | ||
super.reset() | ||
this.localPort.postMessage(this.getValues()) | ||
} | ||
} |
@@ -10,2 +10,4 @@ import { assert } from 'chai' | ||
info.setValues({ | ||
replacedFiles: ['withDefault', 'withBoth', 'withKeys'], | ||
replacedFrom: ['parentURL_A'], | ||
defaultReplacements: { | ||
@@ -12,0 +14,0 @@ withDefault: true, |
@@ -7,2 +7,4 @@ export class FibbleInfo { | ||
this.replacedFromCount = {} | ||
this.replacedFiles = [] | ||
this.replacedFrom = [] | ||
} | ||
@@ -15,2 +17,4 @@ | ||
replacedFromCount, | ||
replacedFiles, | ||
replacedFrom, | ||
}) { | ||
@@ -21,2 +25,4 @@ this.defaultReplacements = defaultReplacements | ||
this.replacedFromCount = replacedFromCount | ||
this.replacedFiles = replacedFiles | ||
this.replacedFrom = replacedFrom | ||
} | ||
@@ -30,2 +36,4 @@ | ||
replacedFromCount: this.replacedFromCount, | ||
replacedFiles: this.replacedFiles, | ||
replacedFrom: this.replacedFrom, | ||
} | ||
@@ -50,7 +58,11 @@ } | ||
getURLCount(fullPath, parentURL) { | ||
const pathCount = this.counts[fullPath] | ||
if (pathCount != null) return pathCount | ||
const parentCount = this.replacedFromCount[parentURL] | ||
if (parentCount != null) return `${parentURL}-${parentCount}` | ||
if (this.replacedFiles.includes(fullPath)) { | ||
const pathCount = this.counts[fullPath] | ||
if (pathCount != null) return pathCount | ||
} | ||
if (this.replacedFrom.includes(parentURL)) { | ||
const parentCount = this.replacedFromCount[parentURL] | ||
if (parentCount != null) return `${parentURL}-${parentCount}` | ||
} | ||
} | ||
} |
@@ -16,6 +16,4 @@ import { replaceFileURL } from './utils.js' | ||
const count = fibbleInfo.getURLCount(url, parentURL) | ||
return count != null | ||
? shortCircuit(`${url}?__fibbleCount=${count}`) | ||
: nextResolve(specifier, context) | ||
return count != null ? shortCircuit(`${url}?__fibbleCount=${count}`) : nr | ||
} | ||
} |
@@ -88,4 +88,4 @@ import { assert } from 'chai' | ||
it('increases the count for all repaced items', () => { | ||
equal(state.getURLCount(path, replacedFrom), 2) | ||
it('removes the url count', () => { | ||
isUndefined(state.getURLCount(path, replacedFrom)) | ||
}) | ||
@@ -92,0 +92,0 @@ |
@@ -15,2 +15,4 @@ import { FibbleInfo } from './info.js' | ||
this.replacedFiles.push(fullPath) | ||
this.replacedFrom.push(parentURL) | ||
this.counts[fullPath] = currentCount + 1 | ||
@@ -26,5 +28,4 @@ this.replacedFromCount[parentURL] = currentReplacedFromCount + 1 | ||
reset() { | ||
Object.keys(this.replacements).forEach((key) => { | ||
this.counts[key] += 1 | ||
}) | ||
this.replacedFiles = [] | ||
this.replacedFrom = [] | ||
this.replacements = {} | ||
@@ -31,0 +32,0 @@ this.replacementKeys = {} |
{ | ||
"name": "fibble", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Small library to insert test doubles into your tests", | ||
@@ -41,2 +41,3 @@ "keywords": [ | ||
}, | ||
"packageManager": "pnpm@8.15.9", | ||
"engines": { | ||
@@ -43,0 +44,0 @@ "node": ">=16.12.0 <20.0.0 || >20.6.0" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26505
602