Skip to content

Commit

Permalink
Update QueryStringValidatorForOverposting.test.ts
Browse files Browse the repository at this point in the history
Enable test.
Fix test to match RND-651 changes
  • Loading branch information
jleiva-gap committed Nov 7, 2023
1 parent 05a68a4 commit 25d464f
Showing 1 changed file with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,7 @@ function createResourceSchema(): ResourceSchema {
};
}

describe('given query parameters have no properties', () => {
it('should not return an error', () => {
const queryParameters = {};

const validationResult = validateQueryParametersAgainstSchema(createModel(), queryParameters);

expect(validationResult).toHaveLength(0);
});
});

describe('given query parameters have a valid property', () => {
it('should not return an error', () => {
const queryParameters = { uniqueId: 'a' };

const validationResult = validateQueryParametersAgainstSchema(createModel(), queryParameters);

expect(validationResult).toHaveLength(0);
});
});

describe('given query parameters with allow overposting is false have two extraneous properties and a valid one', () => {
describe('given query parameters with allow overposting is false have two invalid properties and a valid one', () => {
let validationResult: string[];

beforeAll(() => {
Expand All @@ -85,15 +65,15 @@ describe('given query parameters with allow overposting is false have two extran
});

it('should contain property `one`', () => {
expect(validationResult).toContain("Student does not include property 'one'");
expect(validationResult).toContain(" does not include property 'one'");
});

it('should contain property `two`', () => {
expect(validationResult).toContain("Student does not include property 'two'");
expect(validationResult).toContain(" does not include property 'two'");
});
});

describe.skip('given query parameters with allow overposting is true have two extraneous properties and a valid one', () => {
describe('given query parameters with allow overposting is true have two extraneous properties and a valid one', () => {
let validationResult: string[];

beforeAll(() => {
Expand All @@ -116,11 +96,11 @@ describe.skip('given query parameters with allow overposting is true have two ex
});

it('should contain property `one`', () => {
expect(validationResult).toContain("Student does not include property 'one'");
expect(validationResult).toContain(" does not include property 'one'");
});

it('should contain property `two`', () => {
expect(validationResult).toContain("Student does not include property 'two'");
expect(validationResult).toContain(" does not include property 'two'");
});
});

Expand Down Expand Up @@ -282,7 +262,7 @@ describe('given a bad decimal query parameter value', () => {
});
});

describe.skip('given body insert with allow overposting is false have two invalid properties and a valid one', () => {
describe('given body insert with allow overposting is false have two invalid properties and a valid one', () => {
let validationResult: ValidationFailure | null;

beforeAll(() => {
Expand All @@ -301,13 +281,20 @@ describe.skip('given body insert with allow overposting is false have two invali
jest.restoreAllMocks();
});

it('should have two errors', () => {
expect(validationResult).toHaveLength(2);
it('should have three errors', () => {
expect(validationResult?.error).toHaveLength(3);
});

it('should return validation errors', () => {
expect(validationResult).toMatchInlineSnapshot(`
expect(validationResult?.error).toMatchInlineSnapshot(`
[
{
"context": {
"errorType": "additionalProperties",
},
"message": "'uniqueId' property is not expected to be here",
"path": "{requestBody}",
},
{
"context": {
"errorType": "additionalProperties",
Expand All @@ -327,7 +314,7 @@ describe.skip('given body insert with allow overposting is false have two invali
});
});

describe.skip('given body update with allow overposting is false have two invalid properties and a valid one', () => {
describe('given body update with allow overposting is false have two invalid properties and a valid one', () => {
let validationResult: ValidationFailure | null;

beforeAll(() => {
Expand All @@ -346,13 +333,20 @@ describe.skip('given body update with allow overposting is false have two invali
jest.restoreAllMocks();
});

it('should have two errors', () => {
expect(validationResult).toHaveLength(2);
it('should have three errors', () => {
expect(validationResult?.error).toHaveLength(3);
});

it('should return validation errors', () => {
expect(validationResult).toMatchInlineSnapshot(`
expect(validationResult?.error).toMatchInlineSnapshot(`
[
{
"context": {
"errorType": "additionalProperties",
},
"message": "'uniqueId' property is not expected to be here",
"path": "{requestBody}",
},
{
"context": {
"errorType": "additionalProperties",
Expand All @@ -372,7 +366,7 @@ describe.skip('given body update with allow overposting is false have two invali
});
});

describe.skip('given body insert with allow overposting is true have two invalid properties and a valid one', () => {
describe('given body insert with allow overposting is true have two invalid properties and a valid one', () => {
let validationResult: ValidationFailure | null;

beforeAll(() => {
Expand All @@ -396,7 +390,7 @@ describe.skip('given body insert with allow overposting is true have two invalid
});
});

describe.skip('given body update with allow overposting is true have two invalid properties and a valid one', () => {
describe('given body update with allow overposting is true have two invalid properties and a valid one', () => {
let validationResult: ValidationFailure | null;

beforeAll(() => {
Expand Down

0 comments on commit 25d464f

Please sign in to comment.