refactor: Move and adjust getApp tests for app config model
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
|
|||||||
|
|
||||||
import Base from './base.js';
|
import Base from './base.js';
|
||||||
import AppConfig from './app-config.js';
|
import AppConfig from './app-config.js';
|
||||||
|
import App from './app.js';
|
||||||
import AppAuthClient from './app-auth-client.js';
|
import AppAuthClient from './app-auth-client.js';
|
||||||
import { createAppConfig } from '../../test/factories/app-config.js';
|
import { createAppConfig } from '../../test/factories/app-config.js';
|
||||||
import { createAppAuthClient } from '../../test/factories/app-auth-client.js';
|
import { createAppAuthClient } from '../../test/factories/app-auth-client.js';
|
||||||
@@ -32,6 +33,25 @@ describe('AppConfig model', () => {
|
|||||||
expect(relationMappings).toStrictEqual(expectedRelations);
|
expect(relationMappings).toStrictEqual(expectedRelations);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getApp', () => {
|
||||||
|
it('getApp should return null if there is no key', async () => {
|
||||||
|
const appConfig = new AppConfig();
|
||||||
|
const app = await appConfig.getApp();
|
||||||
|
|
||||||
|
expect(app).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getApp should return app with provided key', async () => {
|
||||||
|
const appConfig = new AppConfig();
|
||||||
|
appConfig.key = 'deepl';
|
||||||
|
|
||||||
|
const app = await appConfig.getApp();
|
||||||
|
const expectedApp = await App.findOneByKey(appConfig.key);
|
||||||
|
|
||||||
|
expect(app).toStrictEqual(expectedApp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('connectionAllowed', () => {
|
describe('connectionAllowed', () => {
|
||||||
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
|
it('should return true when app is enabled, shared and allows custom connection with an active app auth client at least', async () => {
|
||||||
await createAppAuthClient({
|
await createAppAuthClient({
|
||||||
@@ -99,12 +119,4 @@ describe('AppConfig model', () => {
|
|||||||
expect(appConfig.connectionAllowed).toBe(false);
|
expect(appConfig.connectionAllowed).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getApp should return associated application', async () => {
|
|
||||||
const appConfig = await createAppConfig({ key: 'deepl' });
|
|
||||||
|
|
||||||
const app = await appConfig.getApp();
|
|
||||||
|
|
||||||
expect(app.key).toBe('deepl');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user