Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test sanitize params lifecycle #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ describe('HipThrusTS', () => {
c: testConstants.cReturned,
};

const testOutputForSanitizers = {
c: testConstants.cReturned,
};

return {
left: {
[stage]: leftProjector,
Expand All @@ -662,6 +666,7 @@ describe('HipThrusTS', () => {
} as Record<TStage, typeof rightProjector>,
testInput,
testOutput,
testOutputForSanitizers,
};
}

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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';
Expand Down