Skip to content

Commit

Permalink
test(ballot-interpreter): use vitest API
Browse files Browse the repository at this point in the history
  • Loading branch information
eventualbuddha committed Dec 10, 2024
1 parent c96db75 commit ee9d8d8
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/adjudication_reasons.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, test } from 'vitest';
import {
AdjudicationReason,
AdjudicationReasonInfo,
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/bmd/interpret.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeAll, expect, test } from 'vitest';
import { sliceBallotHashForEncoding } from '@votingworks/ballot-encoder';
import { assert, err } from '@votingworks/basics';
import {
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/bmd/utils/qrcode.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { Buffer } from 'node:buffer';
import { err, ok } from '@votingworks/basics';
import {
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/bmd/utils/rotate.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { test } from 'vitest';
import { assert } from '@votingworks/basics';
import { sampleBallotImages } from '@votingworks/fixtures';
import { ImageData } from 'canvas';
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/hmpb-ts/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { electionGridLayoutNewHampshireTestBallotFixtures } from '@votingworks/fixtures';
import { DEFAULT_SYSTEM_SETTINGS } from '@votingworks/types';
import { dirSync, fileSync } from 'tmp';
Expand Down
6 changes: 2 additions & 4 deletions libs/ballot-interpreter/src/hmpb-ts/debug.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { beforeAll, expect, test, vi } from 'vitest';
import { ImageData } from 'canvas';
import { electionGridLayoutNewHampshireTestBallotFixtures } from '@votingworks/fixtures';
import * as addon from './addon';
import { interpret } from './interpret';

jest.mock('./addon');

const interpretImplMock = addon.interpret as jest.MockedFunction<
typeof addon.interpret
>;

const interpretImplMock = vi.mocked(addon.interpret);
let frontImageData!: ImageData;
let backImageData!: ImageData;

Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/hmpb-ts/diagnostic.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { join } from 'node:path';
import { runBlankPaperDiagnostic } from './diagnostic';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { ImageData } from 'canvas';
import { err } from '@votingworks/basics';
import {
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/hmpb-ts/interpret.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { assertDefined, iter, ok, unique } from '@votingworks/basics';
import { ImageData } from 'canvas';
import { electionGridLayoutNewHampshireTestBallotFixtures } from '@votingworks/fixtures';
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/hmpb-ts/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { BallotSide } from './types';

test('has BallotSide enum', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeAll, describe, expect, test } from 'vitest';
import { assert, Optional } from '@votingworks/basics';
import { readElection } from '@votingworks/fs';
import { allBubbleBallotFixtures } from '@votingworks/hmpb';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import {
DEFAULT_FAMOUS_NAMES_BALLOT_STYLE_ID,
DEFAULT_FAMOUS_NAMES_PRECINCT_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { renderBmdBallotFixture } from '@votingworks/bmd-ballot-fixtures';
import { readElection } from '@votingworks/fs';
import { famousNamesFixtures } from '@votingworks/hmpb';
Expand Down
3 changes: 2 additions & 1 deletion libs/ballot-interpreter/src/interpret_bmd_ballots.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
import { sliceBallotHashForEncoding } from '@votingworks/ballot-encoder';
import {
DEFAULT_ELECTION_GENERAL_BALLOT_STYLE_ID,
Expand Down Expand Up @@ -42,7 +43,7 @@ import { interpretSheet, interpretSimplexBmdBallot } from './interpret';
import { InterpreterOptions } from './types';
import { normalizeBallotMode } from './validation';

jest.mock('./validation');
vi.mock('./validation');

beforeEach(() => {
mockOf(normalizeBallotMode).mockImplementation((input) => input);
Expand Down
3 changes: 2 additions & 1 deletion libs/ballot-interpreter/src/interpret_nh_hmpb.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { assert, unique } from '@votingworks/basics';
import {
electionGridLayoutNewHampshireTestBallotFixtures,
Expand All @@ -24,7 +25,7 @@ import { interpretSheet } from './interpret';
import { InterpreterOptions } from './types';
import { normalizeBallotMode } from './validation';

jest.mock('./validation');
vi.mock('./validation');

beforeEach(() => {
mockOf(normalizeBallotMode).mockImplementation((input) => input);
Expand Down
3 changes: 2 additions & 1 deletion libs/ballot-interpreter/src/interpret_vx_hmpb.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
import { sliceBallotHashForEncoding } from '@votingworks/ballot-encoder';
import { assert, assertDefined, iter } from '@votingworks/basics';
import { readElection } from '@votingworks/fs';
Expand Down Expand Up @@ -32,7 +33,7 @@ import { interpretSheet } from './interpret';
import { InterpreterOptions } from './types';
import { normalizeBallotMode } from './validation';

jest.mock('./validation');
vi.mock('./validation');

beforeEach(() => {
mockOf(normalizeBallotMode).mockImplementation((input) => input);
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/save_images.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect, test } from 'vitest';
import { createImageData, ImageData } from '@votingworks/image-utils';
import { SheetOf } from '@votingworks/types';
import { join } from 'node:path';
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { toMatchImageSnapshot } from 'jest-image-snapshot';

expect.extend({ toMatchImageSnapshot });
1 change: 1 addition & 0 deletions libs/ballot-interpreter/src/validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, test } from 'vitest';
import { electionGeneralDefinition } from '@votingworks/fixtures';
import {
BallotId,
Expand Down
1 change: 1 addition & 0 deletions libs/ballot-interpreter/test/helpers/tmp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { afterAll } from 'vitest';
import { removeSync } from 'fs-extra';
import { dirSync } from 'tmp';

Expand Down

0 comments on commit ee9d8d8

Please sign in to comment.