Skip to content

Commit

Permalink
test(isValid3DCoordinate): 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 1, 2022
1 parent ae92f67 commit 56fbf92
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
28 changes: 22 additions & 6 deletions tests/coordinates/__snapshots__/isValid3DCoordinate.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Error Snapshot Testing. Throws error: expect([0, 0, 0]).not.isValid3DCoordinate 1`] = `
"[2mexpect([22m[31m[longitude, latitude, altitude][39m[2m).not.isValid3DCoordinate()[22m
exports[`Error Snapshot Testing. Throws error: Coordinate altitude value must be numeric 1`] = `
"[2mexpect([22m[31m[longitude, latitude, altitude][39m[2m).isValid3DCoordinate()[22m
Expected input to not be a three element array with longitude between (-90 to 90),
latitude between (-180 to 180), and numeric altitude.
Coordinate altitude value must be numeric.
Received: [0, 0, 0]"
Received: [0, 0, true]"
`;

exports[`Error Snapshot Testing. Throws error: Coordinate must be an array of only three elments 1`] = `
"expect([longitude, latitude, altitude]).isValid3DCoordinate()
Coordinate must be an array of only three elments.
Received: [0, 0]"
`;

exports[`Error Snapshot Testing. Throws error: expect([0, 0]).isValid3DCoordinate 1`] = `
exports[`Error Snapshot Testing. Throws error: Invalid input to matcher 1`] = `
"expect([longitude, latitude, altitude]).isValid3DCoordinate()
Coordinate must be an array of only three elments.
Received: [0, 0]"
`;

exports[`Error Snapshot Testing. Throws error: Valid use case passes 1`] = `
"expect([longitude, latitude, altitude]).not.isValid3DCoordinate()
Expected input to not be a three element array with longitude between (-90 to 90),
latitude between (-180 to 180), and numeric altitude.
Received: [0, 0, 0]"
`;
12 changes: 10 additions & 2 deletions tests/coordinates/isValid3DCoordinate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,19 @@ describe('Invalid Use Cases', () => {
})

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

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

test('Coordinate must be an array of only three elments', () => {
expect(() => expect([0, 0]).isValid3DCoordinate()).toThrowErrorMatchingSnapshot()
})

test('Coordinate altitude value must be numeric', () => {
expect(() => expect([0, 0, true]).isValid3DCoordinate()).toThrowErrorMatchingSnapshot()
})
})

0 comments on commit 56fbf92

Please sign in to comment.