Skip to content

Commit 111d797

Browse files
committed
add integration unit tests for SignalCommandMap class
1 parent 0b3aaaf commit 111d797

18 files changed

+957
-0
lines changed

test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMapIntegration.test.ts

Lines changed: 597 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { IInjector, ICommand } from "@robotlegsjs/core";
11+
12+
import { ISignalCommandMap } from "../../../../../../src/robotlegs/bender/extensions/signalCommandMap/api/ISignalCommandMap";
13+
14+
import { NullCommand } from "./NullCommand";
15+
import { SupportSignal } from "./SupportSignal";
16+
17+
@injectable()
18+
export class CascadingCommand implements ICommand {
19+
@inject("Function")
20+
@named("executeCallback")
21+
public callback: Function;
22+
23+
@inject(IInjector) public injector: IInjector;
24+
25+
@inject(ISignalCommandMap) public signalCommandMap: ISignalCommandMap;
26+
27+
public execute(): void {
28+
this.callback();
29+
30+
this.signalCommandMap
31+
.map(SupportSignal)
32+
.toCommand(NullCommand)
33+
.once();
34+
35+
let signal: SupportSignal = this.injector.get(SupportSignal);
36+
signal.dispatch();
37+
}
38+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { ICommand } from "@robotlegsjs/core";
11+
12+
import { Payload } from "./Payload";
13+
14+
@injectable()
15+
export class ExecuteMethodWithParametersCommand implements ICommand {
16+
@inject("Function")
17+
@named("executeCallback")
18+
public callback: Function;
19+
20+
public payload: Payload;
21+
22+
public execute(payload: Payload = null): void {
23+
this.payload = payload;
24+
this.callback(this);
25+
}
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, IGuard } from "@robotlegsjs/core";
9+
10+
@injectable()
11+
export class GrumpyGuard implements IGuard {
12+
public approve(): boolean {
13+
return false;
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, IGuard } from "@robotlegsjs/core";
9+
10+
@injectable()
11+
export class HappyGuard implements IGuard {
12+
public approve(): boolean {
13+
return true;
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable } from "inversify";
9+
10+
@injectable()
11+
export class Payload {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { ICommand } from "@robotlegsjs/core";
11+
12+
import { Payload } from "./Payload";
13+
14+
@injectable()
15+
export class PayloadInjectedCallbackCommand implements ICommand {
16+
@inject("Function")
17+
@named("executeCallback")
18+
public callback: Function;
19+
20+
@inject(Payload) public payload: Payload;
21+
22+
public execute(): void {
23+
this.callback(this);
24+
}
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { Payload } from "./Payload";
11+
12+
@injectable()
13+
export class PayloadInjectedGuard {
14+
@inject("Function")
15+
@named("approveCallback")
16+
public callback: Function;
17+
18+
@inject(Payload) public payload: Payload;
19+
20+
public approve(): boolean {
21+
this.callback(this, PayloadInjectedGuard);
22+
return true;
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { Payload } from "./Payload";
11+
12+
@injectable()
13+
export class PayloadInjectedHook {
14+
@inject("Function")
15+
@named("hookCallback")
16+
public callback: Function;
17+
18+
@inject(Payload) public payload: Payload;
19+
20+
public hook(): void {
21+
this.callback(this, PayloadInjectedHook);
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) 2017 RobotlegsJS. All Rights Reserved.
3+
//
4+
// NOTICE: You are permitted to use, modify, and distribute this file
5+
// in accordance with the terms of the license agreement accompanying it.
6+
// ------------------------------------------------------------------------------
7+
8+
import { injectable, inject, named } from "inversify";
9+
10+
import { ICommand } from "@robotlegsjs/core";
11+
12+
@injectable()
13+
export class ReportingCommand implements ICommand {
14+
@inject("Function")
15+
@named("executeCallback")
16+
public callback: Function;
17+
18+
public execute(): void {
19+
this.callback(this, ReportingCommand);
20+
}
21+
}

0 commit comments

Comments
 (0)