47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import test from 'node:test';
|
|
|
|
const openapi = JSON.parse(
|
|
readFileSync(
|
|
new URL(
|
|
'../../docs/investmoz/simulations/openapi.json',
|
|
import.meta.url,
|
|
),
|
|
'utf8',
|
|
),
|
|
);
|
|
|
|
test('simulation-to-investment-draft conversion contract documents consent and access controls', () => {
|
|
const operation =
|
|
openapi.paths['/simulation-drafts/{id}/conversions']?.post;
|
|
assert.ok(operation);
|
|
assert.deepEqual(
|
|
operation.parameters.map((parameter) => parameter.$ref),
|
|
[
|
|
'#/components/parameters/Id',
|
|
'#/components/parameters/IfMatch',
|
|
'#/components/parameters/SimulationToken',
|
|
],
|
|
);
|
|
assert.equal(
|
|
operation.requestBody.content['application/json'].schema.$ref,
|
|
'#/components/schemas/AttachSimulationToDraftInput',
|
|
);
|
|
for (const response of ['200', '404', '409', '412', '422', '428', '429'])
|
|
assert.ok(
|
|
operation.responses[response],
|
|
`missing response ${response}`,
|
|
);
|
|
assert.match(
|
|
operation.description,
|
|
/does not submit a project or create a CRM record/i,
|
|
);
|
|
|
|
const schema = openapi.components.schemas.AttachSimulationToDraftInput;
|
|
assert.deepEqual(schema.required, ['simulation_id', 'consent_reuse']);
|
|
assert.equal(schema.additionalProperties, false);
|
|
assert.equal(schema.properties.simulation_id.format, 'uuid');
|
|
assert.equal(schema.properties.consent_reuse.const, true);
|
|
});
|