From 4f1fa2d15cbfc5578f63567e54a41694a7a4fffe Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 3 Nov 2025 14:43:21 -0500 Subject: [PATCH] test: additional logic to allow multi-typing in schema type --- test/api.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/api.js b/test/api.js index 80d88f0194..0137d29fd6 100644 --- a/test/api.js +++ b/test/api.js @@ -659,10 +659,15 @@ describe('API', async () => { case 'boolean': assert.strictEqual(typeof response[prop], 'boolean', `"${prop}" was expected to be a boolean, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`); break; - case 'object': - assert.strictEqual(typeof response[prop], 'object', `"${prop}" was expected to be an object, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`); + case 'object': { + let valid = ['object']; + if (schema[prop].additionalProperties && schema[prop].additionalProperties.oneOf) { + valid = schema[prop].additionalProperties.oneOf.map(({ type }) => type); + } + assert(valid.includes(typeof response[prop]), `"${prop}" was expected to be an object, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`); compare(schema[prop], response[prop], method, path, context ? [context, prop].join('.') : prop); break; + } case 'array': assert.strictEqual(Array.isArray(response[prop]), true, `"${prop}" was expected to be an array, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`);