1
1
import { describe , expect , test } from "vitest"
2
- import { CarSimulatorEngine } from "../src/CarSimulatorEngine "
2
+ import { CarSimulator } from "../src/CarSimulator "
3
3
4
- describe ( "CarSimulatorEngine " , ( ) => {
5
- describe ( "new CarSimulatorEngine ()" , ( ) => {
4
+ describe ( "CarSimulator " , ( ) => {
5
+ describe ( "new CarSimulator ()" , ( ) => {
6
6
test ( "should return an instance of AidesVeloEngine with corrects rules parsed" , ( ) => {
7
- const engine = new CarSimulatorEngine ( )
8
- expect ( engine ) . toBeInstanceOf ( CarSimulatorEngine )
7
+ const engine = new CarSimulator ( )
8
+ expect ( engine ) . toBeInstanceOf ( CarSimulator )
9
9
10
10
const parsedRules = engine . getEngine ( ) . getParsedRules ( )
11
11
expect ( parsedRules [ "coûts" ] ) . toBeDefined ( )
12
12
expect ( parsedRules [ "empreinte" ] ) . toBeDefined ( )
13
13
} )
14
14
} )
15
15
16
- const globalTestEngine = new CarSimulatorEngine ( )
16
+ const globalTestEngine = new CarSimulator ( )
17
17
18
18
describe ( "setInputs()" , ( ) => {
19
19
test ( "should correctly set the engine's situation" , ( ) => {
@@ -195,9 +195,7 @@ describe("CarSimulatorEngine", () => {
195
195
describe ( "evaluateAlternatives()" , ( ) => {
196
196
test ( "should return all possible alternatives with default values" , ( ) => {
197
197
const engine = globalTestEngine . shallowCopy ( )
198
- console . time ( "evaluateAlternatives" )
199
198
const alternatives = engine . evaluateAlternatives ( )
200
- console . timeEnd ( "evaluateAlternatives" )
201
199
// TODO: use engine.getOptions
202
200
const nbMotorisations = 3
203
201
const nbFuels = 4
@@ -218,8 +216,8 @@ describe("CarSimulatorEngine", () => {
218
216
expect ( alternative . motorisation . value ) . toBeDefined ( )
219
217
expect ( alternative . motorisation . isEnumValue ) . toBeTruthy ( )
220
218
if ( alternative . motorisation . value !== "électrique" ) {
221
- expect ( alternative . fuel . value ) . toBeDefined ( )
222
- expect ( alternative . fuel . isEnumValue ) . toBeTruthy ( )
219
+ expect ( alternative . fuel ? .value ) . toBeDefined ( )
220
+ expect ( alternative . fuel ? .isEnumValue ) . toBeTruthy ( )
223
221
} else {
224
222
expect ( alternative . fuel ) . toBeUndefined ( )
225
223
}
0 commit comments