feat: add missing crud to provider identity service (#8717)
This commit is contained in:
+67
@@ -335,6 +335,73 @@ moduleIntegrationTestRunner<IAuthModuleService>({
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("deleteProviderIdentity", () => {
|
||||
const entity_id = "provider-test-id"
|
||||
|
||||
it("should delete the providerIdentities given an id successfully", async () => {
|
||||
let providerIdentities = await service.listProviderIdentities({
|
||||
entity_id,
|
||||
})
|
||||
|
||||
expect(providerIdentities).toHaveLength(1)
|
||||
const providerIdentityId = providerIdentities[0].id
|
||||
|
||||
await service.deleteProviderIdentities([providerIdentityId])
|
||||
|
||||
providerIdentities = await service.listProviderIdentities({
|
||||
entity_id,
|
||||
})
|
||||
|
||||
expect(providerIdentities).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("updateProviderIdentity", () => {
|
||||
const entity_id = "provider-test-id"
|
||||
|
||||
it("should throw an error when a id does not exist", async () => {
|
||||
let error
|
||||
|
||||
try {
|
||||
await service.updateProviderIdentites([
|
||||
{
|
||||
id: "does-not-exist",
|
||||
},
|
||||
])
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error.message).toEqual(
|
||||
'ProviderIdentity with id "does-not-exist" not found'
|
||||
)
|
||||
})
|
||||
|
||||
it("should update providerIdentity", async () => {
|
||||
let [providerIdentity] = await service.listProviderIdentities({
|
||||
entity_id,
|
||||
})
|
||||
await service.updateProviderIdentites([
|
||||
{
|
||||
id: providerIdentity.id,
|
||||
provider_metadata: { email: "test@email.com" },
|
||||
},
|
||||
])
|
||||
|
||||
const providerIdentites = await service.listProviderIdentities({
|
||||
id: [providerIdentity.id],
|
||||
})
|
||||
|
||||
expect(providerIdentites[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
provider_metadata: expect.objectContaining({
|
||||
email: "test@email.com",
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user