@jterrazz/test 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/intercept.cjs +40 -28
- package/dist/intercept.cjs.map +1 -1
- package/dist/intercept.d.cts +15 -13
- package/dist/intercept.d.ts +15 -13
- package/dist/intercept.js +40 -28
- package/dist/intercept.js.map +1 -1
- package/dist/types.d.cts +5 -4
- package/dist/types.d.ts +5 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -682,12 +682,13 @@ var SpecificationBuilder = class {
|
|
|
682
682
|
*/
|
|
683
683
|
intercept(trigger, response) {
|
|
684
684
|
if (typeof response === "string") {
|
|
685
|
+
const slashIndex = response.indexOf("/");
|
|
686
|
+
if (slashIndex === -1) throw new Error(`.intercept(): file path must be 'adapter/filename.json' (e.g. 'openai/ingest-tech.json'), got '${response}'`);
|
|
687
|
+
const adapterName = response.slice(0, slashIndex);
|
|
688
|
+
if (adapterName !== trigger.adapter) throw new Error(`.intercept(): adapter mismatch - trigger uses '${trigger.adapter}' but file path starts with '${adapterName}/'`);
|
|
685
689
|
const filePath = resolve(this.testDir, "intercepts", response);
|
|
686
690
|
const data = JSON.parse(readFileSync(filePath, "utf8"));
|
|
687
|
-
const resolved = trigger.wrap
|
|
688
|
-
status: 200,
|
|
689
|
-
body: data
|
|
690
|
-
};
|
|
691
|
+
const resolved = trigger.wrap(data);
|
|
691
692
|
this.intercepts.push({
|
|
692
693
|
trigger,
|
|
693
694
|
response: resolved
|