-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
add_todo_items.ts
29 lines (22 loc) · 924 Bytes
/
add_todo_items.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
import { PerformsTasks, step, Task } from 'serenity-js/lib/screenplay-protractor';
import { AddATodoItem } from './add_a_todo_item';
export class AddTodoItems implements Task {
static called(names: string[]): AddTodoItems {
return new AddTodoItems(names);
}
@step('{0} adds #description')
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(...this.addAll(this.items)); // array -> var args conversion
}
constructor(private items: string[]) {
}
// used in @step as #description
private description() { // tslint:disable-line:no-unused-variable
return !! this.items.length
? `todo items called: "${ this.items.join('", "') }"`
: 'no items';
}
private addAll(items: string[]): Task[] {
return items.map(item => AddATodoItem.called(item));
}
}