Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: import test functions from vitest in every test file #9264

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { formatSignalingSystem } from 'applications/editor/tools/pointEdition/utils';

import type { SignalingSystemForm } from '../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { ApplicableTrackRange } from '../types';
import { makeSpeedRestrictionTrackRanges } from '../utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lineString } from '@turf/helpers';
import length from '@turf/length';
import type { LineString, Point, Position } from 'geojson';
import { describe, it, expect } from 'vitest';

import { editoastToEditorEntity } from 'applications/editor/data/utils';
import type { DetectorEntity } from 'applications/editor/tools/pointEdition/types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TFunction } from 'i18next';
import { describe, it, expect } from 'vitest';

import {
pathInputsEndingWithTwoWaypointsByMap,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import {
formatElectrificationRanges,
isScheduledPointsNotHonored,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { PathfindingResult } from 'common/api/osrdEditoastApi';

import { updatePathStepsFromOperationalPoints } from '../useSetupItineraryForTrainUpdate';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import {
generateCodeNumber,
getStopDurationTime,
Expand Down
1 change: 1 addition & 0 deletions front/src/common/IntervalsDataViz/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import along from '@turf/along';
import distance from '@turf/distance';
import type { LineString, FeatureCollection } from 'geojson';
import { tail, last } from 'lodash';
import { describe, it, expect } from 'vitest';

import { getLineStringDistance, update, resizeSegment, splitAt, mergeIn } from './data';
import type { LinearMetadataItem } from './types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, test, expect } from 'vitest';

import { initialState } from 'modules/pathfinding/consts';
import { reducer } from 'modules/pathfinding/hooks/usePathfinding';
import type { PathfindingAction } from 'modules/pathfinding/types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { PathProperties } from 'common/api/osrdEditoastApi';

import getPathVoltages from '../getPathVoltages';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { TrackRange } from 'common/api/osrdEditoastApi';

import { findTrackSectionOffset } from '../createPathStep';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import {
effortCurves,
voltageRangesForPowerRestrictions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { PowerRestrictionWarnings } from 'modules/powerRestriction/types';

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import {
createEmptyCurve,
createEmptyCurves,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import {
getDefaultRollingStockMode,
getRollingStockEditorDefaultValues,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { LightRollingStock } from 'common/api/osrdEditoastApi';
import { rollingStockPassesEnergeticModeFilters } from 'modules/rollingStock/hooks/useFilterRollingStock';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { RollingStock } from 'common/api/osrdEditoastApi';

import { getSupportedElectrification } from '../electric';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { effortCurves } from 'modules/powerRestriction/helpers/__tests__/sampleData';

import { getRollingStockPowerRestrictionsByMode } from '../powerRestrictions';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { TFunction } from 'i18next';
import { floor } from 'lodash';
import { describe, it, expect } from 'vitest';

import type { EffortCurves } from 'common/api/osrdEditoastApi';
import type { InputGroupSNCFValue } from 'common/BootstrapSNCF/InputGroupSNCF';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { computeFilter, type RollingStockFilters } from '../useFilterRollingStock';

describe('computeFilter', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it } from 'vitest';
import { describe, it, expect } from 'vitest';

import type { TrainScheduleResult } from 'common/api/osrdEditoastApi';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { LIST_VALUES, CHART_AXES } from 'modules/simulationResult/consts';

import simulationTrain from '../../../../../../tests/assets/operationStudies/simulationTrain';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it } from 'vitest';

// TODO: fix warped map - adapt this test
describe('getSimulationHoverPositions', () => {
it.skip('should not crash when headPosition exists but tailPosition does not', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
ElectrificationValues,
LayerData,
} from '@osrd-project/ui-speedspacechart/dist/types/chartTypes';
import { describe, it, expect } from 'vitest';

import type { PathPropertiesFormatted, PositionData } from 'applications/operationalStudies/types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe } from 'vitest';
import { describe, it, expect } from 'vitest';

import { time2sec } from 'utils/timeManipulation';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import type { SimulationResponseSuccess } from 'applications/operationalStudies/types';
import type { TrainScheduleResult } from 'common/api/osrdEditoastApi';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { findActualVmax } from '../utils';

describe('findActualVmax', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';

import type { PathStep } from 'reducers/osrdconf/types';

Expand Down
2 changes: 2 additions & 0 deletions front/src/reducers/editor/__tests__/editorReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, beforeEach, it, expect } from 'vitest';

import { editorInitialState, editorSliceActions, editorSlice } from 'reducers/editor';
import { createStoreWithoutMiddleware } from 'store';

Expand Down
2 changes: 1 addition & 1 deletion front/src/reducers/main/mainReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, it } from 'vitest';
import { describe, it, expect } from 'vitest';

import {
mainInitialState,
Expand Down
2 changes: 1 addition & 1 deletion front/src/reducers/map/mapReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect } from 'vitest';
import { describe, beforeEach, it, expect } from 'vitest';

import type { MapState, Viewport } from 'reducers/map';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, beforeEach, it, expect } from 'vitest';

import { mapViewerInitialState, mapViewerSlice, mapViewerSliceActions } from 'reducers/mapViewer';
import { createStoreWithoutMiddleware } from 'store';

Expand Down
2 changes: 2 additions & 0 deletions front/src/reducers/osrdconf/__tests__/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { ArrivalTimeTypes } from 'applications/stdcmV2/types';

import { computeLinkedOriginTimes, updatePathStepAtIndex } from '../helpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect } from 'vitest';
import { describe, it, expect } from 'vitest';

import { operationalStudiesConfSlice } from 'reducers/osrdconf/operationalStudiesConf';
import { defaultCommonConf } from 'reducers/osrdconf/osrdConfCommon';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { compact, last, omit } from 'lodash';
import { describe, beforeEach, it, expect } from 'vitest';

import { ArrivalTimeTypes, StdcmStopTypes } from 'applications/stdcmV2/types';
import type { Distribution, Infra, TrainScheduleBase } from 'common/api/osrdEditoastApi';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { last } from 'lodash';
import { describe, expect } from 'vitest';
import { describe, it, expect } from 'vitest';

import { ArrivalTimeTypes } from 'applications/stdcmV2/types';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect } from 'vitest';
import { describe, it, expect } from 'vitest';

import { createStoreWithoutMiddleware } from 'store';

Expand Down
2 changes: 1 addition & 1 deletion front/src/reducers/user/userReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, it } from 'vitest';
import { describe, expect, it } from 'vitest';

import {
userInitialState,
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/array.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { addElementAtIndex, isEmptyArray, splitArrayByFirstLetter } from 'utils/array';

describe('isEmptyArray', () => {
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/batch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { getBatchPackage } from '../batch';

const trainIds = [...Array(25)].map((_, i) => i);
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/constants.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { makeEnumBooleans } from 'utils/constants';

describe('makeEnumBooleans', () => {
Expand Down
2 changes: 1 addition & 1 deletion front/src/utils/__tests__/date.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it } from 'vitest';
import { describe, it, expect } from 'vitest';

import {
dateTimeToIso,
Expand Down
1 change: 1 addition & 0 deletions front/src/utils/__tests__/geometry.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { point, lineString, featureCollection } from '@turf/helpers';
import type { Feature, Point } from 'geojson';
import { describe, it, expect } from 'vitest';

import type { GeoJsonLineString as LineString } from 'common/api/osrdEditoastApi';
import { getTangent, getCurrentBearing, nearestPointOnLine } from 'utils/geometry';
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/numbers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { budgetFormat, isFloat, isInvalidFloatNumber, stripDecimalDigits } from 'utils/numbers';
import { NARROW_NO_BREAK_SPACE, NO_BREAK_SPACE } from 'utils/strings';

Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/physics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { jouleToKwh, minutePer100km } from 'utils/physics';

describe('jouleToKwh', () => {
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/strings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { capitalizeFirstLetter, conditionalStringConcat } from 'utils/strings';

describe('conditionalStringConcat', () => {
Expand Down
2 changes: 2 additions & 0 deletions front/src/utils/__tests__/timeManipulation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { ISO8601Duration2sec } from 'utils/timeManipulation';

describe('ISO8601Duration2sec', () => {
Expand Down
1 change: 0 additions & 1 deletion front/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default defineConfig(({ mode }) => {
port: +env.OSRD_VITE_PORT || 3000,
},
test: {
globals: true,
globalSetup: './vitest.global-setup.ts',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
environment: 'happy-dom',
Expand Down
Loading