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: Add tests to action workflows #5

Merged
merged 5 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
delete command tests
  • Loading branch information
omdxp committed May 12, 2022
commit 018a21cbbc9d31c6e782873131b411a861baa8db
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
verbose: true,
setupFilesAfterEnv: ["<rootDir>/tests/setup.js"],
setupFilesAfterEnv: ["./tests/setup.js"],
};
124 changes: 122 additions & 2 deletions tests/delete.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,125 @@
const {
deleteComponents,
deleteScreens,
deleteReduxStore,
} = require("../bin/delete");

const {
createComponent,
createScreen,
createReduxStore,
} = require("../bin/create");

const { fail, sleep, clear } = require("./utils");

const fs = require("file-system");

const { sleep, fail, clear } = require("./utils");
describe("delete component tests", () => {
beforeEach(() => {
clear();
});
afterEach(() => {
clear();
});
console.log = jest.fn();
test("should delete component", async () => {
try {
deleteComponents(["del-test"], "");
await sleep(100);
createComponent("del-test", false, true, "", "", false);
await sleep(100);
deleteComponents(["del-test"], "");
await sleep(100);
expect(fs.existsSync("./src/components/del-test/index.tsx")).toBe(false);
expect(fs.existsSync("./src/components/del-test/styles.ts")).toBe(false);
} catch (err) {
fail(err);
}
});

test("should not delete not existed component", async () => {
try {
deleteComponents(["del-test"], "");
await sleep(100);
expect(console.log).lastCalledWith(
"src/components/del-test/ does not exist"
);
} catch (err) {
fail(err);
}
});
});

describe("delete screen tests", () => {
beforeEach(() => {
clear();
});
afterEach(() => {
clear();
});
console.log = jest.fn();

test("should delete screen", async () => {
try {
deleteScreens(["del-test"], "");
await sleep(100);
createScreen("del-test", false, true, "", "", false);
await sleep(100);
deleteScreens(["del-test"], "");
await sleep(100);
expect(fs.existsSync("./src/screens/del-test/index.tsx")).toBe(false);
expect(fs.existsSync("./src/screens/del-test/styles.ts")).toBe(false);
expect(fs.existsSync("./src/screens/del-test/functions/index.ts")).toBe(
false
);
} catch (err) {
fail(err);
}
});

test("should not delete not existed screen", async () => {
try {
deleteScreens(["del-test"], "");
await sleep(100);
deleteScreens(["del-test"], "");
await sleep(100);
expect(console.log).lastCalledWith("src/screens/del-test does not exist");
} catch (err) {
fail(err);
}
});
});

describe("delete redux tests", () => {
beforeEach(() => {
clear();
});
afterEach(() => {
clear();
});
console.log = jest.fn();
test("should delete redux", async () => {
try {
deleteReduxStore();
await sleep(100);
createReduxStore(false, true);
await sleep(100);
deleteReduxStore();
await sleep(100);
expect(fs.existsSync("src/redux/")).toBe(false);
} catch (err) {
fail(err);
}
});

describe("delete commands test", () => {});
test("should not delete not existed redux", async () => {
try {
deleteReduxStore();
await sleep(100);
expect(fs.existsSync("src/redux/")).toBe(false);
expect(console.log).lastCalledWith("src/redux/ does not exist");
} catch (err) {
fail(err);
}
});
});