test: Add tests for Identity model
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Identity model > jsonSchema should have correct validations 1`] = `
|
||||
{
|
||||
"properties": {
|
||||
"id": {
|
||||
"format": "uuid",
|
||||
"type": "string",
|
||||
},
|
||||
"providerId": {
|
||||
"format": "uuid",
|
||||
"type": "string",
|
||||
},
|
||||
"providerType": {
|
||||
"enum": [
|
||||
"saml",
|
||||
],
|
||||
"type": "string",
|
||||
},
|
||||
"remoteId": {
|
||||
"minLength": 1,
|
||||
"type": "string",
|
||||
},
|
||||
"userId": {
|
||||
"format": "uuid",
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"providerId",
|
||||
"remoteId",
|
||||
"userId",
|
||||
"providerType",
|
||||
],
|
||||
"type": "object",
|
||||
}
|
||||
`;
|
40
packages/backend/src/models/identity.ee.test.js
Normal file
40
packages/backend/src/models/identity.ee.test.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import Identity from './identity.ee';
|
||||
import User from './user';
|
||||
import SamlAuthProvider from './saml-auth-provider.ee';
|
||||
import Base from './base';
|
||||
|
||||
describe('Identity model', () => {
|
||||
it('tableName should return correct name', () => {
|
||||
expect(Identity.tableName).toBe('identities');
|
||||
});
|
||||
|
||||
it('jsonSchema should have correct validations', () => {
|
||||
expect(Identity.jsonSchema).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('relationMappings should return correct associations', () => {
|
||||
const relationMappings = Identity.relationMappings();
|
||||
|
||||
const expectedRelations = {
|
||||
user: {
|
||||
relation: Base.BelongsToOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
from: 'users.id',
|
||||
to: 'identities.user_id',
|
||||
},
|
||||
},
|
||||
samlAuthProvider: {
|
||||
relation: Base.BelongsToOneRelation,
|
||||
modelClass: SamlAuthProvider,
|
||||
join: {
|
||||
from: 'saml_auth_providers.id',
|
||||
to: 'identities.provider_id',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(relationMappings).toStrictEqual(expectedRelations);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user