043c9bb35d
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
29 lines
1.0 KiB
TypeScript
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);
|
|
});
|
|
});
|