mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-15 08:00:05 +00:00
chore(create-job): add tests
This commit is contained in:
@@ -5,20 +5,37 @@ export const computeTests = (adapter: SASjs): TestSuite => ({
|
|||||||
name: "Compute",
|
name: "Compute",
|
||||||
tests: [
|
tests: [
|
||||||
{
|
{
|
||||||
title: "Start Compute Job",
|
title: "Start Compute Job - not waiting for result",
|
||||||
description: "Should start a compute job and return the session",
|
description: "Should start a compute job and return the session",
|
||||||
test: () => {
|
test: () => {
|
||||||
const data: any = { table1: [{ col1: "first col value" }] };
|
const data: any = { table1: [{ col1: "first col value" }] };
|
||||||
return adapter.startComputeJob("/Public/app/common/sendArr", data);
|
return adapter.startComputeJob("/Public/app/common/sendArr", data);
|
||||||
},
|
},
|
||||||
assertion: (res: any) => {
|
assertion: (res: any) => {
|
||||||
return (
|
const expectedProperties = ["id", "applicationName", "attributes"]
|
||||||
!!res &&
|
return validate(expectedProperties, res);
|
||||||
!!res.applicationName &&
|
}
|
||||||
!!res.attributes &&
|
},
|
||||||
!!res.attributes.sessionInactiveTimeout
|
{
|
||||||
);
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user