aboutsummaryrefslogtreecommitdiff
path: root/test/content
diff options
context:
space:
mode:
Diffstat (limited to 'test/content')
-rw-r--r--test/content/operators/impls/AddonOperatorFactoryChain.test.ts4
-rw-r--r--test/content/operators/impls/DisableAddonOperator.test.ts5
-rw-r--r--test/content/operators/impls/EnableAddonOperator.test.ts5
-rw-r--r--test/content/operators/impls/MockConsoleFramePresenter.ts26
-rw-r--r--test/content/operators/impls/ToggleAddonOperator.test.ts6
-rw-r--r--test/content/usecases/AddonEnabledUseCase.test.ts11
6 files changed, 51 insertions, 6 deletions
diff --git a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts
index c064bb9..dde5a35 100644
--- a/test/content/operators/impls/AddonOperatorFactoryChain.test.ts
+++ b/test/content/operators/impls/AddonOperatorFactoryChain.test.ts
@@ -6,13 +6,15 @@ import * as operations from "../../../../src/shared/operations";
import { expect } from "chai";
import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient";
import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository";
+import MockConsoleFramePresenter from "./MockConsoleFramePresenter";
describe("AddonOperatorFactoryChain", () => {
describe("#create", () => {
it("returns an operator", () => {
const sut = new AddonOperatorFactoryChain(
new MockAddonIndicatorClient(),
- new MockAddonEnabledRepository()
+ new MockAddonEnabledRepository(),
+ new MockConsoleFramePresenter(false)
);
expect(sut.create({ type: operations.ADDON_ENABLE }, 0)).to.be.instanceOf(
EnableAddonOperator
diff --git a/test/content/operators/impls/DisableAddonOperator.test.ts b/test/content/operators/impls/DisableAddonOperator.test.ts
index 358ae44..e05d1f1 100644
--- a/test/content/operators/impls/DisableAddonOperator.test.ts
+++ b/test/content/operators/impls/DisableAddonOperator.test.ts
@@ -2,18 +2,21 @@ import { expect } from "chai";
import DisableAddonOperator from "../../../../src/content/operators/impls/DisableAddonOperator";
import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient";
import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository";
+import MockConsoleFramePresenter from "./MockConsoleFramePresenter";
describe("DisableAddonOperator", () => {
describe("#run", () => {
it("disables addon", async () => {
const client = new MockAddonIndicatorClient(true);
const repository = new MockAddonEnabledRepository(true);
- const sut = new DisableAddonOperator(client, repository);
+ const presenter = new MockConsoleFramePresenter(true);
+ const sut = new DisableAddonOperator(client, repository, presenter);
await sut.run();
expect(client.enabled).to.be.false;
expect(repository.enabled).to.be.false;
+ expect(presenter.attached).to.be.false;
});
});
});
diff --git a/test/content/operators/impls/EnableAddonOperator.test.ts b/test/content/operators/impls/EnableAddonOperator.test.ts
index a6ca31b..6025608 100644
--- a/test/content/operators/impls/EnableAddonOperator.test.ts
+++ b/test/content/operators/impls/EnableAddonOperator.test.ts
@@ -2,18 +2,21 @@ import { expect } from "chai";
import EnableAddonOperator from "../../../../src/content/operators/impls/EnableAddonOperator";
import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient";
import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository";
+import MockConsoleFramePresenter from "./MockConsoleFramePresenter";
describe("EnableAddonOperator", () => {
describe("#run", () => {
it("enabled addon", async () => {
const client = new MockAddonIndicatorClient(false);
const repository = new MockAddonEnabledRepository(false);
- const sut = new EnableAddonOperator(client, repository);
+ const presenter = new MockConsoleFramePresenter(false);
+ const sut = new EnableAddonOperator(client, repository, presenter);
await sut.run();
expect(client.enabled).to.be.true;
expect(repository.enabled).to.be.true;
+ expect(presenter.attached).to.be.true;
});
});
});
diff --git a/test/content/operators/impls/MockConsoleFramePresenter.ts b/test/content/operators/impls/MockConsoleFramePresenter.ts
new file mode 100644
index 0000000..23bc27f
--- /dev/null
+++ b/test/content/operators/impls/MockConsoleFramePresenter.ts
@@ -0,0 +1,26 @@
+import ConsoleFramePresenter from "../../../../src/content/presenters/ConsoleFramePresenter";
+
+export default class MockConsoleFramePresenter
+ implements ConsoleFramePresenter {
+ constructor(public attached: boolean) {}
+
+ attach(): void {
+ this.attached = true;
+ }
+
+ detach(): void {
+ this.attached = false;
+ }
+
+ blur(): void {
+ throw new Error("not implemented");
+ }
+
+ resize(_width: number, _height: number): void {
+ throw new Error("not implemented");
+ }
+
+ isTopWindow(): boolean {
+ return true;
+ }
+}
diff --git a/test/content/operators/impls/ToggleAddonOperator.test.ts b/test/content/operators/impls/ToggleAddonOperator.test.ts
index 6026eb1..1f291b5 100644
--- a/test/content/operators/impls/ToggleAddonOperator.test.ts
+++ b/test/content/operators/impls/ToggleAddonOperator.test.ts
@@ -2,23 +2,27 @@ import { expect } from "chai";
import ToggleAddonOperator from "../../../../src/content/operators/impls/ToggleAddonOperator";
import MockAddonIndicatorClient from "../../mock/MockAddonIndicatorClient";
import MockAddonEnabledRepository from "../../mock/MockAddonEnabledRepository";
+import MockConsoleFramePresenter from "./MockConsoleFramePresenter";
describe("ToggleAddonOperator", () => {
describe("#run", () => {
it("toggles addon-enabled state", async () => {
const client = new MockAddonIndicatorClient(true);
const repository = new MockAddonEnabledRepository(true);
- const sut = new ToggleAddonOperator(client, repository);
+ const presenter = new MockConsoleFramePresenter(true);
+ const sut = new ToggleAddonOperator(client, repository, presenter);
await sut.run();
expect(client.enabled).to.be.false;
expect(repository.enabled).to.be.false;
+ expect(presenter.attached).to.be.false;
await sut.run();
expect(client.enabled).to.be.true;
expect(repository.enabled).to.be.true;
+ expect(presenter.attached).to.be.true;
});
});
});
diff --git a/test/content/usecases/AddonEnabledUseCase.test.ts b/test/content/usecases/AddonEnabledUseCase.test.ts
index 885da83..8a614c5 100644
--- a/test/content/usecases/AddonEnabledUseCase.test.ts
+++ b/test/content/usecases/AddonEnabledUseCase.test.ts
@@ -2,6 +2,7 @@ import AddonEnabledRepository from "../../../src/content/repositories/AddonEnabl
import AddonEnabledUseCase from "../../../src/content/usecases/AddonEnabledUseCase";
import AddonIndicatorClient from "../../../src/content/client/AddonIndicatorClient";
import { expect } from "chai";
+import MockConsoleFramePresenter from "../operators/impls/MockConsoleFramePresenter";
class MockAddonEnabledRepository implements AddonEnabledRepository {
private enabled: boolean;
@@ -35,12 +36,14 @@ class MockAddonIndicatorClient implements AddonIndicatorClient {
describe("AddonEnabledUseCase", () => {
let repository: MockAddonEnabledRepository;
let indicator: MockAddonIndicatorClient;
+ let presenter: MockConsoleFramePresenter;
let sut: AddonEnabledUseCase;
beforeEach(() => {
- repository = new MockAddonEnabledRepository(true);
+ repository = new MockAddonEnabledRepository(false);
indicator = new MockAddonIndicatorClient(false);
- sut = new AddonEnabledUseCase(indicator, repository);
+ presenter = new MockConsoleFramePresenter(false);
+ sut = new AddonEnabledUseCase(indicator, repository, presenter);
});
describe("#enable", () => {
@@ -49,6 +52,7 @@ describe("AddonEnabledUseCase", () => {
expect(repository.get()).to.be.true;
expect(indicator.enabled).to.be.true;
+ expect(presenter.attached).to.be.true;
});
});
@@ -58,6 +62,7 @@ describe("AddonEnabledUseCase", () => {
expect(repository.get()).to.be.false;
expect(indicator.enabled).to.be.false;
+ expect(presenter.attached).to.be.false;
});
});
@@ -68,6 +73,7 @@ describe("AddonEnabledUseCase", () => {
expect(repository.get()).to.be.false;
expect(indicator.enabled).to.be.false;
+ expect(presenter.attached).to.be.false;
repository.set(false);
@@ -75,6 +81,7 @@ describe("AddonEnabledUseCase", () => {
expect(repository.get()).to.be.true;
expect(indicator.enabled).to.be.true;
+ expect(presenter.attached).to.be.true;
});
});