From 88f1c2f843a82f1d9828179795f3e5db4e7386ea Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Thu, 3 Mar 2022 13:00:14 +0100 Subject: [PATCH] chore: added viya web approach test (special missing) --- sasjs-tests/package-lock.json | 4 +- sasjs-tests/src/testSuites/SpecialCases.ts | 51 +++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/sasjs-tests/package-lock.json b/sasjs-tests/package-lock.json index 53400d6..2840748 100644 --- a/sasjs-tests/package-lock.json +++ b/sasjs-tests/package-lock.json @@ -2388,7 +2388,7 @@ "node_modules/@sasjs/adapter": { "version": "5.0.0", "resolved": "file:../build/sasjs-adapter-5.0.0.tgz", - "integrity": "sha512-JZsvovkPNb0dlnBRh1uDdvgJg+BE0ebIomWwhYjHj3YApds4MgI++1pa+Ck2tltIUUYASeiPUIPJJX8tF3VCTw==", + "integrity": "sha512-O4MnLA6Tm2xoANU1uBJ5xMzEBeXVGkw38lR6LoiLIUhQOJY5gpwjb39oBPFqPfvCwjG0Jqjx7XcaE+g23pEfNw==", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -20998,7 +20998,7 @@ }, "@sasjs/adapter": { "version": "file:../build/sasjs-adapter-5.0.0.tgz", - "integrity": "sha512-JZsvovkPNb0dlnBRh1uDdvgJg+BE0ebIomWwhYjHj3YApds4MgI++1pa+Ck2tltIUUYASeiPUIPJJX8tF3VCTw==", + "integrity": "sha512-O4MnLA6Tm2xoANU1uBJ5xMzEBeXVGkw38lR6LoiLIUhQOJY5gpwjb39oBPFqPfvCwjG0Jqjx7XcaE+g23pEfNw==", "requires": { "@sasjs/utils": "2.36.1", "axios": "0.26.0", diff --git a/sasjs-tests/src/testSuites/SpecialCases.ts b/sasjs-tests/src/testSuites/SpecialCases.ts index 2b77581..9e85cf2 100644 --- a/sasjs-tests/src/testSuites/SpecialCases.ts +++ b/sasjs-tests/src/testSuites/SpecialCases.ts @@ -416,6 +416,55 @@ export const specialCaseTests = (adapter: SASjs): TestSuite => ({ return assertionRes } - } + }, + { + title: 'Special missing values (ONE ROW) useComputeApi undefined', + description: + 'Should support special missing values, when one row is send (On VIYA Web Approach)', + test: () => { + return adapter.request( + 'common/sendObj', + testTableWithSpecialNumericOneRow, + { useComputeApi: undefined } + ) + }, + assertion: (res: any) => { + let assertionRes = true + + // We receive formats in response. We compare it with formats that we included in request to make sure they are equal + const resVars = res[`$${testTable}`].vars + + Object.keys(resVars).forEach((key: any, i: number) => { + let formatValue = + testTableWithSpecialNumeric[`$${testTable}`].formats[ + key.toLowerCase() + ] + // If it is char, we change it to $ to be compatible for comparsion + // If it is number, it will already be compatible to comapre (best.) + formatValue = formatValue?.includes('$') ? '$' : formatValue + + if ( + formatValue !== undefined && + !resVars[key].format.includes(formatValue) + ) { + assertionRes = false + } + }) + + // Here we will compare the response values with values we send + const resValues = res[testTable] + + testTableWithSpecialNumericOneRow[testTable].forEach( + (row: { [key: string]: any }, i: number) => + Object.keys(row).forEach((col: string) => { + if (resValues[i][col.toUpperCase()] !== row[col]) { + assertionRes = false + } + }) + ) + + return assertionRes + } + }, ] })