@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 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 ? trigger.wrap(data) : {
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