@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.cjs
CHANGED
|
@@ -684,12 +684,13 @@ var SpecificationBuilder = class {
|
|
|
684
684
|
*/
|
|
685
685
|
intercept(trigger, response) {
|
|
686
686
|
if (typeof response === "string") {
|
|
687
|
+
const slashIndex = response.indexOf("/");
|
|
688
|
+
if (slashIndex === -1) throw new Error(`.intercept(): file path must be 'adapter/filename.json' (e.g. 'openai/ingest-tech.json'), got '${response}'`);
|
|
689
|
+
const adapterName = response.slice(0, slashIndex);
|
|
690
|
+
if (adapterName !== trigger.adapter) throw new Error(`.intercept(): adapter mismatch - trigger uses '${trigger.adapter}' but file path starts with '${adapterName}/'`);
|
|
687
691
|
const filePath = (0, node_path.resolve)(this.testDir, "intercepts", response);
|
|
688
692
|
const data = JSON.parse((0, node_fs.readFileSync)(filePath, "utf8"));
|
|
689
|
-
const resolved = trigger.wrap
|
|
690
|
-
status: 200,
|
|
691
|
-
body: data
|
|
692
|
-
};
|
|
693
|
+
const resolved = trigger.wrap(data);
|
|
693
694
|
this.intercepts.push({
|
|
694
695
|
trigger,
|
|
695
696
|
response: resolved
|