Skip to content

Commit

Permalink
Add Step definition for AddCarToFleet
Browse files Browse the repository at this point in the history
  • Loading branch information
bofalke committed Mar 26, 2024
1 parent 51ef746 commit 5951fe5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
39 changes: 29 additions & 10 deletions packages/be/features/step_definitions/AddCarToFleetSteps.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
import { binding, given, then, when } from "cucumber-tsflow";

import { Car } from '@app/shared/types/fleet-management/car/car';
import { addCarToFleet } from "@app/shared/commands/fleet-management/add-car-to-fleet";
import { handleAddCarToFleet } from "@server/command-handlers/fleet-management/car/handle-add-car-to-fleet";
import { Event } from "@event-engine/messaging/event";
@binding()
class AddCarToFleetSteps {

private car: Car | undefined;
private events: Array<Event> = [];
@given('car is BMW model 1er')
public givenCarWithBrandAndModel (): string {
// Write code here that turns the phrase above into concrete actions
return 'pending';
public givenCarWithBrandAndModel (): void {
this.car = {
'vehicleId': 'f832125e-4a4f-4cef-963c-c783a73a52fe',
'brand' : 'BMW',
'model': '1er'
};
}

@when(/I add the car to the fleet/)
public addsCarToFleet(): string {
// Write code here that turns the phrase above into concrete actions
return 'pending';
public addsCarToFleet(): void {
const car = this.car;
if (car === undefined) {

return;
}
const command = addCarToFleet({...car});
(async () => {
for await (const event of handleAddCarToFleet(car, command))
this.events.push(event);
})();
}

@then(/an incomplete car should be added/)
public thenIncompleteCarAdded(): string {
// Write code here that turns the phrase above into concrete actions
return 'pending';
public thenIncompleteCarAdded(): void {
expect(this.events).toHaveLength(1);
const receivedEvent = this.events.pop();

expect(receivedEvent?.name).toBe('FleetManagement.Car.IncompleteCarAdded');
}
}

Expand Down
14 changes: 8 additions & 6 deletions packages/be/features/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"compilerOptions": {
"moduleResolution": "node",
"experimentalDecorators": true
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
"experimentalDecorators": true
},
"include": ["step_definitions/**/*.ts"]
}
2 changes: 1 addition & 1 deletion packages/be/nodemon.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"watch": ["src", "../shared"],
"watch": ["src", "features", "../shared"],
"ext": "ts,json",
"ignore": ["src/**/*.spec.ts", "../shared/**/*.spec.ts"],
"exec": "npx ts-node -r tsconfig-paths/register src/main.ts"
Expand Down
7 changes: 6 additions & 1 deletion packages/be/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./features/tsconfig.json"
}
],
"compilerOptions": {
"esModuleInterop": true
"esModuleInterop": true,
"moduleResolution": "node",
"experimentalDecorators": true
}
}

0 comments on commit 5951fe5

Please sign in to comment.