diff --git a/sasjs-tests/src/testSuites/Compute.ts b/sasjs-tests/src/testSuites/Compute.ts index eae2728..646470e 100644 --- a/sasjs-tests/src/testSuites/Compute.ts +++ b/sasjs-tests/src/testSuites/Compute.ts @@ -5,20 +5,37 @@ export const computeTests = (adapter: SASjs): TestSuite => ({ name: "Compute", tests: [ { - title: "Start Compute Job", + title: "Start Compute Job - not waiting for result", description: "Should start a compute job and return the session", test: () => { const data: any = { table1: [{ col1: "first col value" }] }; return adapter.startComputeJob("/Public/app/common/sendArr", data); }, assertion: (res: any) => { - return ( - !!res && - !!res.applicationName && - !!res.attributes && - !!res.attributes.sessionInactiveTimeout - ); + const expectedProperties = ["id", "applicationName", "attributes"] + return validate(expectedProperties, res); + } + }, + { + title: "Start Compute Job - waiting for result", + description: "Should start a compute job and return the job", + test: () => { + const data: any = { table1: [{ col1: "first col value" }] }; + return adapter.startComputeJob("/Public/app/common/sendArr", data, {}, "", true); + }, + assertion: (res: any) => { + const expectedProperties = ["id", "state", "creationTimeStamp", "jobConditionCode"] + return validate(expectedProperties, res); } } ] }); + +const validate = (expectedProperties: string[], data: any): boolean => { + const actualProperties = Object.keys(data); + + const isValid = expectedProperties.every( + (property) => actualProperties.includes(property) + ); + return isValid +} \ No newline at end of file