Skip to content

Commit

Permalink
test(isValid2DBoundingBox): add robust snapshot tests
Browse files Browse the repository at this point in the history
Adds extensive snapshot testing to address #32.
  • Loading branch information
M-Scott-Lassiter committed Jun 2, 2022
1 parent 7b4a804 commit 4363710
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,66 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Error Snapshot Testing. Throws error: expect([10, 10, 20, 20]).not.isValid2DBoundingBox 1`] = `
"[2mexpect([22m[31m[east, south, west, north][39m[2m).not.isValid2DBoundingBox()[22m
exports[`Error Snapshot Testing. Throws error: Bounding box eastern value must be a number between -180 and 180 1`] = `
"[2mexpect([22m[31m[east, south, west, north][39m[2m).isValid2DBoundingBox()[22m
Expected input to not be a four element array of numbers with longitude between (-90 to 90),
latitude between (-180 to 180), and northern boundary greater than southern boundary.
Bounding box western value must be a number between -180 and 180.
Received: [31m[10, 10, 20, 20][39m"
Received: [31m[10, 10, 200, 20][39m"
`;

exports[`Error Snapshot Testing. Throws error: expect(false).isValid2DBoundingBox() 1`] = `
exports[`Error Snapshot Testing. Throws error: Bounding box must be an array of only four elments 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box must be an array of only four elments.
Received: [10, 10, 20, 20, 30]"
`;

exports[`Error Snapshot Testing. Throws error: Bounding box northern value must be a number between -90 and 90 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box northern value must be a number between -90 and 90.
Received: [10, 10, 20, 200]"
`;

exports[`Error Snapshot Testing. Throws error: Bounding box northern value must be greater than southern 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box northern value must be greater than southern.
Received: [10, 20, 20, 0]"
`;

exports[`Error Snapshot Testing. Throws error: Bounding box southern value must be a number between -90 and 90 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box southern value must be a number between -90 and 90.
Received: [10, -200, 20, 20]"
`;

exports[`Error Snapshot Testing. Throws error: Bounding box western value must be a number between -180 and 180 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box eastern value must be a number between -180 and 180.
Received: [200, 10, 20, 20]"
`;

exports[`Error Snapshot Testing. Throws error: Invalid input to matcher 1`] = `
"expect([east, south, west, north]).isValid2DBoundingBox()
Bounding box must be an array of only four elments.
Received: false"
`;

exports[`Error Snapshot Testing. Throws error: Valid use case passes 1`] = `
"expect([east, south, west, north]).not.isValid2DBoundingBox()
Expected input to not be a four element array of numbers with longitude between (-90 to 90),
latitude between (-180 to 180), and northern boundary greater than southern boundary.
Received: [10, 10, 20, 20]"
`;
38 changes: 36 additions & 2 deletions tests/boundingBoxes/isValid2DBoundingBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,47 @@ describe('Inalid Use Cases', () => {
})

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

test('expect(false).isValid2DBoundingBox()', () => {
test('Invalid input to matcher', () => {
expect(() => expect(false).isValid2DBoundingBox()).toThrowErrorMatchingSnapshot()
})

test('Bounding box must be an array of only four elments', () => {
expect(() =>
expect([10, 10, 20, 20, 30]).isValid2DBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('Bounding box eastern value must be a number between -180 and 180', () => {
expect(() =>
expect([10, 10, 200, 20]).isValid2DBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('Bounding box western value must be a number between -180 and 180', () => {
expect(() =>
expect([200, 10, 20, 20]).isValid2DBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('Bounding box southern value must be a number between -90 and 90', () => {
expect(() =>
expect([10, -200, 20, 20]).isValid2DBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('Bounding box northern value must be a number between -90 and 90', () => {
expect(() =>
expect([10, 10, 20, 200]).isValid2DBoundingBox()
).toThrowErrorMatchingSnapshot()
})

test('Bounding box northern value must be greater than southern', () => {
expect(() => expect([10, 20, 20, 0]).isValid2DBoundingBox()).toThrowErrorMatchingSnapshot()
})
})

0 comments on commit 4363710

Please sign in to comment.