-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic plugin specs for transform registry
- Loading branch information
1 parent
1ca7f87
commit 321c078
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use babel"; | ||
|
||
import React from "react"; | ||
|
||
import { toJS } from "mobx"; | ||
import HydrogenProvider from "./../../lib/plugin-api/hydrogen-provider"; | ||
import Hydrogen from "./../../lib/main"; | ||
import transformManager from "./../../lib/components/transforms"; | ||
import Markdown from "./../../lib/components/transforms/markdown"; | ||
|
||
describe("Hydrogen Provider", () => { | ||
const plugin = Hydrogen.provideHydrogen(); | ||
it("should create a valid provider", () => { | ||
expect(plugin instanceof HydrogenProvider).toBeTruthy(); | ||
}); | ||
|
||
describe("registerTransform", () => { | ||
it("should add a new transform", () => { | ||
expect(plugin.registerTransform(<Markdown />, "mark")).toBeTruthy(); | ||
expect(transformManager.transforms.has("mark")).toBeTruthy(); | ||
expect(transformManager.transforms.get("mark").type).toEqual(Markdown); | ||
}); | ||
|
||
it("should not override an existing transform", () => { | ||
expect(plugin.registerTransform(<Markdown />, "svg")).toBeTruthy(); | ||
expect(transformManager.transforms.get("svg").type).not.toEqual(Markdown); | ||
}); | ||
}); | ||
|
||
describe("unregisterTransform", () => { | ||
it("should remove a transform", () => { | ||
expect(plugin.unregisterTransform("mark")).toBeTruthy(); | ||
expect(!transformManager.transforms.has("mark")).toBeTruthy(); | ||
}); | ||
|
||
it("should return false for non-existent key", () => { | ||
expect(!plugin.unregisterTransform("mark")).toBeTruthy(); | ||
}); | ||
}); | ||
}); |