Skip to content

Commit

Permalink
migrate shared-data tests to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Mar 1, 2024
1 parent 94e6077 commit 485addb
Show file tree
Hide file tree
Showing 37 changed files with 6,022 additions and 18 deletions.
5,970 changes: 5,969 additions & 1 deletion shared-data/js/__tests__/__snapshots__/pipettes.test.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion shared-data/js/__tests__/deckSchemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Ajv from 'ajv'
import path from 'path'
import glob from 'glob'

import { describe, expect, it } from 'vitest'
import deckSchema from '../../deck/schemas/3.json'
import deckSchemaV4 from '../../deck/schemas/4.json'

Expand Down
4 changes: 2 additions & 2 deletions shared-data/js/__tests__/errors.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// tests for error accessors

import { describe, expect, it } from 'vitest'
import { getError } from '../errors'

import errorDefinitions from '@opentrons/shared-data/errors/definitions/1/errors.json'
import errorDefinitions from '../../errors/definitions/1/errors.json'

Object.keys(errorDefinitions.codes).forEach(errorCode =>
describe(`error ${errorCode} accessors`, () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/getAreSlotsAdjacent.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import {
getAreSlotsAdjacent,
getAreSlotsHorizontallyAdjacent,
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/getWellNamePerMultiTip.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import fixture_trash from '../../labware/fixtures/2/fixture_trash.json'
import fixture_96_plate from '../../labware/fixtures/2/fixture_96_plate.json'
import fixture_384_plate from '../../labware/fixtures/2/fixture_384_plate.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/labwareDefQuirks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import glob from 'glob'
import { describe, expect, it, beforeAll } from 'vitest'

const definitionsGlobPath = path.join(
__dirname,
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/labwareDefSchemaV1.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import glob from 'glob'
import Ajv from 'ajv'
import { describe, expect, it, beforeAll } from 'vitest'

import { labwareSchemaV1 } from '../schema'
import type { LabwareDefinition1 } from '../types'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/labwareDefSchemaV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import path from 'path'
import glob from 'glob'
import Ajv from 'ajv'
import { describe, expect, it, beforeAll, test } from 'vitest'

import schema from '../../labware/schemas/2.json'
import type { LabwareDefinition2, LabwareWell } from '../types'
Expand Down
13 changes: 8 additions & 5 deletions shared-data/js/__tests__/moduleAccessors.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest'

import {
getModuleDef2,
getModuleType,
Expand Down Expand Up @@ -36,15 +38,16 @@ describe('all valid models work', () => {
})
})

describe('legacy models work too', () => {
describe('legacy models', () => {
const legacyEquivs = [
[TEMPDECK, TEMPERATURE_MODULE_V1],
[MAGDECK, MAGNETIC_MODULE_V1],
[THERMOCYCLER, THERMOCYCLER_MODULE_V1],
] as const

legacyEquivs.forEach(([legacy, modern]) => {
const fromLegacy = normalizeModuleModel(legacy)
expect(fromLegacy).toEqual(modern)
it('legacy models work too', () => {
legacyEquivs.forEach(([legacy, modern]) => {
const fromLegacy = normalizeModuleModel(legacy)
expect(fromLegacy).toEqual(modern)
})
})
})
1 change: 1 addition & 0 deletions shared-data/js/__tests__/moduleSpecsSchema.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ajv from 'ajv'
import { describe, expect, it, beforeAll } from 'vitest'
import moduleSpecsSchemaV1 from '../../module/schemas/1.json'
import moduleSpecsV1 from '../../module/definitions/1.json'
import moduleSpecsSchemaV2 from '../../module/schemas/2.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/pipetteSchemaV2.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ajv from 'ajv'
import glob from 'glob'
import path from 'path'
import { describe, expect, it } from 'vitest'

import liquidSpecsSchema from '../../pipette/schemas/2/pipetteLiquidPropertiesSchema.json'
import geometrySpecsSchema from '../../pipette/schemas/2/pipetteGeometrySchema.json'
Expand Down
2 changes: 2 additions & 0 deletions shared-data/js/__tests__/pipetteSpecSchemas.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Ajv from 'ajv'
import { describe, expect, it } from 'vitest'

import nameSpecsSchema from '../../pipette/schemas/1/pipetteNameSpecsSchema.json'
import modelSpecsSchema from '../../pipette/schemas/1/pipetteModelSpecsSchema.json'
import pipetteNameSpecs from '../../pipette/definitions/1/pipetteNameSpecs.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/pipettes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// tests for pipette info accessors in `shared-data/js/pipettes.js`
import { describe, expect, it } from 'vitest'
import { getPipetteNameSpecs, getPipetteModelSpecs } from '../pipettes'

const PIPETTE_NAMES = [
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/protocolSchemaV4.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Ajv from 'ajv'
import path from 'path'
import glob from 'glob'
import omit from 'lodash/omit'
import { describe, expect, it } from 'vitest'

import protocolSchema from '../../protocol/schemas/4.json'
import labwareV2Schema from '../../labware/schemas/2.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/protocolSchemaV5.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Ajv from 'ajv'
import path from 'path'
import glob from 'glob'
import omit from 'lodash/omit'
import { describe, expect, it } from 'vitest'

import protocolSchema from '../../protocol/schemas/5.json'
import labwareV2Schema from '../../labware/schemas/2.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/protocolSchemaV6.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Ajv from 'ajv'
import path from 'path'
import glob from 'glob'
import omit from 'lodash/omit'
import { describe, expect, it } from 'vitest'

import protocolSchema from '../../protocol/schemas/6.json'
import labwareV2Schema from '../../labware/schemas/2.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/protocolSchemaV7.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Ajv from 'ajv'
import path from 'path'
import glob from 'glob'
import omit from 'lodash/omit'
import { describe, expect, it } from 'vitest'

import protocolSchema from '../../protocol/schemas/7.json'
import labwareV2Schema from '../../labware/schemas/2.json'
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/protocolValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'path'
import glob from 'glob'
import { validate } from '../protocols'
import { omit } from 'lodash'
import { describe, expect, it } from 'vitest'

const relRoot = path.join(__dirname, '../../protocol/fixtures/')

Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/sortWells.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import { sortWells } from '../helpers'

describe('sortWells', () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/__tests__/splitWellsOnColumn.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import { splitWellsOnColumn } from '../helpers'

describe('test splitWellsOnColumn', () => {
Expand Down
5 changes: 3 additions & 2 deletions shared-data/js/__tests__/validateErrors.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Tests for error data validation
import { describe, expect, it } from 'vitest'

import Ajv from 'ajv'

import errorDefinitions from '@opentrons/shared-data/errors/definitions/1/errors.json'
import errorSchema from '@opentrons/shared-data/errors/schemas/1.json'
import errorDefinitions from '../../errors/definitions/1/errors.json'
import errorSchema from '../../errors/schemas/1.json'

describe('error data should match error schema', () => {
it('error schema should match', () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/getAdapterName.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { getAdapterName } from '../index'

describe('getAdapterName', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import ot2DeckDef from '../../../deck/definitions/4/ot2_standard.json'
import ot3DeckDef from '../../../deck/definitions/4/ot3_standard.json'
import { getDeckDefFromRobotType } from '..'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import {
FLEX_SIMPLEST_DECK_CONFIG_PROTOCOL_SPEC,
getSimplestDeckConfigForProtocol,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { getVectorDifference } from '../getVectorDifference'

describe('getVectorDifference', () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/getVectorSum.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { getVectorSum } from '../getVectorSum'

describe('getVectorSum', () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/labwareInference.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { getIfConsistent, getSpacingIfUniform } from '../labwareInference'

describe('getSpacingIfUniform', () => {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/orderWells.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { orderWells } from '../orderWells'
import type { WellOrderOption } from '../orderWells'

Expand Down
4 changes: 2 additions & 2 deletions shared-data/js/helpers/__tests__/parseProtocolData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('validateJsonProtocolFileContents', () => {
it('should call handleError with INVALID_FILE_TYPE if empty json', () => {
validateJsonProtocolFileContents('[]', handleError)
expect(handleError).toBeCalledWith('INVALID_JSON_FILE', {
rawError: expect.any(Error),
rawError: 'Error: schema should be object or boolean',
})
})

Expand All @@ -70,7 +70,7 @@ describe('validateJsonProtocolFileContents', () => {
})
validateJsonProtocolFileContents('[]', handleError)
expect(handleError).toBeCalledWith('INVALID_JSON_FILE', {
rawError: expect.any(Error),
rawError: 'Error: not parseable as JSON',
})
parseSpy.mockRestore()
})
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/volume.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// volume helpers tests
import { describe, it, expect } from 'vitest'
import * as helpers from '..'

interface BaseSpec<T extends (...args: any) => any> {
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/helpers/__tests__/wellSets.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, beforeEach } from 'vitest'
import pipetteNameSpecsFixtures from '../../../pipette/fixtures/name/pipetteNameSpecFixtures.json'
import fixture_12_trough from '../../../labware/fixtures/2/fixture_12_trough.json'
import fixture_96_plate from '../../../labware/fixtures/2/fixture_96_plate.json'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`test createIrregularLabware function > failing to validate against labware schema throws w/o "strict" 1`] = `[Error: Generated labware failed to validate, please check your inputs]`;

exports[`test createIrregularLabware function failing to validate against labware schema throws w/o "strict" 1`] = `"Generated labware failed to validate, please check your inputs"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`createLabware > failing to validate against labware schema throws w/o "strict" 1`] = `[Error: Generated labware failed to validate, please check your inputs]`;

exports[`createLabware failing to validate against labware schema throws w/o "strict" 1`] = `"Generated labware failed to validate, please check your inputs"`;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest'
import { createDefaultDisplayName } from '..'

import type { RegularNameProps } from '..'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import omit from 'lodash/omit'
import range from 'lodash/range'

import { describe, it, expect, beforeEach } from 'vitest'
import { splitWellsOnColumn, sortWells } from '../../helpers/index'
import fixture_irregular_example_1 from '../../../labware/fixtures/2/fixture_irregular_example_1.json'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import omit from 'lodash/omit'
import range from 'lodash/range'
import { describe, it, expect, beforeEach } from 'vitest'
import { createRegularLabware } from '..'
import fixture_regular_example_1 from '../../../labware/fixtures/2/fixture_regular_example_1.json'
import fixture_regular_example_2 from '../../../labware/fixtures/2/fixture_regular_example_2.json'
Expand Down
4 changes: 2 additions & 2 deletions shared-data/labware/fixtures/2/fixture_calibration_block.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"format": "irregular",
"isTiprack": false,
"isMagneticModuleCompatible": false,
"loadName": "opentrons_calibrationblock_short_side_left"
"loadName": "fixture_calibration_block"
},
"ordering": [["A1"], ["A2"]],
"namespace": "opentrons",
"namespace": "fixture",
"version": 1,
"schemaVersion": 2,
"cornerOffsetFromSlot": {
Expand Down

0 comments on commit 485addb

Please sign in to comment.