Skip to content

Commit

Permalink
fix: axios stub url
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Oct 27, 2019
1 parent e542610 commit 67c9a99
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test('assign local port', async t => {
t.truthy(conf2.Proxy['测试 2'].includes('local-port = 4001'));
});

test('custom filter', async t => {
test.only('custom filter', async t => {
const { code } = await coffee.fork(cli, ['generate'], {
cwd: resolve('custom-filter'),
execArgv: ['--require', require.resolve('./stub-axios.js')],
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/assign-local-port/provider/ssr.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = {
url: '/test-ssr-sub.txt',
url: 'http://example.com/test-ssr-sub.txt',
type: 'shadowsocksr_subscribe',
startPort: 5000,
};
2 changes: 1 addition & 1 deletion test/fixture/assign-local-port/provider/v2rayn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = {
url: '/test-v2rayn-sub.txt',
url: 'http://example.com/test-v2rayn-sub.txt',
type: 'v2rayn_subscribe',
startPort: 4000,
};
2 changes: 1 addition & 1 deletion test/fixture/custom-filter/provider/ss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { utils } = require('../../../../');

module.exports = {
url: '/test-ss-sub.txt',
url: 'http://example.com/test-ss-sub.txt',
type: 'shadowsocks_subscribe',
customFilters: {
keywordFilter: utils.useKeywords(['US 1', 'US 2']),
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/not-specify-binPath/provider/ssr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/test-ssr-sub.txt',
url: 'http://example.com/test-ssr-sub.txt',
type: 'shadowsocksr_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/plain/provider/ss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/test-ss-sub.txt',
url: 'http://example.com/test-ss-sub.txt',
type: 'shadowsocks_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/plain/provider/ss_json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/gui-config.json',
url: 'http://example.com/gui-config.json',
type: 'shadowsocks_json_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/plain/provider/ssr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/test-ssr-sub.txt',
url: 'http://example.com/test-ssr-sub.txt',
type: 'shadowsocksr_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/plain/provider/v2rayn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/test-v2rayn-sub.txt',
url: 'http://example.com/test-v2rayn-sub.txt',
type: 'v2rayn_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/template-error/provider/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/gui-config.json',
url: 'http://example.com/gui-config.json',
type: 'shadowsocks_json_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/template-variables-functions/provider/ss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = {
url: '/test-ss-sub.txt',
url: 'http://example.com/test-ss-sub.txt',
type: 'shadowsocks_subscribe',
};
2 changes: 1 addition & 1 deletion test/fixture/template-variables-functions/surgio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
remoteSnippets: [
{
name: 'netflix',
url: '/netflix.list'
url: 'http://example.com/netflix.list'
}
],
urlBase: 'https://example.com/',
Expand Down
10 changes: 5 additions & 5 deletions test/stub-axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ const path = require('path');

moxios.install();

moxios.stubRequest('/gui-config.json', {
moxios.stubRequest('http://example.com/gui-config.json', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, 'asset/gui-config-1.json'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/test-ss-sub.txt', {
moxios.stubRequest('http://example.com/test-ss-sub.txt', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, 'asset/test-ss-sub.txt'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/test-ssr-sub.txt', {
moxios.stubRequest('http://example.com/test-ssr-sub.txt', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, 'asset/test-ssr-sub.txt'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/test-v2rayn-sub.txt', {
moxios.stubRequest('http://example.com/test-v2rayn-sub.txt', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, 'asset/test-v2rayn-sub.txt'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/netflix.list', {
moxios.stubRequest('http://example.com/netflix.list', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, 'asset/netflix.list'), {
encoding: 'utf8',
Expand Down
32 changes: 16 additions & 16 deletions test/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,14 @@ test('normalizeClashProxyGroupConfig', t => {
});

test('getShadowsocksJSONConfig', async t => {
moxios.stubRequest('/gui-config.json', {
moxios.stubRequest('http://example.com/gui-config.json', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, '../asset/gui-config-1.json'), {
encoding: 'utf8',
}),
});

const config = await utils.getShadowsocksJSONConfig({ url: '/gui-config.json', udpRelay: true });
const config = await utils.getShadowsocksJSONConfig({ url: 'http://example.com/gui-config.json', udpRelay: true });

t.deepEqual(config[0], {
nodeName: '🇺🇸US 1',
Expand Down Expand Up @@ -387,19 +387,19 @@ test('getShadowsocksJSONConfig', async t => {
});

test('loadRemoteSnippetList', async t => {
moxios.stubRequest('/test-ruleset.list', {
moxios.stubRequest('http://example.com/test-ruleset.list', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, '../asset/test-ruleset-1.list'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/netflix.list', {
moxios.stubRequest('http://example.com/netflix.list', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, '../asset/netflix.list'), {
encoding: 'utf8',
}),
});
moxios.stubRequest('/telegram.list', {
moxios.stubRequest('http://example.com/telegram.list', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, '../asset/telegram.list'), {
encoding: 'utf8',
Expand All @@ -408,15 +408,15 @@ test('loadRemoteSnippetList', async t => {

const remoteSnippetList = await utils.loadRemoteSnippetList([
{
url: '/telegram.list',
url: 'http://example.com/telegram.list',
name: 'telegram',
},
{
url: '/netflix.list',
url: 'http://example.com/netflix.list',
name: 'netflix',
},
{
url: '/test-ruleset.list',
url: 'http://example.com/test-ruleset.list',
name: 'test',
},
]);
Expand Down Expand Up @@ -453,32 +453,32 @@ test('loadRemoteSnippetList', async t => {
test('loadRemoteSnippetList with error', async t => {
t.plan(1);

moxios.stubRequest('/error', {
moxios.stubRequest('http://example.com/error', {
status: 500,
responseText: '',
});

try {
const res = await utils.loadRemoteSnippetList([
{
url: '/error',
url: 'http://example.com/error',
name: 'error',
},
]);
} catch (err) {
t.truthy(err instanceof Error);
}
})
});

test('getV2rayNSubscription', async t => {
moxios.stubRequest('/test-v2rayn-sub.txt', {
moxios.stubRequest('http://example.com/test-v2rayn-sub.txt', {
status: 200,
responseText: fs.readFileSync(path.join(__dirname, '../asset/test-v2rayn-sub.txt'), {
encoding: 'utf8',
}),
});

const url = '/test-v2rayn-sub.txt';
const url = 'http://example.com/test-v2rayn-sub.txt';
const configList = await utils.getV2rayNSubscription({ url });

t.deepEqual(configList[0], {
Expand Down Expand Up @@ -744,7 +744,7 @@ test('getShadowsocksSubscription with udp', async t => {
});

const nodeList = await utils.getShadowsocksSubscription({
url: '/ss-sub.txt',
url: 'http://example.com/ss-sub.txt',
udpRelay: true,
});

Expand Down Expand Up @@ -779,7 +779,7 @@ test('getShadowsocksSubscription without udp', async t => {
});

const nodeList = await utils.getShadowsocksSubscription({
url: '/ss-sub.txt',
url: 'http://example.com/ss-sub.txt',
});

t.deepEqual(nodeList[0], {
Expand Down Expand Up @@ -811,7 +811,7 @@ test('getShadowsocksrSubscription', async t => {
});

const nodeList = await utils.getShadowsocksrSubscription({
url: '/ssr-sub.txt',
url: 'http://example.com/ssr-sub.txt',
});

t.deepEqual(nodeList[0], {
Expand Down

0 comments on commit 67c9a99

Please sign in to comment.