aboutsummaryrefslogtreecommitdiff
path: root/test/shared/blacklists.test.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-07-13 22:36:56 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-07-13 22:36:56 +0900
commit944dea59199fa03f77e0e7c0d3c02acf8ccb458f (patch)
tree5f44471cdb32376a8c93e6f6eba738180f08c96f /test/shared/blacklists.test.js
parent77b4e807e2a8b3e7ddb5f042719a34962a31b1c4 (diff)
parent28bfa3ac8124d3453cd539db26da4f4703e783df (diff)
Merge remote-tracking branch 'origin/master' into greenkeeper/css-loader-1.0.0
Diffstat (limited to 'test/shared/blacklists.test.js')
-rw-r--r--test/shared/blacklists.test.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/shared/blacklists.test.js b/test/shared/blacklists.test.js
new file mode 100644
index 0000000..87e89c5
--- /dev/null
+++ b/test/shared/blacklists.test.js
@@ -0,0 +1,42 @@
+import { includes } from 'shared/blacklists';
+
+describe("shared/blacklist", () => {
+ it('matches by *', () => {
+ let blacklist = ['*'];
+
+ expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
+ })
+
+ it('matches by hostname', () => {
+ let blacklist = ['github.com'];
+
+ expect(includes(blacklist, 'https://github.com')).to.be.true;
+ expect(includes(blacklist, 'https://gist.github.com')).to.be.false;
+ expect(includes(blacklist, 'https://github.com/ueokande')).to.be.true;
+ expect(includes(blacklist, 'https://github.org')).to.be.false;
+ expect(includes(blacklist, 'https://google.com/search?q=github.org')).to.be.false;
+ })
+
+ it('matches by hostname with wildcard', () => {
+ let blacklist = ['*.github.com'];
+
+ expect(includes(blacklist, 'https://github.com')).to.be.false;
+ expect(includes(blacklist, 'https://gist.github.com')).to.be.true;
+ })
+
+ it('matches by path', () => {
+ let blacklist = ['github.com/abc'];
+
+ expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
+ expect(includes(blacklist, 'https://github.com/abcdef')).to.be.false;
+ expect(includes(blacklist, 'https://gist.github.com/abc')).to.be.false;
+ })
+
+ it('matches by path with wildcard', () => {
+ let blacklist = ['github.com/abc*'];
+
+ expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
+ expect(includes(blacklist, 'https://github.com/abcdef')).to.be.true;
+ expect(includes(blacklist, 'https://gist.github.com/abc')).to.be.false;
+ })
+});