Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate tests to ESM #8

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import plantuml from "node-plantuml";
* See details about plugin API:
* https://github.com/unifiedjs/unified#plugin
*/
function remarkSimplePlantumlPlugin() {
function remarkLocalPlantumlPlugin() {
return async function transformer(syntaxTree) {
const nodes = [];
visit(syntaxTree, "code", node => {
Expand Down Expand Up @@ -43,4 +43,4 @@ function remarkSimplePlantumlPlugin() {
};
}

module.exports = remarkSimplePlantumlPlugin;
export default remarkLocalPlantumlPlugin;
18 changes: 12 additions & 6 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const chai = require("chai");
const fs = require("fs");
const path = require("path");
const remark = require("remark");
const plugin = require("../index");
import chai from "chai";
import fs from "fs";
import path from "path";
import remark from "remark";
import plugin from "../index.js";

import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);


describe("Plugin", () => {
it("should convert PlantUML code to Image nodes", async () => {
Expand All @@ -13,7 +18,8 @@ describe("Plugin", () => {
.use(plugin)
.process(input);
const output = result.toString();

//fs.writeFileSync(path.resolve(__dirname, "./resources/actual.md"), output);

chai.assert.equal(sanitized(output), sanitized(expected));
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/resources/expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Operating System: Windows 10
OS Version: 10.0
Default Encoding: UTF-8
Language: en
Country: US
Country: GB
--></g></svg></div>

## A Different Code Block
Expand Down