Files
RSSHub/test/utils/common-config.js
SettingDust f8990b7cb7 The cherrio config route (#1699)
Use js config too build rss

close #349 close #1035
2019-03-11 10:47:09 +08:00

39 lines
1019 B
JavaScript

const configUtils = require('../../lib/utils/common-config');
describe('index', () => {
it('transElemText', async () => {
const $ = () => 'RSSHub';
expect(configUtils.transElemText($, '$()')).toBe('RSSHub');
});
it('replaceParams', async () => {
const $ = () => 'RSSHub';
const data = {
params: {
title: 'RSSHub',
},
title: '%title%',
};
expect(configUtils.replaceParams(data, data.title, $)).toBe('RSSHub');
});
it('getProp', async () => {
const $ = () => 'RSSHub';
const data = {
title: 'RSSHub',
};
expect(configUtils.getProp(data, ['title'], $)).toBe('RSSHub');
});
it('all', async () => {
const $ = () => 'RSSHub';
const data = {
params: {
title: '$()',
},
title: '%title%',
};
expect(configUtils.getProp(data, ['title'], $)).toBe('RSSHub');
});
});