Skip to content

Commit be775dc

Browse files
author
edgarjrg
committed
remove unnecesary types
1 parent dfb672a commit be775dc

File tree

3 files changed

+45
-51
lines changed

3 files changed

+45
-51
lines changed

Diff for: commands.ts

+44-44
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ import {
1717
clearNewToDo
1818
} from './utils';
1919
import { all, } from "ramda";
20-
import { ModelMachine2 } from './modelMachine';
20+
import { ModelMachine } from './modelMachine';
2121

22-
export class EnterCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
22+
export class EnterCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
2323
constructor() { }
2424

25-
check(_m: Readonly<ModelMachine2>) {
25+
check(_m: Readonly<ModelMachine>) {
2626
return true
2727
};
2828

29-
async run(m: ModelMachine2, page: Page) {
29+
async run(m: ModelMachine, page: Page) {
3030

3131
await checkModel(m.state.context)
3232
// .catch(e => { throw new Error(e) })
@@ -49,14 +49,14 @@ export class EnterCommand implements fc.AsyncCommand<ModelMachine2, Page, false>
4949
toString = () => `${EnterCommand.name}`;
5050
}
5151

52-
export class WriteInputCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
52+
export class WriteInputCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
5353
constructor(readonly input: Model['input']) { }
5454

55-
check(_m: Readonly<ModelMachine2>) {
55+
check(_m: Readonly<ModelMachine>) {
5656
return true;
5757
};
5858

59-
async run(m: ModelMachine2, page: Page) {
59+
async run(m: ModelMachine, page: Page) {
6060

6161
await clearNewToDo(CLASS_SELECTORS.NEW_TODO)
6262

@@ -77,16 +77,16 @@ export class WriteInputCommand implements fc.AsyncCommand<ModelMachine2, Page, f
7777
toString = () => `${WriteInputCommand.name} ${JSON.stringify(this.input)}`;
7878
}
7979

80-
export class MarkAllCompletedCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
80+
export class MarkAllCompletedCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
8181
constructor() { }
8282

83-
check(m: Readonly<ModelMachine2>) {
83+
check(m: Readonly<ModelMachine>) {
8484

8585
return m.state.context.toDos.length > 0;
8686

8787
};
8888

89-
async run(m: ModelMachine2, page: Page) {
89+
async run(m: ModelMachine, page: Page) {
9090

9191
await page.click(CLASS_SELECTORS.TOGGLE_ALL_LABEL)
9292

@@ -104,16 +104,16 @@ export class MarkAllCompletedCommand implements fc.AsyncCommand<ModelMachine2, P
104104
toString = () => `${MarkAllCompletedCommand.name}`;
105105
}
106106

107-
export class ToggleItemCompletedCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
107+
export class ToggleItemCompletedCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
108108
constructor() { }
109109

110-
check(m: Readonly<ModelMachine2>) {
110+
check(m: Readonly<ModelMachine>) {
111111

112112
return filteredToDos(m.state.context).length > 0;
113113

114114
};
115115

116-
async run(m: ModelMachine2, page: Page) {
116+
async run(m: ModelMachine, page: Page) {
117117

118118
await page
119119
.$$(CLASS_SELECTORS.TODO_ITEMS_INPUT)
@@ -144,16 +144,16 @@ export class ToggleItemCompletedCommand implements fc.AsyncCommand<ModelMachine2
144144
toString = () => `${ToggleItemCompletedCommand.name}`;
145145
}
146146

147-
export class TriggerEditingCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
147+
export class TriggerEditingCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
148148
constructor(readonly number: number) { }
149149

150-
check(m: Readonly<ModelMachine2>) {
150+
check(m: Readonly<ModelMachine>) {
151151

152152
return filteredToDos(m.state.context).length > 0;
153153

154154
};
155155

156-
async run(m: ModelMachine2, page: Page) {
156+
async run(m: ModelMachine, page: Page) {
157157
const index = pickToDo(this.number, m.state.context);
158158

159159
await page
@@ -193,16 +193,16 @@ export class TriggerEditingCommand implements fc.AsyncCommand<ModelMachine2, Pag
193193
toString = () => `${TriggerEditingCommand.name}`;
194194
}
195195

196-
export class EditTodoCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
196+
export class EditTodoCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
197197
constructor(readonly todo: Model['input'], readonly number: number) { }
198198

199-
check(m: Readonly<ModelMachine2>) {
199+
check(m: Readonly<ModelMachine>) {
200200

201201
return filteredToDos(m.state.context).length > 0;
202202

203203
};
204204

205-
async run(m: ModelMachine2, page: Page) {
205+
async run(m: ModelMachine, page: Page) {
206206
const index = pickToDo(this.number, m.state.context);
207207

208208
await page
@@ -257,16 +257,16 @@ export class EditTodoCommand implements fc.AsyncCommand<ModelMachine2, Page, fal
257257
toString = () => `${EditTodoCommand.name} ${JSON.stringify(this.todo)}`;
258258
}
259259

260-
export class EditEmptyCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
260+
export class EditEmptyCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
261261
constructor(readonly number: number) { }
262262

263-
check(m: Readonly<ModelMachine2>) {
263+
check(m: Readonly<ModelMachine>) {
264264

265265
return filteredToDos(m.state.context).length > 0;
266266

267267
};
268268

269-
async run(m: ModelMachine2, page: Page) {
269+
async run(m: ModelMachine, page: Page) {
270270
const index = pickToDo(this.number, m.state.context);
271271

272272
await page
@@ -312,20 +312,20 @@ export class EditEmptyCommand implements fc.AsyncCommand<ModelMachine2, Page, fa
312312
toString = () => `${EditEmptyCommand.name}`;
313313
}
314314

315-
export class EditCancelCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
315+
export class EditCancelCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
316316

317-
model: Readonly<ModelMachine2> | undefined
317+
model: Readonly<ModelMachine> | undefined
318318

319319
constructor(readonly todo: Model['input'], readonly number: number) { }
320320

321-
check(m: Readonly<ModelMachine2>) {
321+
check(m: Readonly<ModelMachine>) {
322322

323323
this.model = m;
324324
return filteredToDos(m.state.context).length > 0;
325325

326326
};
327327

328-
async run(m: ModelMachine2, page: Page) {
328+
async run(m: ModelMachine, page: Page) {
329329
this.model = m;
330330
const index = pickToDo(this.number, m.state.context);
331331

@@ -378,15 +378,15 @@ export class EditCancelCommand implements fc.AsyncCommand<ModelMachine2, Page, f
378378

379379
}
380380

381-
export class ClearCompletedCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
381+
export class ClearCompletedCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
382382

383383
constructor() { }
384384

385-
check(m: Readonly<ModelMachine2>) {
385+
check(m: Readonly<ModelMachine>) {
386386
return itemsLeftCount(m.state.context.toDos) < m.state.context.toDos.length;
387387
};
388388

389-
async run(m: ModelMachine2, page: Page) {
389+
async run(m: ModelMachine, page: Page) {
390390

391391
await page.click(CLASS_SELECTORS.CLEAR_COMPLETED);
392392

@@ -404,15 +404,15 @@ export class ClearCompletedCommand implements fc.AsyncCommand<ModelMachine2, Pag
404404

405405
}
406406

407-
export class AddToDosCommands implements fc.AsyncCommand<ModelMachine2, Page, false> {
407+
export class AddToDosCommands implements fc.AsyncCommand<ModelMachine, Page, false> {
408408

409409
constructor(readonly toDos: ValidInput[]) { }
410410

411-
check(_m: Readonly<ModelMachine2>) {
411+
check(_m: Readonly<ModelMachine>) {
412412
return true
413413
};
414414

415-
async run(m: ModelMachine2, page: Page) {
415+
async run(m: ModelMachine, page: Page) {
416416

417417
expect(all(isValidTodo)(this.toDos.map(x => x.text))).toBe(true)
418418

@@ -451,15 +451,15 @@ export class AddToDosCommands implements fc.AsyncCommand<ModelMachine2, Page, fa
451451

452452
}
453453

454-
export class GoToAllCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
454+
export class GoToAllCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
455455

456456
constructor() { }
457457

458-
check(m: Readonly<ModelMachine2>) {
458+
check(m: Readonly<ModelMachine>) {
459459
return m.state.context.toDos.length > 0;
460460
};
461461

462-
async run(m: ModelMachine2, page: Page) {
462+
async run(m: ModelMachine, page: Page) {
463463

464464
await expect(page)
465465
.toMatchElement(CLASS_SELECTORS.FILTER_ITEMS, { text: 'All' })
@@ -485,15 +485,15 @@ export class GoToAllCommand implements fc.AsyncCommand<ModelMachine2, Page, fals
485485

486486
}
487487

488-
export class GoToActiveCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
488+
export class GoToActiveCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
489489

490490
constructor() { }
491491

492-
check(m: Readonly<ModelMachine2>) {
492+
check(m: Readonly<ModelMachine>) {
493493
return m.state.context.toDos.length > 0;
494494
};
495495

496-
async run(m: ModelMachine2, page: Page) {
496+
async run(m: ModelMachine, page: Page) {
497497

498498
await expect(page)
499499
.toMatchElement(CLASS_SELECTORS.FILTER_ITEMS, { text: 'Active' })
@@ -518,15 +518,15 @@ export class GoToActiveCommand implements fc.AsyncCommand<ModelMachine2, Page, f
518518

519519
}
520520

521-
export class GoToCompletedCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
521+
export class GoToCompletedCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
522522

523523
constructor() { }
524524

525-
check(m: Readonly<ModelMachine2>) {
525+
check(m: Readonly<ModelMachine>) {
526526
return m.state.context.toDos.length > 0;
527527
};
528528

529-
async run(m: ModelMachine2, page: Page) {
529+
async run(m: ModelMachine, page: Page) {
530530

531531
await expect(page)
532532
.toMatchElement(CLASS_SELECTORS.FILTER_ITEMS, { text: 'Completed' })
@@ -551,15 +551,15 @@ export class GoToCompletedCommand implements fc.AsyncCommand<ModelMachine2, Page
551551

552552
}
553553

554-
export class GoBackCommand implements fc.AsyncCommand<ModelMachine2, Page, false> {
554+
export class GoBackCommand implements fc.AsyncCommand<ModelMachine, Page, false> {
555555

556556
constructor() { }
557557

558-
check(m: Readonly<ModelMachine2>) {
558+
check(m: Readonly<ModelMachine>) {
559559
return m.state.context.navigation.length > 1;
560560
};
561561

562-
async run(m: ModelMachine2, page: Page) {
562+
async run(m: ModelMachine, page: Page) {
563563

564564
await page.goBack()
565565

Diff for: modelMachine.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ const ACTION = {
207207
}),
208208
}
209209

210-
export type ModelMachine = StateMachine<Model, Schema, Event, any>
211-
export type ModelMachine2 = Interpreter<Model, Schema, Event, any>
212-
export type ModelMachine3 = State<Model, Event, Schema, any>
210+
export type ModelMachine = Interpreter<Model, Schema, Event, any>
213211

214212
export const modelMachine = Machine<Context, Schema, Event>({
215213
initial: 'DEFAULT',

Diff for: stateful.spec.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import * as fc from 'fast-check'
22
import { CLASS_SELECTORS } from './cons';
33
import {
4-
// ValidEnterCommand,
5-
// WhiteEnterCommand,
6-
// EmptyEnterCommand,
7-
// TrimEnterCommand,
84
WriteInputCommand,
95
MarkAllCompletedCommand,
106
ToggleItemCompletedCommand,

0 commit comments

Comments
 (0)