forked from sismo-core/app-store
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: compare app in whitelist check (sismo-core#111)
- Loading branch information
1 parent
8f6b7be
commit 62eb3a4
Showing
4 changed files
with
80 additions
and
5 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
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
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
48 changes: 48 additions & 0 deletions
48
src/libs/user-store/memory-user-store/memory-user-store.test.ts
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { MemoryUserStore } from "."; | ||
import { UserStore } from "../store"; | ||
|
||
let userStore: UserStore; | ||
|
||
const user1 = { | ||
appSlug: "appSlug1", | ||
userId: "userId1", | ||
}; | ||
const user2 = { | ||
appSlug: "appSlug2", | ||
userId: "userId2", | ||
}; | ||
const user3 = { | ||
appSlug: "appSlug1", | ||
userId: "userId3" | ||
}; | ||
|
||
describe("MemoryUserStore", () => { | ||
beforeEach(async () => { | ||
userStore = new MemoryUserStore(); | ||
|
||
await userStore.add(user1); | ||
await userStore.add(user2); | ||
await userStore.add(user3); | ||
}); | ||
|
||
it("Should return all users when query is missing", async () => { | ||
const users = await userStore.getUsers(); | ||
expect(users.length).toEqual(3); | ||
expect(users[0]).toEqual(user1); | ||
expect(users[1]).toEqual(user2); | ||
expect(users[2]).toEqual(user3); | ||
}); | ||
|
||
it("Should return all users matching partial query", async () => { | ||
const users = await userStore.getUsers({ appSlug: "appSlug1"}); | ||
expect(users.length).toEqual(2); | ||
expect(users[0]).toEqual(user1); | ||
expect(users[1]).toEqual(user3); | ||
}); | ||
|
||
it("Should return users matching full query", async () => { | ||
const users = await userStore.getUsers({ appSlug: "appSlug1", userId: "userId1"}); | ||
expect(users.length).toEqual(1); | ||
expect(users[0]).toEqual(user1); | ||
}); | ||
}); |