Skip to content

Commit

Permalink
test(isValidBoundingBox): add robust snapshot tests
Browse files Browse the repository at this point in the history
Adds extensive snapshot testing. Final matcher to get updated addressing this issue.

Resolves: #32
  • Loading branch information
M-Scott-Lassiter committed Jun 2, 2022
1 parent a37ec48 commit 063b94e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
24 changes: 8 additions & 16 deletions tests/boundingBoxes/__snapshots__/isValidBoundingBox.test.js.snap
@@ -1,33 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Error Snapshot Testing. Throws error: expect([0, -95, 0, 0, 0, 0]).isValidBoundingBox 1`] = `
exports[`Error Snapshot Testing. Throws error: Bounding box must be an array of either four or six elments 1`] = `
"expect([west, south, (depth), east, north, (altitude)]).isValidBoundingBox()
Bounding box southern value must be a number between -90 and 90.
Bounding box must be an array of either four or six elments.
Received: [31m[0, -95, 0, 0, 0, 0][39m"
Received: [31m[0, 1, 2, 3, 4][39m"
`;

exports[`Error Snapshot Testing. Throws error: expect([0, 0, 0, 0, 0, 0]).not.isValidBoundingBox 1`] = `
"[2mexpect([22m[31m[west, south, (depth), east, north, (altitude)][39m[2m).not.isValidBoundingBox()[22m
exports[`Error Snapshot Testing. Throws error: Invalid input to matcher 1`] = `
"[2mexpect([22m[31m[west, south, (depth), east, north, (altitude)][39m[2m).isValidBoundingBox()[22m
Expected input to not be a four or six element bounding box array.
Bounding box must be an array.
Received: [31m[0, 0, 0, 0, 0, 0][39m"
Received: [31mfalse[39m"
`;

exports[`Error Snapshot Testing. Throws error: expect([0, 0, 0, 0]).not.isValidBoundingBox 1`] = `
exports[`Error Snapshot Testing. Throws error: Valid use case passes 1`] = `
"expect([west, south, (depth), east, north, (altitude)]).not.isValidBoundingBox()
Expected input to not be a four or six element bounding box array.
Received: [-20, 10, -10, 20]"
`;

exports[`Error Snapshot Testing. Throws error: expect([0, 0, 95, 0]).isValidBoundingBox 1`] = `
"expect([west, south, (depth), east, north, (altitude)]).isValidBoundingBox()
Bounding box northern value must be a number between -90 and 90.
Received: [0, 0, 0, 95]"
`;
18 changes: 5 additions & 13 deletions tests/boundingBoxes/isValidBoundingBox.test.js
Expand Up @@ -20,25 +20,17 @@ describe('Invalid Use Cases', () => {
})

describe('Error Snapshot Testing. Throws error:', () => {
test('expect([0, 0, 0, 0]).not.isValidBoundingBox', () => {
test('Valid use case passes', () => {
expect(() =>
expect([-20, 10, -10, 20]).not.isValidBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('expect([0, 0, 0, 0, 0, 0]).not.isValidBoundingBox', () => {
expect(() =>
expect([0, 0, 0, 0, 0, 0]).not.isValidBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('expect([0, 0, 95, 0]).isValidBoundingBox', () => {
expect(() => expect([0, 0, 0, 95]).isValidBoundingBox()).toThrowErrorMatchingSnapshot()
test('Invalid input to matcher', () => {
expect(() => expect(false).isValidBoundingBox()).toThrowErrorMatchingSnapshot()
})

test('expect([0, -95, 0, 0, 0, 0]).isValidBoundingBox', () => {
expect(() =>
expect([0, -95, 0, 0, 0, 0]).isValidBoundingBox()
).toThrowErrorMatchingSnapshot()
test('Bounding box must be an array of either four or six elments', () => {
expect(() => expect([0, 1, 2, 3, 4]).isValidBoundingBox()).toThrowErrorMatchingSnapshot()
})
})

0 comments on commit 063b94e

Please sign in to comment.