-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcustom-world.ts
39 lines (34 loc) · 1.24 KB
/
custom-world.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { SimpleMathsCalculator } from '../domains/simple-maths/simple-maths-calculator';
import { setWorldConstructor } from '@cucumber/cucumber';
import { Stream } from 'stream';
export type MediaType = 'text/plain' | 'image/png' | 'application/json';
export type AttachBuffer = (data: Buffer, mediaType: MediaType) => void | Promise<void>;
export type AttachStream = (data: Stream, mediaType: MediaType) => void | Promise<void>;
export type AttachText = (data: string) => void | Promise<void>;
export type AttachStringifiedJson = (
data: string,
mediaType: 'application/json',
) => void | Promise<void>;
export type AttachBase64EncodedPng = (data: string, mediaType: 'image/png') => void | Promise<void>;
export type AttachFn = AttachBuffer &
AttachStream &
AttachBase64EncodedPng &
AttachStringifiedJson &
AttachText;
export interface CucumberWorldConstructorParams {
attach: AttachFn;
parameters: { [key: string]: string };
}
export class CustomWorld {
public attach: AttachFn;
public calculator: SimpleMathsCalculator = new SimpleMathsCalculator();
public foo = false;
public debug = false;
/**
*
*/
constructor({ attach }: CucumberWorldConstructorParams) {
this.attach = attach;
}
}
setWorldConstructor(CustomWorld);