Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
const utils = require("../index");
import * as utils from "../index";

describe("utils", () => {
describe("createArrowFunction", () => {
Expand All @@ -18,7 +18,7 @@ describe("utils", () => {
});
it("should stringify an array", () => {
expect(
utils.createDynamicPromise(["app.js", "index.js"])
utils.createDynamicPromise(["app.js", "index.js"]),
).toMatchSnapshot();
});
});
Expand Down Expand Up @@ -48,49 +48,49 @@ describe("utils", () => {
describe("Inquirer", () => {
it("should make an List object", () => {
expect(utils.List("entry", "does it work?", ["Yes", "Maybe"])).toEqual({
type: "list",
name: "entry",
choices: ["Yes", "Maybe"],
message: "does it work?",
choices: ["Yes", "Maybe"]
name: "entry",
type: "list",
});
});
it("should make an RawList object", () => {
expect(
utils.RawList("output", "does it work?", ["Yes", "Maybe"])
utils.RawList("output", "does it work?", ["Yes", "Maybe"]),
).toEqual({
type: "rawlist",
name: "output",
choices: ["Yes", "Maybe"],
message: "does it work?",
choices: ["Yes", "Maybe"]
name: "output",
type: "rawlist",
});
});
it("should make an CheckList object", () => {
expect(
utils.CheckList("context", "does it work?", ["Yes", "Maybe"])
utils.CheckList("context", "does it work?", ["Yes", "Maybe"]),
).toEqual({
type: "checkbox",
name: "context",
choices: ["Yes", "Maybe"],
message: "does it work?",
choices: ["Yes", "Maybe"]
name: "context",
type: "checkbox",
});
});
it("should make an Input object", () => {
expect(utils.Input("plugins", "what is your plugin?")).toEqual({
type: "input",
message: "what is your plugin?",
name: "plugins",
message: "what is your plugin?"
type: "input",
});
});
it("should make an Confirm object", () => {
expect(utils.Confirm("context", "what is your context?")).toEqual({
type: "confirm",
message: "what is your context?",
name: "context",
message: "what is your context?"
type: "confirm",
});
});
it("should make an Input object with validation", () => {
expect(
utils.InputValidate("plugins", "what is your plugin?", () => {})
utils.InputValidate("plugins", "what is your plugin?", () => true),
).toMatchSnapshot();
});
});
Expand Down
8 changes: 4 additions & 4 deletions packages/webpack-scaffold/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ export interface IInquirerInput extends IInquirerScaffoldObject {
validate?: (input: string) => string | boolean;
}

export function createArrowFunction(value: Function): string {
export function createArrowFunction(value: string): string {
return `() => '${value}'`;
}

export function createRegularFunction(value: Function): string {
export function createRegularFunction(value: string): string {
return `function () {\n return '${value}'\n}`;
}

export function createDynamicPromise(arrOrString: Function[] | string): string {
export function createDynamicPromise(arrOrString: string[] | string): string {
if (Array.isArray(arrOrString)) {
return (
"() => new Promise((resolve) => resolve([" +
arrOrString.map((func: Function) => {
arrOrString.map((func: string) => {
return "'" + func + "'";
}) +
"]))"
Expand Down