From 05ba21a56df0acd902e030dc34bff0c25ce3d2b7 Mon Sep 17 00:00:00 2001 From: David Bucio-Paz Date: Sun, 29 Nov 2026 01:36:58 -0500 Subject: [PATCH 1/3] implemented employee.test.js description --- webdevadv/src/test/empDBLogic.test.js | 42 +++++++++++++++++++++++++++ webdevadv/src/test/employee.test.js | 4 ++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 webdevadv/src/test/empDBLogic.test.js diff --git a/webdevadv/src/test/empDBLogic.test.js b/webdevadv/src/test/empDBLogic.test.js new file mode 100644 index 0000000..07514e4 --- /dev/null +++ b/webdevadv/src/test/empDBLogic.test.js @@ -0,0 +1,42 @@ + +import { describe, it, expect, vi, beforeEach} from 'vitest'; + +const { mockRun, mockAll, mockPrepare } = vi.hoisted(() => { + const mockRun = vi.fn(); + const mockAll = vi.fn(); + const mockPrepare = vi.fn(() => ({ + run: mockRun, + all: mockAll + })) + return { mockRun, mockAll, mockPrepare } +}) + +vi.mock('../../database/initialize', () => ({ + db: { prepare: mockPrepare} +})); + +import empDBLogic from '../employee/empDBLogic.js'; +describe('empDBLogic', () => { + beforeEach(() => { + vi.clearAllMocks(); + }) + it('writeToDB inserts an employee and returns lastInsertRowid', () => { + mockRun.mockReturnValue({ lastInsertRowid: 1}); + + const id = empDBLogic.writeToDB('Alex', 'Server') + + expect(mockPrepare).toHaveBeenCalledWith(expect.stringContaining('INSERT INTO employeesTable')); + expect(mockRun).toHaveBeenCalled('Alex','Server'); + expect(id).toBe(1) + }); +}); + +describe('empDBLogic', () => { + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('writeToDB Happy Path: ') +}) + diff --git a/webdevadv/src/test/employee.test.js b/webdevadv/src/test/employee.test.js index eac8448..f5bbb9e 100644 --- a/webdevadv/src/test/employee.test.js +++ b/webdevadv/src/test/employee.test.js @@ -7,5 +7,7 @@ test("Employee can be imported and stores employee details", () => { expect(employee.getName()).toBe('Alex'); expect(employee.getOccupation()).toBe('Usher'); -}) +}); + + From b75705b97dd065546f3abae4243c842763beff63 Mon Sep 17 00:00:00 2001 From: David Bucio-Paz Date: Sun, 29 Nov 2026 01:43:25 -0500 Subject: [PATCH 2/3] fixed slight bug causing CI pipeline to fail --- webdevadv/src/test/empDBLogic.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webdevadv/src/test/empDBLogic.test.js b/webdevadv/src/test/empDBLogic.test.js index 07514e4..74e6486 100644 --- a/webdevadv/src/test/empDBLogic.test.js +++ b/webdevadv/src/test/empDBLogic.test.js @@ -15,7 +15,7 @@ vi.mock('../../database/initialize', () => ({ db: { prepare: mockPrepare} })); -import empDBLogic from '../employee/empDBLogic.js'; +import empDBLogic from '../../employee/empDBLogic.js'; describe('empDBLogic', () => { beforeEach(() => { vi.clearAllMocks(); From 3f9e6d11775ad141bf47c1d5b6a6ebb4d591361a Mon Sep 17 00:00:00 2001 From: David Bucio-Paz Date: Sun, 29 Nov 2026 01:50:16 -0500 Subject: [PATCH 3/3] fix issue of ci pipeline with this branch --- node_modules/.vite/vitest/CACHEDIR.TAG | 3 +++ .../da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json | 1 + webdevadv/src/test/empDBLogic.test.js | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 node_modules/.vite/vitest/CACHEDIR.TAG create mode 100644 node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json diff --git a/node_modules/.vite/vitest/CACHEDIR.TAG b/node_modules/.vite/vitest/CACHEDIR.TAG new file mode 100644 index 0000000..8c1ef4c --- /dev/null +++ b/node_modules/.vite/vitest/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by Vitest. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json new file mode 100644 index 0000000..2dd56bd --- /dev/null +++ b/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json @@ -0,0 +1 @@ +{"version":1,"projects":{"":{"files":{"webdevadv/src/test/empDBLogic.test.js":{"failed":true,"duration":8.140199999999993,"lastRun":1795934876478,"failedTests":["empDBLogic > writeToDB inserts an employee and returns lastInsertRowid"]},"webdevadv/src/test/employee.test.js":{"failed":false,"duration":4.360600000000005,"lastRun":1795934876478},"webdevadv/src/test/index.test.js":{"failed":false,"duration":4.897300000000001,"lastRun":1795934876478},"webdevadv/src/test/ipc.test.js":{"failed":false,"duration":10.749500000000012,"lastRun":1795934876478},"webdevadv/src/test/parse.test.js":{"failed":false,"duration":41.89140000000003,"lastRun":1795934876478},"webdevadv/src/test/solver-path.test.js":{"failed":false,"duration":6.848299999999995,"lastRun":1795934876478},"webdevadv/src/test/solver.test.js":{"failed":true,"duration":10.099899999999991,"lastRun":1795934876478,"failedTests":["solver > normal day: valid schedule, every show covered, everyone at minimum","solver > understaffed day: still returns a valid schedule and flags uncovered shows"]}}}}} \ No newline at end of file diff --git a/webdevadv/src/test/empDBLogic.test.js b/webdevadv/src/test/empDBLogic.test.js index 74e6486..4d4475e 100644 --- a/webdevadv/src/test/empDBLogic.test.js +++ b/webdevadv/src/test/empDBLogic.test.js @@ -23,7 +23,7 @@ describe('empDBLogic', () => { it('writeToDB inserts an employee and returns lastInsertRowid', () => { mockRun.mockReturnValue({ lastInsertRowid: 1}); - const id = empDBLogic.writeToDB('Alex', 'Server') + const id = empDBLogic.addEmployee('Alex', 'Server') expect(mockPrepare).toHaveBeenCalledWith(expect.stringContaining('INSERT INTO employeesTable')); expect(mockRun).toHaveBeenCalled('Alex','Server'); @@ -37,6 +37,6 @@ describe('empDBLogic', () => { vi.clearAllMocks(); }); - it('writeToDB Happy Path: ') + it('addEmployee Happy Path: ') })