From c6f2a975916546f15c8c07d51fbe4b7005dddd7c Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Thu, 24 Oct 2024 17:04:45 +0200 Subject: [PATCH] test: Add missing associations test for app auth client --- .../backend/src/models/app-auth-client.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/backend/src/models/app-auth-client.test.js b/packages/backend/src/models/app-auth-client.test.js index d9ef9d99..0f5c2764 100644 --- a/packages/backend/src/models/app-auth-client.test.js +++ b/packages/backend/src/models/app-auth-client.test.js @@ -4,6 +4,7 @@ import enc from 'crypto-js/enc-utf8.js'; import AppConfig from './app-config.js'; import AppAuthClient from './app-auth-client.js'; +import Base from './base.js'; import appConfig from '../config/app.js'; import { createAppAuthClient } from '../../test/factories/app-auth-client.js'; import { createAppConfig } from '../../test/factories/app-config.js'; @@ -17,6 +18,23 @@ describe('AppAuthClient model', () => { expect(AppAuthClient.jsonSchema).toMatchSnapshot(); }); + it('relationMappings should return correct associations', () => { + const relationMappings = AppAuthClient.relationMappings(); + + const expectedRelations = { + appConfig: { + relation: Base.BelongsToOneRelation, + modelClass: AppConfig, + join: { + from: 'app_auth_clients.app_key', + to: 'app_configs.key', + }, + }, + }; + + expect(relationMappings).toStrictEqual(expectedRelations); + }); + describe('encryptData', () => { it('should return undefined if eligibleForEncryption is not true', async () => { vi.spyOn(