The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/apps/tests/server/accessors/SettingsExtend.test.ts

54 lines
1.7 KiB

import * as assert from 'node:assert';
import { describe, it } from 'node:test';
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import { SettingType } from '@rocket.chat/apps-engine/definition/settings';
import type { ProxiedApp } from '../../../src/server/ProxiedApp';
import { SettingsExtend } from '../../../src/server/accessors';
import type { IAppStorageItem } from '../../../src/server/storage';
describe('SettingsExtend', () => {
it('basicSettingsExtend', () => {
assert.doesNotThrow(() => new SettingsExtend({} as ProxiedApp));
});
it('provideSettingToSettingsExtend', async () => {
const mockedStorageItem: IAppStorageItem = {
settings: {},
} as IAppStorageItem;
const mockedApp: ProxiedApp = {
getStorageItem: function _getStorageItem() {
return mockedStorageItem;
},
} as ProxiedApp;
const se = new SettingsExtend(mockedApp);
const setting: ISetting = {
id: 'testing',
type: SettingType.STRING,
packageValue: 'thing',
required: false,
public: false,
i18nLabel: 'Testing_Settings',
};
await assert.doesNotReject(() => se.provideSetting(setting));
assert.ok(Object.keys(mockedStorageItem.settings).length > 0);
const settingModified: ISetting = {
id: 'testing',
type: SettingType.STRING,
packageValue: 'thing',
required: false,
public: false,
i18nLabel: 'Testing_Thing',
value: 'dont-use-me',
};
await assert.doesNotReject(() => se.provideSetting(settingModified));
assert.ok(mockedStorageItem.settings.testing !== undefined);
assert.ok(mockedStorageItem.settings.testing.value === undefined);
assert.strictEqual(mockedStorageItem.settings.testing.i18nLabel, 'Testing_Thing');
});
});