|
|
@@ -1,14 +1,5 @@
|
|
|
import test from 'tape';
|
|
|
-import { isRemote, compareVersion } from 'src/background/utils/script';
|
|
|
-
|
|
|
-test('isRemote', t => {
|
|
|
- t.notOk(isRemote());
|
|
|
- t.notOk(isRemote('file:///tmp/file'));
|
|
|
- t.notOk(isRemote('data:text/plain,hello,world'));
|
|
|
- t.ok(isRemote('http://www.google.com'));
|
|
|
- t.ok(isRemote('https://www.google.com'));
|
|
|
- t.end();
|
|
|
-});
|
|
|
+import { compareVersion, parseMeta } from 'src/background/utils/script';
|
|
|
|
|
|
test('compareVersion', t => {
|
|
|
t.equal(compareVersion('1.2.3', '1.2.3'), 0);
|
|
|
@@ -20,3 +11,48 @@ test('compareVersion', t => {
|
|
|
t.equal(compareVersion('1.10', '1.9'), 1);
|
|
|
t.end();
|
|
|
});
|
|
|
+
|
|
|
+const baseMeta = {
|
|
|
+ include: [],
|
|
|
+ exclude: [],
|
|
|
+ match: [],
|
|
|
+ excludeMatch: [],
|
|
|
+ require: [],
|
|
|
+ grant: [],
|
|
|
+ resources: {},
|
|
|
+ noframes: false,
|
|
|
+};
|
|
|
+
|
|
|
+test('parseMeta', t => {
|
|
|
+ t.deepEqual(parseMeta(`\
|
|
|
+// ==UserScript==
|
|
|
+// @name New Script
|
|
|
+// @namespace Violentmonkey Scripts
|
|
|
+// @description This is a script
|
|
|
+// @version 1.0
|
|
|
+// @match *://*/*
|
|
|
+// @grant none
|
|
|
+// ==/UserScript==
|
|
|
+`), Object.assign({}, baseMeta, {
|
|
|
+ name: 'New Script',
|
|
|
+ namespace: 'Violentmonkey Scripts',
|
|
|
+ description: 'This is a script',
|
|
|
+ version: '1.0',
|
|
|
+ match: ['*://*/*'],
|
|
|
+ grant: ['none'],
|
|
|
+ }));
|
|
|
+ t.deepEqual(parseMeta(`\
|
|
|
+// ==UserScript==
|
|
|
+// @name New Script
|
|
|
+// @namespace Violentmonkey Scripts
|
|
|
+// @match *://*/*
|
|
|
+// @noframes
|
|
|
+// ==/UserScript==
|
|
|
+`), Object.assign({}, baseMeta, {
|
|
|
+ name: 'New Script',
|
|
|
+ namespace: 'Violentmonkey Scripts',
|
|
|
+ match: ['*://*/*'],
|
|
|
+ noframes: true,
|
|
|
+ }));
|
|
|
+ t.end();
|
|
|
+});
|