Skip to content

Commit

Permalink
test: add test case for JsSdkTest-4
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanphamcybozu committed Apr 25, 2024
1 parent 103a58c commit da5f2c1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
63 changes: 59 additions & 4 deletions packages/create-plugin/__e2e__/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import assert from "assert";
import { executeCommandWithInteractiveInput } from "./utils/helper";
import { CREATE_PLUGIN_COMMAND, DEFAULT_ANSWER, NO } from "./utils/constants";
import {
CREATE_PLUGIN_COMMAND,
DEFAULT_ANSWER,
ANSWER_NO,
ANSWER_YES,
} from "./utils/constants";
import path from "path";
import { generateWorkingDir } from "./utils/generateWorkingDir";
import fs from "fs";
Expand All @@ -16,16 +21,16 @@ describe("create-plugin", function () {
workingDir = generateWorkingDir();
});

it("Should able to create a plugin with specified output directory and required options successfully", async () => {
it.skip("Should able to create a plugin with specified output directory and required options successfully", async () => {
const outputDir = "test1";
const ANSWER = [
"test1-name",
"test1-description",
DEFAULT_ANSWER,
DEFAULT_ANSWER,
DEFAULT_ANSWER,
NO,
NO,
ANSWER_NO,
ANSWER_NO,
];
const response = await executeCommandWithInteractiveInput(
CREATE_PLUGIN_COMMAND,
Expand All @@ -47,6 +52,56 @@ describe("create-plugin", function () {
assertObjectIncludes(actualManifestJson, expectedManifestJson);
});

it("Should able to create a plugin with specified output directory and all options successfully", async () => {
const outputDir = "test1";
const ANSWER = [
"test4-name",
"test1-description",
ANSWER_YES,
"私のプラグイン",
"私のプラグイン",
ANSWER_YES,
"我的插件",
"我的插件",
"https://github.com",
"https://github.jp",
"https://github.cn",
ANSWER_YES,
ANSWER_YES,
];
const response = await executeCommandWithInteractiveInput(
CREATE_PLUGIN_COMMAND,
workingDir,
outputDir,
ANSWER,
);

assert(response.status === 0, "Failed to create plugin");

const pluginDir = path.resolve(workingDir, outputDir);
assert.ok(fs.existsSync(pluginDir), "plugin dir is not created.");

const actualManifestJson = readPluginManifestJson(pluginDir);
const expectedManifestJson = {
name: { en: "test4-name" },
description: {
en: "test4-description",
ja: "私のプラグイン",
zh: "我的插件",
},
homepage_url: {
en: "https://github.com",
ja: "https://github.jp",
zh: "https://github.cn",
},
mobile: {
js: ["js/mobile.js"],
css: ["css/mobile.css"],
},
};
assertObjectIncludes(actualManifestJson, expectedManifestJson);
});

afterEach(() => {
rimrafSync(workingDir);
console.log(`Working directory ${workingDir} has been removed`);
Expand Down
4 changes: 2 additions & 2 deletions packages/create-plugin/__e2e__/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const DEFAULT_ANSWER = "";
export const YES = "Yes";
export const NO = "No";
export const ANSWER_YES = "Yes";
export const ANSWER_NO = "No";

export const CREATE_PLUGIN_COMMAND = "create-plugin";

Expand Down

0 comments on commit da5f2c1

Please sign in to comment.