-
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(organization): retrict user field select query (#502)
- Loading branch information
1 parent
7b80019
commit 4f9d81a
Showing
2 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
packages/~/users/repository/src/get_users_by_organization_id.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,62 @@ | ||
// | ||
|
||
import { | ||
create_pink_diamond_user, | ||
create_red_diamond_user, | ||
create_unicorn_organization, | ||
} from "@~/moncomptepro.database/seed/unicorn"; | ||
import { | ||
add_user_to_organization, | ||
empty_database, | ||
migrate, | ||
pg, | ||
} from "@~/moncomptepro.database/testing"; | ||
import { beforeAll, beforeEach, expect, test } from "bun:test"; | ||
import { get_users_by_organization_id } from "./get_users_by_organization_id"; | ||
|
||
// | ||
|
||
beforeAll(migrate); | ||
beforeEach(empty_database); | ||
|
||
test("returns pink diamond", async () => { | ||
const unicorn_organization_id = await create_unicorn_organization(pg); | ||
const pink_diamond_user_id = await create_pink_diamond_user(pg); | ||
await add_user_to_organization({ | ||
organization_id: unicorn_organization_id, | ||
user_id: pink_diamond_user_id, | ||
}); | ||
const red_diamond_user_id = await create_red_diamond_user(pg); | ||
await add_user_to_organization({ | ||
organization_id: unicorn_organization_id, | ||
user_id: red_diamond_user_id, | ||
}); | ||
|
||
const emails = await get_users_by_organization_id(pg, { | ||
organization_id: unicorn_organization_id, | ||
}); | ||
|
||
expect(emails).toEqual({ | ||
count: 2, | ||
users: [ | ||
{ | ||
email: "[email protected]", | ||
family_name: "Diamond", | ||
given_name: "Red", | ||
id: red_diamond_user_id, | ||
job: null, | ||
verification_type: null, | ||
is_external: false, | ||
}, | ||
{ | ||
email: "[email protected]", | ||
family_name: "Diamond", | ||
given_name: "Pink", | ||
id: pink_diamond_user_id, | ||
job: null, | ||
verification_type: null, | ||
is_external: false, | ||
}, | ||
], | ||
}); | ||
}); |
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