ui-thing 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +273 -239
- package/dist/index.js +4747 -4711
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/commands/add.ts +293 -286
- package/src/commands/shortcuts.ts +42 -42
- package/src/comps.ts +2316 -2462
- package/src/templates/shortcuts.ts +217 -217
- package/src/types.ts +3 -3
- package/src/utils/fetchComponents.ts +8 -8
- package/src/utils/installPackages.ts +28 -1
- package/src/utils/promptForComponents.ts +19 -19
- package/src/utils/uiConfigPrompt.ts +73 -73
- package/tests/templates/css.test.ts +34 -34
- package/tests/utils/addPrettierConfig.test.ts +71 -71
- package/tests/utils/compareUIConfig.test.ts +60 -60
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import kleur from "kleur";
|
|
2
|
-
import prompts from "prompts";
|
|
3
|
-
|
|
4
|
-
import { CSS_THEME_OPTIONS } from "./constants";
|
|
5
|
-
|
|
6
|
-
export const initPrompts = async () => {
|
|
7
|
-
const response = await prompts([
|
|
8
|
-
{
|
|
9
|
-
name: "theme",
|
|
10
|
-
type: "autocomplete",
|
|
11
|
-
message: "Which theme do you want to start with?",
|
|
12
|
-
choices: CSS_THEME_OPTIONS,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: "tailwindCSSLocation",
|
|
16
|
-
type: "text",
|
|
17
|
-
message: "Where is your tailwind.css file located?",
|
|
18
|
-
initial: "assets/css/tailwind.css",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "tailwindConfigLocation",
|
|
22
|
-
type: "text",
|
|
23
|
-
message: "Where is your tailwind.config file located?",
|
|
24
|
-
initial: "tailwind.config.js",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "componentsLocation",
|
|
28
|
-
type: "text",
|
|
29
|
-
message: "Where should your components be stored?",
|
|
30
|
-
initial: "components/Ui",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "composablesLocation",
|
|
34
|
-
type: "text",
|
|
35
|
-
message: "Where should your composables be stored?",
|
|
36
|
-
initial: "composables",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "utilsLocation",
|
|
40
|
-
type: "text",
|
|
41
|
-
message: "Where should your utils be stored?",
|
|
42
|
-
initial: "utils",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "force",
|
|
46
|
-
type: "confirm",
|
|
47
|
-
message: "Should we just replace component files if they already exist?",
|
|
48
|
-
initial: true,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "useDefaultFilename",
|
|
52
|
-
type: "confirm",
|
|
53
|
-
message: "Would you like to use the default filename when adding components?",
|
|
54
|
-
initial: true,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "packageManager",
|
|
58
|
-
type: "select",
|
|
59
|
-
message: "Which package manager do you use?",
|
|
60
|
-
choices: [
|
|
61
|
-
{ title: "NPM", value: "npm" },
|
|
62
|
-
{ title: "Yarn", value: "yarn" },
|
|
63
|
-
{ title: "PNPM", value: "pnpm" },
|
|
64
|
-
{ title: "Bun", value: "bun" },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
]);
|
|
68
|
-
if (!response || Object.keys(response).length < 9) {
|
|
69
|
-
console.log(kleur.red("Incomplete configuration submitted. Exiting..."));
|
|
70
|
-
return process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
return response;
|
|
73
|
-
};
|
|
1
|
+
import kleur from "kleur";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
|
|
4
|
+
import { CSS_THEME_OPTIONS } from "./constants";
|
|
5
|
+
|
|
6
|
+
export const initPrompts = async () => {
|
|
7
|
+
const response = await prompts([
|
|
8
|
+
{
|
|
9
|
+
name: "theme",
|
|
10
|
+
type: "autocomplete",
|
|
11
|
+
message: "Which theme do you want to start with?",
|
|
12
|
+
choices: CSS_THEME_OPTIONS,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "tailwindCSSLocation",
|
|
16
|
+
type: "text",
|
|
17
|
+
message: "Where is your tailwind.css file located?",
|
|
18
|
+
initial: "assets/css/tailwind.css",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "tailwindConfigLocation",
|
|
22
|
+
type: "text",
|
|
23
|
+
message: "Where is your tailwind.config file located?",
|
|
24
|
+
initial: "tailwind.config.js",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "componentsLocation",
|
|
28
|
+
type: "text",
|
|
29
|
+
message: "Where should your components be stored?",
|
|
30
|
+
initial: "components/Ui",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "composablesLocation",
|
|
34
|
+
type: "text",
|
|
35
|
+
message: "Where should your composables be stored?",
|
|
36
|
+
initial: "composables",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "utilsLocation",
|
|
40
|
+
type: "text",
|
|
41
|
+
message: "Where should your utils be stored?",
|
|
42
|
+
initial: "utils",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "force",
|
|
46
|
+
type: "confirm",
|
|
47
|
+
message: "Should we just replace component files if they already exist?",
|
|
48
|
+
initial: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "useDefaultFilename",
|
|
52
|
+
type: "confirm",
|
|
53
|
+
message: "Would you like to use the default filename when adding components?",
|
|
54
|
+
initial: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "packageManager",
|
|
58
|
+
type: "select",
|
|
59
|
+
message: "Which package manager do you use?",
|
|
60
|
+
choices: [
|
|
61
|
+
{ title: "NPM", value: "npm" },
|
|
62
|
+
{ title: "Yarn", value: "yarn" },
|
|
63
|
+
{ title: "PNPM", value: "pnpm" },
|
|
64
|
+
{ title: "Bun", value: "bun" },
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
]);
|
|
68
|
+
if (!response || Object.keys(response).length < 9) {
|
|
69
|
+
console.log(kleur.red("Incomplete configuration submitted. Exiting..."));
|
|
70
|
+
return process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
return response;
|
|
73
|
+
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
import * as testingFn from "../../src/templates/css";
|
|
4
|
-
|
|
5
|
-
describe("templates/css", () => {
|
|
6
|
-
afterEach(() => {
|
|
7
|
-
vi.restoreAllMocks();
|
|
8
|
-
vi.resetAllMocks();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("should return ZINC theme if an invalid theme is passed", async () => {
|
|
12
|
-
// create spies
|
|
13
|
-
vi.spyOn(testingFn, "createCSS");
|
|
14
|
-
|
|
15
|
-
// call function
|
|
16
|
-
const result = testingFn.createCSS("BAD_THEME" as any);
|
|
17
|
-
|
|
18
|
-
// assertions
|
|
19
|
-
expect(result).toContain(testingFn.ZINC_THEME);
|
|
20
|
-
expect(testingFn.createCSS).toHaveBeenCalledTimes(1);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should returned the expected theme", async () => {
|
|
24
|
-
// create spies
|
|
25
|
-
vi.spyOn(testingFn, "createCSS");
|
|
26
|
-
|
|
27
|
-
// call function
|
|
28
|
-
const result = testingFn.createCSS("BLUE");
|
|
29
|
-
|
|
30
|
-
// assertions
|
|
31
|
-
expect(result).toContain(testingFn.BLUE_THEME);
|
|
32
|
-
expect(testingFn.createCSS).toHaveBeenCalledTimes(1);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import * as testingFn from "../../src/templates/css";
|
|
4
|
+
|
|
5
|
+
describe("templates/css", () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
vi.restoreAllMocks();
|
|
8
|
+
vi.resetAllMocks();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should return ZINC theme if an invalid theme is passed", async () => {
|
|
12
|
+
// create spies
|
|
13
|
+
vi.spyOn(testingFn, "createCSS");
|
|
14
|
+
|
|
15
|
+
// call function
|
|
16
|
+
const result = testingFn.createCSS("BAD_THEME" as any);
|
|
17
|
+
|
|
18
|
+
// assertions
|
|
19
|
+
expect(result).toContain(testingFn.ZINC_THEME);
|
|
20
|
+
expect(testingFn.createCSS).toHaveBeenCalledTimes(1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should returned the expected theme", async () => {
|
|
24
|
+
// create spies
|
|
25
|
+
vi.spyOn(testingFn, "createCSS");
|
|
26
|
+
|
|
27
|
+
// call function
|
|
28
|
+
const result = testingFn.createCSS("BLUE");
|
|
29
|
+
|
|
30
|
+
// assertions
|
|
31
|
+
expect(result).toContain(testingFn.BLUE_THEME);
|
|
32
|
+
expect(testingFn.createCSS).toHaveBeenCalledTimes(1);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import * as execa from "execa";
|
|
2
|
-
import fse from "fs-extra";
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
import type { PathLike } from "fs";
|
|
5
|
-
|
|
6
|
-
import * as testingFn from "../../src/utils/addPrettierConfig";
|
|
7
|
-
|
|
8
|
-
const currentDir = process.cwd();
|
|
9
|
-
|
|
10
|
-
describe("utils/addPrettierConfig", () => {
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
vi.restoreAllMocks();
|
|
13
|
-
vi.resetAllMocks();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should ask the user if they want to overwrite the existing prettier config file if one exists", async () => {
|
|
17
|
-
vi.spyOn(fse, "existsSync").mockImplementation((path: PathLike) => true);
|
|
18
|
-
vi.mock("prompts", async () => {
|
|
19
|
-
const prompts = await vi.importActual<typeof import("prompts")>("prompts");
|
|
20
|
-
return {
|
|
21
|
-
...prompts,
|
|
22
|
-
default: async () => {
|
|
23
|
-
return { overwrite: false };
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
const prompts = await import("prompts");
|
|
28
|
-
vi.spyOn(prompts, "default");
|
|
29
|
-
|
|
30
|
-
const result = await testingFn.addPrettierConfig();
|
|
31
|
-
expect(result).toBe(false);
|
|
32
|
-
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
33
|
-
expect(prompts.default).toHaveBeenCalledTimes(1);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("should create config file if one does not exist", async () => {
|
|
37
|
-
vi.spyOn(fse, "existsSync").mockImplementation(() => false);
|
|
38
|
-
vi.spyOn(fse, "writeFile").mockResolvedValue();
|
|
39
|
-
|
|
40
|
-
const result = await testingFn.addPrettierConfig(currentDir, false);
|
|
41
|
-
expect(result).toBe(true);
|
|
42
|
-
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
43
|
-
expect(fse.writeFile).toHaveBeenCalledTimes(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should format files with prettier if format is true", async () => {
|
|
47
|
-
vi.spyOn(testingFn, "addPrettierConfig");
|
|
48
|
-
vi.spyOn(fse, "existsSync").mockImplementation(() => false);
|
|
49
|
-
vi.spyOn(fse, "writeFile").mockResolvedValue();
|
|
50
|
-
vi.mock("execa", async () => {
|
|
51
|
-
const execa = await vi.importActual<typeof import("execa")>("execa");
|
|
52
|
-
return {
|
|
53
|
-
...execa,
|
|
54
|
-
$: async () => {
|
|
55
|
-
return true;
|
|
56
|
-
},
|
|
57
|
-
default: async () => {
|
|
58
|
-
return true;
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
vi.spyOn(execa, "$");
|
|
63
|
-
|
|
64
|
-
const result = await testingFn.addPrettierConfig(currentDir, true);
|
|
65
|
-
expect(result).toBe(true);
|
|
66
|
-
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
67
|
-
expect(fse.writeFile).toHaveBeenCalledTimes(1);
|
|
68
|
-
expect(execa.$).toHaveBeenCalledTimes(1);
|
|
69
|
-
expect(testingFn.addPrettierConfig).toHaveBeenCalledTimes(1);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
import * as execa from "execa";
|
|
2
|
+
import fse from "fs-extra";
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import type { PathLike } from "fs";
|
|
5
|
+
|
|
6
|
+
import * as testingFn from "../../src/utils/addPrettierConfig";
|
|
7
|
+
|
|
8
|
+
const currentDir = process.cwd();
|
|
9
|
+
|
|
10
|
+
describe("utils/addPrettierConfig", () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
vi.restoreAllMocks();
|
|
13
|
+
vi.resetAllMocks();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should ask the user if they want to overwrite the existing prettier config file if one exists", async () => {
|
|
17
|
+
vi.spyOn(fse, "existsSync").mockImplementation((path: PathLike) => true);
|
|
18
|
+
vi.mock("prompts", async () => {
|
|
19
|
+
const prompts = await vi.importActual<typeof import("prompts")>("prompts");
|
|
20
|
+
return {
|
|
21
|
+
...prompts,
|
|
22
|
+
default: async () => {
|
|
23
|
+
return { overwrite: false };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
const prompts = await import("prompts");
|
|
28
|
+
vi.spyOn(prompts, "default");
|
|
29
|
+
|
|
30
|
+
const result = await testingFn.addPrettierConfig();
|
|
31
|
+
expect(result).toBe(false);
|
|
32
|
+
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
33
|
+
expect(prompts.default).toHaveBeenCalledTimes(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should create config file if one does not exist", async () => {
|
|
37
|
+
vi.spyOn(fse, "existsSync").mockImplementation(() => false);
|
|
38
|
+
vi.spyOn(fse, "writeFile").mockResolvedValue();
|
|
39
|
+
|
|
40
|
+
const result = await testingFn.addPrettierConfig(currentDir, false);
|
|
41
|
+
expect(result).toBe(true);
|
|
42
|
+
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(fse.writeFile).toHaveBeenCalledTimes(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should format files with prettier if format is true", async () => {
|
|
47
|
+
vi.spyOn(testingFn, "addPrettierConfig");
|
|
48
|
+
vi.spyOn(fse, "existsSync").mockImplementation(() => false);
|
|
49
|
+
vi.spyOn(fse, "writeFile").mockResolvedValue();
|
|
50
|
+
vi.mock("execa", async () => {
|
|
51
|
+
const execa = await vi.importActual<typeof import("execa")>("execa");
|
|
52
|
+
return {
|
|
53
|
+
...execa,
|
|
54
|
+
$: async () => {
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
default: async () => {
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
vi.spyOn(execa, "$");
|
|
63
|
+
|
|
64
|
+
const result = await testingFn.addPrettierConfig(currentDir, true);
|
|
65
|
+
expect(result).toBe(true);
|
|
66
|
+
expect(fse.existsSync).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(fse.writeFile).toHaveBeenCalledTimes(1);
|
|
68
|
+
expect(execa.$).toHaveBeenCalledTimes(1);
|
|
69
|
+
expect(testingFn.addPrettierConfig).toHaveBeenCalledTimes(1);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { UIConfig } from "../../src/types";
|
|
4
|
-
import * as testingFn from "../../src/utils/compareUIConfig";
|
|
5
|
-
import * as configModule from "../../src/utils/config";
|
|
6
|
-
|
|
7
|
-
const goodConfig: UIConfig = {
|
|
8
|
-
theme: "string",
|
|
9
|
-
tailwindCSSLocation: "string",
|
|
10
|
-
tailwindConfigLocation: "string",
|
|
11
|
-
componentsLocation: "string",
|
|
12
|
-
composablesLocation: "string",
|
|
13
|
-
utilsLocation: "string",
|
|
14
|
-
force: true,
|
|
15
|
-
useDefaultFilename: true,
|
|
16
|
-
packageManager: "string",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const badConfig = {
|
|
20
|
-
theme: "string",
|
|
21
|
-
tailwindCSSLocation: "string",
|
|
22
|
-
tailwindConfigLocation: "string",
|
|
23
|
-
utilsLocation: "string",
|
|
24
|
-
force: true,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe("utils/compareUIConfig", () => {
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
vi.restoreAllMocks();
|
|
30
|
-
vi.resetAllMocks();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should return false if properties are missing", async () => {
|
|
34
|
-
// create spies
|
|
35
|
-
vi.spyOn(configModule, "getUIConfig").mockResolvedValue(badConfig as UIConfig);
|
|
36
|
-
vi.spyOn(testingFn, "compareUIConfig");
|
|
37
|
-
|
|
38
|
-
// call the function we are testing
|
|
39
|
-
const configValue = await testingFn.compareUIConfig();
|
|
40
|
-
|
|
41
|
-
// assertions
|
|
42
|
-
expect(configValue).toBe(false);
|
|
43
|
-
expect(testingFn.compareUIConfig).toHaveBeenCalledTimes(1);
|
|
44
|
-
expect(configModule.getUIConfig).toHaveBeenCalledTimes(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should return true if all properties are present", async () => {
|
|
48
|
-
// create spies
|
|
49
|
-
vi.spyOn(configModule, "getUIConfig").mockResolvedValue(goodConfig);
|
|
50
|
-
vi.spyOn(testingFn, "compareUIConfig");
|
|
51
|
-
|
|
52
|
-
// call the function we are testing
|
|
53
|
-
const configValue = await testingFn.compareUIConfig();
|
|
54
|
-
|
|
55
|
-
// assertions
|
|
56
|
-
expect(configValue).toBe(true);
|
|
57
|
-
expect(testingFn.compareUIConfig).toHaveBeenCalledTimes(1);
|
|
58
|
-
expect(configModule.getUIConfig).toHaveBeenCalledTimes(1);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { UIConfig } from "../../src/types";
|
|
4
|
+
import * as testingFn from "../../src/utils/compareUIConfig";
|
|
5
|
+
import * as configModule from "../../src/utils/config";
|
|
6
|
+
|
|
7
|
+
const goodConfig: UIConfig = {
|
|
8
|
+
theme: "string",
|
|
9
|
+
tailwindCSSLocation: "string",
|
|
10
|
+
tailwindConfigLocation: "string",
|
|
11
|
+
componentsLocation: "string",
|
|
12
|
+
composablesLocation: "string",
|
|
13
|
+
utilsLocation: "string",
|
|
14
|
+
force: true,
|
|
15
|
+
useDefaultFilename: true,
|
|
16
|
+
packageManager: "string",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const badConfig = {
|
|
20
|
+
theme: "string",
|
|
21
|
+
tailwindCSSLocation: "string",
|
|
22
|
+
tailwindConfigLocation: "string",
|
|
23
|
+
utilsLocation: "string",
|
|
24
|
+
force: true,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe("utils/compareUIConfig", () => {
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
vi.restoreAllMocks();
|
|
30
|
+
vi.resetAllMocks();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return false if properties are missing", async () => {
|
|
34
|
+
// create spies
|
|
35
|
+
vi.spyOn(configModule, "getUIConfig").mockResolvedValue(badConfig as UIConfig);
|
|
36
|
+
vi.spyOn(testingFn, "compareUIConfig");
|
|
37
|
+
|
|
38
|
+
// call the function we are testing
|
|
39
|
+
const configValue = await testingFn.compareUIConfig();
|
|
40
|
+
|
|
41
|
+
// assertions
|
|
42
|
+
expect(configValue).toBe(false);
|
|
43
|
+
expect(testingFn.compareUIConfig).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(configModule.getUIConfig).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should return true if all properties are present", async () => {
|
|
48
|
+
// create spies
|
|
49
|
+
vi.spyOn(configModule, "getUIConfig").mockResolvedValue(goodConfig);
|
|
50
|
+
vi.spyOn(testingFn, "compareUIConfig");
|
|
51
|
+
|
|
52
|
+
// call the function we are testing
|
|
53
|
+
const configValue = await testingFn.compareUIConfig();
|
|
54
|
+
|
|
55
|
+
// assertions
|
|
56
|
+
expect(configValue).toBe(true);
|
|
57
|
+
expect(testingFn.compareUIConfig).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(configModule.getUIConfig).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
});
|