From 49774b9213af76ebf9da96c9bfd707a60eebe9b2 Mon Sep 17 00:00:00 2001 From: Volodymyr Kulynii Date: Thu, 11 Jun 2020 17:52:09 +0300 Subject: [PATCH] test: test sanitize params lifecycle --- test/index.test.ts | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/index.test.ts b/test/index.test.ts index 51a9982..3c00012 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -653,6 +653,10 @@ describe('HipThrusTS', () => { c: testConstants.cReturned, }; + const testOutputForSanitizers = { + c: testConstants.cReturned, + }; + return { left: { [stage]: leftProjector, @@ -662,6 +666,7 @@ describe('HipThrusTS', () => { } as Record, testInput, testOutput, + testOutputForSanitizers, }; } @@ -678,6 +683,19 @@ describe('HipThrusTS', () => { true ); }); + it('sanitize params test', async () => { + const lifecycleStage = 'sanitizeParams'; + await HTPipeTest( + HTPipe( + fullyCoveredCaseTest(lifecycleStage).left, + fullyCoveredCaseTest(lifecycleStage).right + ), + lifecycleStage, + fullyCoveredCaseTest(lifecycleStage).testInput, + fullyCoveredCaseTest(lifecycleStage).testOutputForSanitizers, + true + ); + }); it('attachData test sync', async () => { const lifecycleStage = 'attachData'; await HTPipeTest( @@ -765,6 +783,19 @@ describe('HipThrusTS', () => { true ); }); + it('sanitizeParams test', async () => { + const lifecycleStage = 'sanitizeParams'; + await HTPipeTest( + HTPipe( + transformedTypeCaseTest(lifecycleStage).left, + transformedTypeCaseTest(lifecycleStage).right + ), + lifecycleStage, + transformedTypeCaseTest(lifecycleStage).testInput, + transformedTypeCaseTest(lifecycleStage).testOutput, + true + ); + }); it('attachData sync', async () => { const lifecycleStage = 'attachData'; await HTPipeTest( @@ -946,6 +977,23 @@ describe('HipThrusTS', () => { true ); }); + it('sanitizeParams should give error in this case because of his filtration functionality test', () => { + async function expectErrorWithHTPipe() { + const lifecycleStage = 'sanitizeParams'; + await HTPipeTest( + // @ts-expect-error + HTPipe( + notCoveredCaseTest(lifecycleStage).left, + notCoveredCaseTest(lifecycleStage).right + ), + lifecycleStage, + notCoveredCaseTest(lifecycleStage).testInput, + notCoveredCaseTest(lifecycleStage).testOutput, + // @ts-expect-error + true + ); + } + }); it('attachData sync', async () => { const lifecycleStage = 'attachData'; await HTPipeTest( @@ -1025,6 +1073,19 @@ describe('HipThrusTS', () => { true ); }); + it('sanitizeParams test', async () => { + const lifecycleStage = 'sanitizeParams'; + await HTPipeTest( + HTPipe( + leftOnlyCaseTest(lifecycleStage).left, + leftOnlyCaseTest(lifecycleStage).right + ), + lifecycleStage, + leftOnlyCaseTest(lifecycleStage).testInput, + leftOnlyCaseTest(lifecycleStage).testOutput, + true + ); + }); it('attachData sync', async () => { const lifecycleStage = 'attachData'; await HTPipeTest( @@ -1104,6 +1165,19 @@ describe('HipThrusTS', () => { true ); }); + it('sanitizeParams test', async () => { + const lifecycleStage = 'sanitizeParams'; + await HTPipeTest( + HTPipe( + rightOnlyCaseTest(lifecycleStage).left, + rightOnlyCaseTest(lifecycleStage).right + ), + lifecycleStage, + rightOnlyCaseTest(lifecycleStage).testInput, + rightOnlyCaseTest(lifecycleStage).testOutput, + true + ); + }); it('attachData sync', async () => { const lifecycleStage = 'attachData'; await HTPipeTest( @@ -1170,6 +1244,16 @@ describe('HipThrusTS', () => { ); } }); + it('sanitizeParams test', async () => { + const lifecycleStage = 'sanitizeParams'; + function expectErrorWithHTPipe() { + // @ts-expect-error + const pipedError = HTPipe( + errorCaseTest(lifecycleStage).left, + errorCaseTest(lifecycleStage).right + ); + } + }); it('attachData sync', async () => { it('no attaches data when left sync outputs have type mismatch with right inputs', () => { const lifecycleStage = 'attachData';