Skip to content

Commit 3df69e6

Browse files
committed
✅ add tests for mutually exclusive tags
1 parent 1e5c047 commit 3df69e6

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

test/integration/headers/fixtures.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ValueType } from 'webpack-userscript';
1+
import { HeadersProps, ValueType } from 'webpack-userscript';
22

33
import { File, GlobalFixtures } from '../fixtures';
44

@@ -91,4 +91,22 @@ export class Fixtures extends GlobalFixtures {
9191
invalidValues: [{ value: { unknownBrowser: 'incompatible string' } }],
9292
},
9393
};
94+
95+
public static readonly mutuallyExclusiveTags: HeadersProps[] = [
96+
{
97+
homepage: 'https://home.example.com',
98+
homepageURL: 'https://home.example.com',
99+
website: 'https://home.example.com',
100+
source: 'https://home.example.com',
101+
},
102+
{
103+
icon: 'https://icon.example.com',
104+
iconURL: 'https://icon.example.com',
105+
defaulticon: 'https://icon.example.com',
106+
},
107+
{
108+
downloadURL: 'https://download.example.com',
109+
installURL: 'https://install.example.com',
110+
},
111+
];
94112
}

test/integration/headers/index.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ describe('headers', () => {
109109
return expect(promise).toReject();
110110
});
111111

112+
for (const headers of Fixtures.mutuallyExclusiveTags) {
113+
it(
114+
'should throw error if mutually exclusive tags present: ' +
115+
Object.keys(headers).join(', '),
116+
() => {
117+
const promise = compile(input, {
118+
...Fixtures.webpackConfig,
119+
plugins: [
120+
new UserscriptPlugin({
121+
headers,
122+
strict: true,
123+
}),
124+
],
125+
});
126+
127+
return expect(promise).toReject();
128+
},
129+
);
130+
}
131+
112132
for (const [tag, { validValues, invalidValues }] of Object.entries(
113133
Fixtures.tagSamples,
114134
)) {

test/integration/proxy-script/base-url-proxy-script.headers.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
// @version 0.0.0
55
// @match *://*/*
66
// @downloadURL http://example.com
7-
// @installURL http://example.com
87
// @updateURL http://example.com
98
// ==/UserScript==

test/integration/proxy-script/index.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('proxy script', () => {
2222
headers: {
2323
// these URLs should be ignored in proxy scripts
2424
updateURL: 'http://example.com',
25-
downloadURL: 'http://example.com',
2625
installURL: 'http://example.com',
2726
// require tag will be extended in the proxy script
2827
require: ['http://require.example.com'],
@@ -47,7 +46,6 @@ describe('proxy script', () => {
4746
headers: {
4847
// these URLs should be ignored in proxy scripts
4948
updateURL: 'http://example.com',
50-
downloadURL: 'http://example.com',
5149
installURL: 'http://example.com',
5250
// require tag will be extended in the proxy script
5351
require: 'http://require.example.com',
@@ -75,7 +73,6 @@ describe('proxy script', () => {
7573
// these URLs should be ignored in proxy scripts
7674
updateURL: 'http://example.com',
7775
downloadURL: 'http://example.com',
78-
installURL: 'http://example.com',
7976
},
8077
proxyScript: {
8178
baseURL: 'http://base.example.com',

test/integration/proxy-script/proxy-script.headers.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// @description this is a fantastic userscript
44
// @version 0.0.0
55
// @match *://*/*
6-
// @downloadURL http://example.com
76
// @installURL http://example.com
87
// @require http://require.example.com
98
// @updateURL http://example.com

0 commit comments

Comments
 (0)