mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
test: common-config
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable unicorn/consistent-function-scoping */
|
||||
const configUtils = require('../../lib/utils/common-config');
|
||||
const nock = require('nock');
|
||||
import { describe, expect, it } from '@jest/globals';
|
||||
import configUtils, { transElemText, replaceParams, getProp } from '@/utils/common-config';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('index', () => {
|
||||
it('transElemText', () => {
|
||||
const $ = () => 'RSSHub';
|
||||
expect(configUtils.transElemText($, '$()')).toBe('RSSHub');
|
||||
expect(transElemText($, '$()')).toBe('RSSHub');
|
||||
});
|
||||
|
||||
it('replaceParams', () => {
|
||||
@@ -16,7 +16,7 @@ describe('index', () => {
|
||||
},
|
||||
title: '%title%',
|
||||
};
|
||||
expect(configUtils.replaceParams(data, data.title, $)).toBe('RSSHub');
|
||||
expect(replaceParams(data, data.title, $)).toBe('RSSHub');
|
||||
});
|
||||
|
||||
it('getProp', () => {
|
||||
@@ -24,8 +24,8 @@ describe('index', () => {
|
||||
const data = {
|
||||
title: 'RSSHub',
|
||||
};
|
||||
expect(configUtils.getProp(data, ['title'], $)).toBe('RSSHub');
|
||||
expect(configUtils.getProp(data, 'title', $)).toBe('RSSHub');
|
||||
expect(getProp(data, ['title'], $)).toBe('RSSHub');
|
||||
expect(getProp(data, 'title', $)).toBe('RSSHub');
|
||||
});
|
||||
|
||||
it('all', () => {
|
||||
@@ -36,7 +36,7 @@ describe('index', () => {
|
||||
},
|
||||
title: '%title%',
|
||||
};
|
||||
expect(configUtils.getProp(data, ['title'], $)).toBe('RSSHub');
|
||||
expect(getProp(data, ['title'], $)).toBe('RSSHub');
|
||||
});
|
||||
|
||||
it('buildData', async () => {
|
||||
@@ -1,12 +1,6 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const iconv = require('iconv-lite');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const date = require('@/utils/date');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const timezone = require('@/utils/timezone');
|
||||
import cheerio from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import iconv from 'iconv-lite';
|
||||
|
||||
function transElemText($, prop) {
|
||||
const regex = /\$\((.*)\)/g;
|
||||
@@ -76,7 +70,5 @@ async function buildData(data) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = buildData;
|
||||
module.exports.transElemText = transElemText;
|
||||
module.exports.replaceParams = replaceParams;
|
||||
module.exports.getProp = getProp;
|
||||
export default buildData;
|
||||
export { transElemText, replaceParams, getProp };
|
||||
@@ -1,7 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { decodeCFEmail } = require('@/utils/cf-email');
|
||||
const { decodeCFEmail } = require('./cf-email');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
Reference in New Issue
Block a user