From 063b94ec11198675684b52a7acfcf0303b2e5db3 Mon Sep 17 00:00:00 2001 From: M-Scott-Lassiter Date: Wed, 1 Jun 2022 17:12:22 -0700 Subject: [PATCH] test(isValidBoundingBox): add robust snapshot tests Adds extensive snapshot testing. Final matcher to get updated addressing this issue. Resolves: #32 --- .../isValidBoundingBox.test.js.snap | 24 +++++++------------ .../boundingBoxes/isValidBoundingBox.test.js | 18 ++++---------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/tests/boundingBoxes/__snapshots__/isValidBoundingBox.test.js.snap b/tests/boundingBoxes/__snapshots__/isValidBoundingBox.test.js.snap index 4151caf..b5045bc 100644 --- a/tests/boundingBoxes/__snapshots__/isValidBoundingBox.test.js.snap +++ b/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: [0, -95, 0, 0, 0, 0]" +Received: [0, 1, 2, 3, 4]" `; -exports[`Error Snapshot Testing. Throws error: expect([0, 0, 0, 0, 0, 0]).not.isValidBoundingBox 1`] = ` -"expect([west, south, (depth), east, north, (altitude)]).not.isValidBoundingBox() +exports[`Error Snapshot Testing. Throws error: Invalid input to matcher 1`] = ` +"expect([west, south, (depth), east, north, (altitude)]).isValidBoundingBox() -Expected input to not be a four or six element bounding box array. +Bounding box must be an array. -Received: [0, 0, 0, 0, 0, 0]" +Received: false" `; -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]" -`; diff --git a/tests/boundingBoxes/isValidBoundingBox.test.js b/tests/boundingBoxes/isValidBoundingBox.test.js index 18b226b..a4d8dbb 100644 --- a/tests/boundingBoxes/isValidBoundingBox.test.js +++ b/tests/boundingBoxes/isValidBoundingBox.test.js @@ -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() }) })