Ghost/apps/admin-x-settings/test/unit/api/customThemeSettings.ts
Michael Barrett 043c9bb35d
Port custom theme setting visibility to admin-x (#18367)
refs https://github.com/TryGhost/Product/issues/3962

Port custom theme setting visibility to admin-x based on previous
implementation in the Ghost admin:
https://github.com/TryGhost/Ghost/pull/17920
2023-10-02 15:54:14 +01:00

29 lines
1.0 KiB
TypeScript

import * as assert from 'assert/strict';
import {CustomThemeSetting, isCustomThemeSettingVisible} from '../../../src/api/customThemeSettings';
describe('isCustomThemeSettingVisible', function () {
it('returns whether or not a custom theme setting is visible', function () {
const settings: CustomThemeSetting[] = [
{
id: 'abc123',
key: 'foo',
type: 'boolean',
value: false,
default: true
},
{
id: 'def456',
key: 'bar',
type: 'text',
value: 'qux',
default: 'qux',
visibility: 'foo:true'
}
];
const settingsKeyValueObj = settings.reduce((obj, {key, value}) => ({...obj, [key]: value}), {});
assert.equal(isCustomThemeSettingVisible(settings[0], settingsKeyValueObj), true);
assert.equal(isCustomThemeSettingVisible(settings[1], settingsKeyValueObj), false);
});
});