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