-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathActorWorld.ts
32 lines (25 loc) · 939 Bytes
/
ActorWorld.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
import { World, IWorldOptions } from '@cucumber/cucumber'
import Actor from './Actor'
import ActorLookup from './ActorLookup'
import assignTasks from './assignTasks'
import asyncAssignTasks from './asyncAssignTasks'
export interface IActorWorldOptions extends IWorldOptions {
packageType: 'commonjs' | 'module'
}
export default class ActorWorld extends World {
public readonly actorLookup = new ActorLookup()
public readonly promise
constructor(props: IActorWorldOptions) {
const { packageType = 'commonjs', ...rest } = props
super(rest)
if (packageType === 'commonjs' && this.parameters.tasks) {
assignTasks(this, this.parameters.tasks)
}
if (packageType === 'module' && this.parameters.tasks) {
this.promise = asyncAssignTasks(this, this.parameters.tasks)
}
}
public findOrCreateActor(actorName: string): Actor {
return this.actorLookup.findOrCreateActor(this, actorName)
}
}