Skip to content

Commit 9f2fbaa

Browse files
committed
refactor: rename folder to test
1 parent a07b044 commit 9f2fbaa

File tree

9 files changed

+13
-21
lines changed

9 files changed

+13
-21
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/gist.test.js renamed to test/gist.test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,25 @@ const errorGist = {
3737
errors: []
3838
};
3939

40-
vi.mock("ofetch", async (importOriginal) => {
41-
const mod = await importOriginal();
42-
return {
43-
...mod,
44-
$fetch: vi.fn()
45-
};
46-
});
40+
vi.mock("ofetch", () => ({
41+
$fetch: vi.fn()
42+
}));
4743

4844
describe("getGist", () => {
4945
it("gist id - should return gist", async () => {
50-
vi.mocked($fetch).mockResolvedValue(fakeGist);
46+
vi.mocked($fetch).mockResolvedValueOnce(fakeGist);
5147
const gist = await getGist("cbe7cef5572e6b832da0e9bd3454b312");
5248
expect(gist.data.viewer.gist.files[0].language.name).toEqual("JSON");
5349
});
5450

5551
it("undefined - should go on error and return null gist object", async () => {
56-
vi.mocked($fetch).mockResolvedValue(errorGist);
52+
vi.mocked($fetch).mockResolvedValueOnce(errorGist);
5753
const gists = await getGist();
5854
expect(gists.data.viewer.gist).toBeNull();
5955
});
6056

6157
it("gist doesn't exist - should return empty object", async () => {
62-
vi.mocked($fetch).mockResolvedValue(fakeNULL);
58+
vi.mocked($fetch).mockResolvedValueOnce(fakeNULL);
6359
const gists = await getGist("_");
6460
expect(gists.data.viewer.gist).toBeNull();
6561
});

tests/gistsList.test.js renamed to test/gistsList.test.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, vi } from "vitest";
2-
import { getGists } from "./../src/gistsList.js";
2+
import { getGists } from "../src/gistsList.js";
33
import { $fetch } from "ofetch";
44

55
const fakeGists = [
@@ -29,17 +29,13 @@ const fakeGists = [
2929
}
3030
];
3131

32-
vi.mock("ofetch", async (importOriginal) => {
33-
const mod = await importOriginal();
34-
return {
35-
...mod,
36-
$fetch: vi.fn()
37-
};
38-
});
32+
vi.mock("ofetch", () => ({
33+
$fetch: vi.fn()
34+
}));
3935

4036
describe("getGists", () => {
4137
it("yizack - should return gists", async () => {
42-
vi.mocked($fetch).mockResolvedValue(fakeGists);
38+
vi.mocked($fetch).mockResolvedValueOnce(fakeGists);
4339
const gists = await getGists("yizack");
4440
expect(gists).toEqual(fakeGists);
4541
expect(gists[0].files["reduce_dataset.js"].language).toEqual("JavaScript");
@@ -48,13 +44,13 @@ describe("getGists", () => {
4844
});
4945

5046
it("undefined - should return empty data array", async () => {
51-
vi.mocked($fetch).mockResolvedValue([]);
47+
vi.mocked($fetch).mockResolvedValueOnce([]);
5248
const gists = await getGists();
5349
expect(gists).toEqual([]);
5450
});
5551

5652
it("user doesn't exist - should return empty array", async () => {
57-
vi.mocked($fetch).mockResolvedValue([]);
53+
vi.mocked($fetch).mockResolvedValueOnce([]);
5854
const gists = await getGists("_");
5955
expect(gists).toEqual([]);
6056
});
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)