Skip to content

Commit

Permalink
tests(webpack-scaffold): moved to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 authored and dhruvdutt committed Nov 6, 2018
1 parent 5a34a88 commit 122a770
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
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

0 comments on commit 122a770

Please sign in to comment.