blob: b8b1fbdd7d7cb9cf770f02bc822ed635aa51107b (
plain) (
blame)
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
|
import * as operations from "../../../../src/shared/operations";
import BackgroundOperationOperator from "../../../../src/content/operators/impls/BackgroundOperationOperator";
import OperationClient from "../../../../src/content/client/OperationClient";
import { expect } from "chai";
class MockOperationClient implements OperationClient {
public readonly executedOps: {
op: operations.Operation;
repeat: number;
}[] = [];
async execBackgroundOp(
repeat: number,
op: operations.Operation
): Promise<void> {
this.executedOps.push({ repeat, op });
}
internalOpenUrl(): Promise<void> {
throw new Error("not implemented");
}
}
describe("BackgroundOperationOperator", () => {
describe("#run", () => {
it("returns an operator", async () => {
const client = new MockOperationClient();
const sut = new BackgroundOperationOperator(client, 2, {
type: operations.TAB_CLOSE,
});
await sut.run();
expect(client.executedOps).to.deep.equal([
{ op: { type: operations.TAB_CLOSE }, repeat: 2 },
]);
});
});
});
|