Skip to content
Prev Previous commit
Next Next commit
chore: migrate to vitest mock functions
  • Loading branch information
defaude committed Oct 2, 2023
commit 2f58f9884f01926c66b3b7f45ab0a680f2b21ecb
11 changes: 2 additions & 9 deletions Data-Structures/Graph/test/Graph2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Graph2', () => {
graph.addEdge('C', 'F')

it('Check adjacency lists', () => {
const mockFn = jest.fn()
const mockFn = vi.fn()
graph.printGraph(mockFn)

// Expect one call per vertex
Expand All @@ -27,13 +27,6 @@ describe('Test Graph2', () => {
// Collect adjacency lists from output (call args)
const adjListArr = mockFn.mock.calls.map((v) => v[0])

expect(adjListArr).toEqual([
'A -> B D E ',
'B -> A C ',
'C -> B E F ',
'D -> A E ',
'E -> A D F C ',
'F -> E C '
])
expect(adjListArr).toEqual(['A -> B D E ', 'B -> A C ', 'C -> B E F ', 'D -> A E ', 'E -> A D F C ', 'F -> E C '])
})
})
6 changes: 3 additions & 3 deletions Data-Structures/Heap/test/MinPriorityQueue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe('MinPriorityQueue', () => {

beforeEach(() => {
queue = new MinPriorityQueue(capacity)
values.forEach(v => queue.insert(v))
values.forEach((v) => queue.insert(v))
})

it('Check heap ordering', () => {
const mockFn = jest.fn()
const mockFn = vi.fn()
queue.print(mockFn)

expect(mockFn.mock.calls.length).toBe(1) // Expect one call
Expand All @@ -24,7 +24,7 @@ describe('MinPriorityQueue', () => {

it('heapSort() expected to reverse the heap ordering', () => {
queue.heapReverse()
const mockFn = jest.fn()
const mockFn = vi.fn()
queue.print(mockFn)

expect(mockFn.mock.calls.length).toBe(1)
Expand Down