From 8c92283514218d2a8774d8a92247cac236c85589 Mon Sep 17 00:00:00 2001 From: sayhiben Date: Sat, 10 Aug 2024 23:54:33 -0700 Subject: [PATCH] Clean up redundant tests, rename scripts --- .github/workflows/test.yml | 2 +- package.json | 4 +-- src/geometry.test.js | 66 ++++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a8884c..4500fc3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: run: npm install - name: Run Tests - run: npm test + run: npm run test:ci env: CI: true diff --git a/package.json b/package.json index 5ad7e9b..5549789 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "start": "npm run build -- --stats=errors-only && electron dist", "start-local": "npm run build -- --stats=errors-only && electron dist --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev", "start-dev": "npm run build -- --stats=verbose && electron dist --enable-logging --control.address=http://localhost:4444 --control.username=streamwall --control.password=local-dev", - "test-full": "jest", - "test": "jest --ci --reporters=default --reporters=jest-junit --testPathIgnorePatterns=src/node/server.test.js --coverage" + "jest": "jest", + "test:ci": "jest --ci --reporters=default --reporters=jest-junit --testPathIgnorePatterns=src/node/server.test.js --coverage" }, "author": "Max Goodhart ", "license": "MIT", diff --git a/src/geometry.test.js b/src/geometry.test.js index 8192c9f..fd88805 100644 --- a/src/geometry.test.js +++ b/src/geometry.test.js @@ -90,40 +90,42 @@ describe.each([ }) }) -describe('idxToCoords', () => { - it('should convert index to coordinates correctly', () => { - const gridCount = 5 - const idx = 12 - const result = idxToCoords(gridCount, idx) - expect(result).toEqual({ x: 2, y: 2 }) - }) +describe.each([ + [ + 'a middle index', + 5, + 12, + { x: 2, y: 2 }, + ], + [ + 'the top-left corner', + 5, + 0, + { x: 0, y: 0 }, + ], + [ + 'the top-right corner', + 5, + 4, + { x: 4, y: 0 }, + ], + [ + 'the bottom-left corner', + 5, + 20, + { x: 0, y: 4 }, + ], + [ + 'the bottom-right corner', + 5, + 24, + { x: 4, y: 4 }, + ], - it('should support the top-left corner', () => { - const gridCount = 5 - const idx = 0 +])('idxToCoords', (humanized_location, gridCount, idx, coords) => { + test(`should support ${humanized_location}`, () => { const result = idxToCoords(gridCount, idx) - expect(result).toEqual({ x: 0, y: 0 }) - }) - - it('should support the top-right corner', () => { - const gridCount = 5 - const idx = 4 - const result = idxToCoords(gridCount, idx) - expect(result).toEqual({ x: 4, y: 0 }) - }) - - it('should support the bottom-left corner', () => { - const gridCount = 5 - const idx = 20 - const result = idxToCoords(gridCount, idx) - expect(result).toEqual({ x: 0, y: 4 }) - }) - - it('should support the bottom-right corner', () => { - const gridCount = 5 - const idx = 24 - const result = idxToCoords(gridCount, idx) - expect(result).toEqual({ x: 4, y: 4 }) + expect(result).toEqual(coords) }) })