This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ndr-brt/fix/fix-utils-tests
fix(test): fix utils.js tests
- Loading branch information
Showing
2 changed files
with
27 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
jest.mock('../storage.js'); | ||
const getBanList = require('../storage.js').getBanList; | ||
|
||
const utils = require("../utils"); | ||
|
||
describe("isPackageNameBanned Tests", () => { | ||
// Now since the editor is started in development mode for testing, we know | ||
// banned package lists will fallback to a static list here. | ||
|
||
test("Returns true correctly for banned item", async () => { | ||
let name = "situs-slot-gacor"; | ||
getBanList.mockResolvedValue({ ok: true, content: ['banned-item'] }); | ||
let name = "banned-item"; | ||
|
||
let isBanned = await utils.isPackageNameBanned(name); | ||
expect(isBanned).toBeTruthy(); | ||
|
||
expect(isBanned.ok).toBeTruthy(); | ||
}); | ||
|
||
test("Returns false correctly for non-banned item", async () => { | ||
let name = "innocent-name"; | ||
getBanList.mockResolvedValue({ ok: true, content: ['banned-item'] }); | ||
let name = "not-banned-item"; | ||
|
||
let isBanned = await utils.isPackageNameBanned(name); | ||
expect(isBanned).toBeFalsy(); | ||
|
||
expect(isBanned.ok).toBeFalsy(); | ||
}); | ||
|
||
test("Returns true if no banned list can be retrieved", async () => { | ||
getBanList.mockResolvedValue({ ok: false }); | ||
|
||
let isBanned = await utils.isPackageNameBanned('any'); | ||
|
||
expect(isBanned.ok).toBeTruthy(); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters