diff --git a/.eslintrc.yml b/.eslintrc.yml
index 95be3a07c..83a8fed31 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -8,6 +8,6 @@ overrides:
- js/portalHelper/**
- subprojects/extensions-app/**
- subprojects/extensions-tool/**
- - tests/shell/**
+ - tests/**
parserOptions:
sourceType: module
diff --git a/tests/unit/highlighter.js b/tests/unit/highlighter.js
index d582d38e3..dda206511 100644
--- a/tests/unit/highlighter.js
+++ b/tests/unit/highlighter.js
@@ -11,72 +11,116 @@ Environment.init();
const Util = imports.misc.util;
const tests = [
- { input: 'abc cba',
- terms: null,
- output: 'abc cba' },
- { input: 'abc cba',
- terms: [],
- output: 'abc cba' },
- { input: 'abc cba',
- terms: [''],
- output: 'abc cba' },
- { input: 'abc cba',
- terms: ['a'],
- output: 'abc cba' },
- { input: 'abc cba',
- terms: ['a', 'a'],
- output: 'abc cba' },
- { input: 'CaSe InSenSiTiVe',
- terms: ['cas', 'sens'],
- output: 'CaSe InSenSiTiVe' },
- { input: 'This contains the < character',
- terms: null,
- output: 'This contains the < character' },
- { input: 'Don\'t',
- terms: ['t'],
- output: 'Don't' },
- { input: 'Don\'t',
- terms: ['n\'t'],
- output: 'Don't' },
- { input: 'Don\'t',
- terms: ['o', 't'],
- output: 'Don't' },
- { input: 'salt&pepper',
- terms: ['salt'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['salt', 'alt'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['pepper'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['salt', 'pepper'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['t', 'p'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['t', '&', 'p'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['e'],
- output: 'salt&pepper' },
- { input: 'salt&pepper',
- terms: ['&a', '&am', '&', '&'],
- output: 'salt&pepper' },
- { input: '&&&&&',
- terms: ['a'],
- output: '&&&&&' },
- { input: '&;&;&;&;&;',
- terms: ['a'],
- output: '&;&;&;&;&;' },
- { input: '&;&;&;&;&;',
- terms: [';'],
- output: '&;&;&;&;&;' },
- { input: '&',
- terms: ['a'],
- output: '&' }
+ {
+ input: 'abc cba',
+ terms: null,
+ output: 'abc cba',
+ },
+ {
+ input: 'abc cba',
+ terms: [],
+ output: 'abc cba',
+ },
+ {
+ input: 'abc cba',
+ terms: [''],
+ output: 'abc cba',
+ },
+ {
+ input: 'abc cba',
+ terms: ['a'],
+ output: 'abc cba',
+ },
+ {
+ input: 'abc cba',
+ terms: ['a', 'a'],
+ output: 'abc cba',
+ },
+ {
+ input: 'CaSe InSenSiTiVe',
+ terms: ['cas', 'sens'],
+ output: 'CaSe InSenSiTiVe',
+ },
+ {
+ input: 'This contains the < character',
+ terms: null,
+ output: 'This contains the < character',
+ },
+ {
+ input: 'Don\'t',
+ terms: ['t'],
+ output: 'Don't',
+ },
+ {
+ input: 'Don\'t',
+ terms: ['n\'t'],
+ output: 'Don't',
+ },
+ {
+ input: 'Don\'t',
+ terms: ['o', 't'],
+ output: 'Don't',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['salt'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['salt', 'alt'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['pepper'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['salt', 'pepper'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['t', 'p'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['t', '&', 'p'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['e'],
+ output: 'salt&pepper',
+ },
+ {
+ input: 'salt&pepper',
+ terms: ['&a', '&am', '&', '&'],
+ output: 'salt&pepper',
+ },
+ {
+ input: '&&&&&',
+ terms: ['a'],
+ output: '&&&&&',
+ },
+ {
+ input: '&;&;&;&;&;',
+ terms: ['a'],
+ output: '&;&;&;&;&;',
+ },
+ {
+ input: '&;&;&;&;&;',
+ terms: [';'],
+ output: '&;&;&;&;&;',
+ },
+ {
+ input: '&',
+ terms: ['a'],
+ output: '&',
+ },
];
try {
@@ -86,7 +130,7 @@ try {
JsUnit.assertEquals(`Test ${i + 1} highlight ` +
`"${tests[i].terms}" in "${tests[i].input}"`,
- output, tests[i].output);
+ output, tests[i].output);
let parsed = false;
try {
@@ -96,9 +140,8 @@ try {
JsUnit.assertEquals(`Test ${i + 1} is valid markup`, true, parsed);
}
} catch (e) {
- if (typeof(e.isJsUnitException) != 'undefined'
- && e.isJsUnitException)
- {
+ if (typeof e.isJsUnitException != 'undefined' &&
+ e.isJsUnitException) {
if (e.comment)
log(`Error in: ${e.comment}`);
}
diff --git a/tests/unit/insertSorted.js b/tests/unit/insertSorted.js
index 33f9bd1e1..cd9f56606 100644
--- a/tests/unit/insertSorted.js
+++ b/tests/unit/insertSorted.js
@@ -20,10 +20,10 @@ Util.insertSorted(arrayInt, 3);
Assertions.assertArrayEquals('second test', [1, 2, 3, 3, 4, 5, 6], arrayInt);
-let obj1 = { a: 1 };
-let obj2 = { a: 2, b: 0 };
-let obj3 = { a: 2, b: 1 };
-let obj4 = { a: 3 };
+let obj1 = {a: 1};
+let obj2 = {a: 2, b: 0};
+let obj3 = {a: 2, b: 1};
+let obj4 = {a: 3};
let arrayObj = [obj1, obj3, obj4];
diff --git a/tests/unit/jsParse.js b/tests/unit/jsParse.js
index 207c840df..31796510c 100644
--- a/tests/unit/jsParse.js
+++ b/tests/unit/jsParse.js
@@ -10,90 +10,146 @@ Environment.init();
const JsParse = imports.misc.jsParse;
-const HARNESS_COMMAND_HEADER = "let imports = obj;" +
- "let global = obj;" +
- "let Main = obj;" +
- "let foo = obj;" +
- "let r = obj;";
+const HARNESS_COMMAND_HEADER = 'let imports = obj;' +
+ 'let global = obj;' +
+ 'let Main = obj;' +
+ 'let foo = obj;' +
+ 'let r = obj;';
const testsFindMatchingQuote = [
- { input: '"double quotes"',
- output: 0 },
- { input: '\'single quotes\'',
- output: 0 },
- { input: 'some unquoted "some quoted"',
- output: 14 },
- { input: '"mixed \' quotes\'"',
- output: 0 },
- { input: '"escaped \\" quote"',
- output: 0 }
+ {
+ input: '"double quotes"',
+ output: 0,
+ },
+ {
+ input: '\'single quotes\'',
+ output: 0,
+ },
+ {
+ input: 'some unquoted "some quoted"',
+ output: 14,
+ },
+ {
+ input: '"mixed \' quotes\'"',
+ output: 0,
+ },
+ {
+ input: '"escaped \\" quote"',
+ output: 0,
+ },
];
const testsFindMatchingSlash = [
- { input: '/slash/',
- output: 0 },
- { input: '/slash " with $ funny ^\' stuff/',
- output: 0 },
- { input: 'some unslashed /some slashed/',
- output: 15 },
- { input: '/escaped \\/ slash/',
- output: 0 }
+ {
+ input: '/slash/',
+ output: 0,
+ },
+ {
+ input: '/slash " with $ funny ^\' stuff/',
+ output: 0,
+ },
+ {
+ input: 'some unslashed /some slashed/',
+ output: 15,
+ },
+ {
+ input: '/escaped \\/ slash/',
+ output: 0,
+ },
];
const testsFindMatchingBrace = [
- { input: '[square brace]',
- output: 0 },
- { input: '(round brace)',
- output: 0 },
- { input: '([()][nesting!])',
- output: 0 },
- { input: '[we have "quoted [" braces]',
- output: 0 },
- { input: '[we have /regex [/ braces]',
- output: 0 },
- { input: '([[])[] mismatched braces ]',
- output: 1 }
+ {
+ input: '[square brace]',
+ output: 0,
+ },
+ {
+ input: '(round brace)',
+ output: 0,
+ },
+ {
+ input: '([()][nesting!])',
+ output: 0,
+ },
+ {
+ input: '[we have "quoted [" braces]',
+ output: 0,
+ },
+ {
+ input: '[we have /regex [/ braces]',
+ output: 0,
+ },
+ {
+ input: '([[])[] mismatched braces ]',
+ output: 1,
+ },
];
const testsGetExpressionOffset = [
- { input: 'abc.123',
- output: 0 },
- { input: 'foo().bar',
- output: 0 },
- { input: 'foo(bar',
- output: 4 },
- { input: 'foo[abc.match(/"/)]',
- output: 0 }
+ {
+ input: 'abc.123',
+ output: 0,
+ },
+ {
+ input: 'foo().bar',
+ output: 0,
+ },
+ {
+ input: 'foo(bar',
+ output: 4,
+ },
+ {
+ input: 'foo[abc.match(/"/)]',
+ output: 0,
+ },
];
const testsGetDeclaredConstants = [
- { input: 'const foo = X; const bar = Y;',
- output: ['foo', 'bar'] },
- { input: 'const foo=X; const bar=Y',
- output: ['foo', 'bar'] }
+ {
+ input: 'const foo = X; const bar = Y;',
+ output: ['foo', 'bar'],
+ },
+ {
+ input: 'const foo=X; const bar=Y',
+ output: ['foo', 'bar'],
+ },
];
const testsIsUnsafeExpression = [
- { input: 'foo.bar',
- output: false },
- { input: 'foo[\'bar\']',
- output: false },
- { input: 'foo["a=b=c".match(/=/)',
- output: false },
- { input: 'foo[1==2]',
- output: false },
- { input: '(x=4)',
- output: true },
- { input: '(x = 4)',
- output: true },
- { input: '(x;y)',
- output: true }
+ {
+ input: 'foo.bar',
+ output: false,
+ },
+ {
+ input: 'foo[\'bar\']',
+ output: false,
+ },
+ {
+ input: 'foo["a=b=c".match(/=/)',
+ output: false,
+ },
+ {
+ input: 'foo[1==2]',
+ output: false,
+ },
+ {
+ input: '(x=4)',
+ output: true,
+ },
+ {
+ input: '(x = 4)',
+ output: true,
+ },
+ {
+ input: '(x;y)',
+ output: true,
+ },
];
const testsModifyScope = [
"foo['a",
"foo()['b'",
"obj.foo()('a', 1, 2, 'b')().",
- "foo.[.",
- "foo]]]()))].",
+ 'foo.[.',
+ 'foo]]]()))].',
"123'ab\"",
- "Main.foo.bar = 3; bar.",
- "(Main.foo = 3).",
- "Main[Main.foo+=-1]."
+ 'Main.foo.bar = 3; bar.',
+ '(Main.foo = 3).',
+ 'Main[Main.foo+=-1].',
];
//
@@ -104,48 +160,48 @@ for (let i = 0; i < testsFindMatchingQuote.length; i++) {
let text = testsFindMatchingQuote[i].input;
let match = JsParse.findMatchingQuote(text, text.length - 1);
- JsUnit.assertEquals('Test testsFindMatchingQuote ' + i,
- match, testsFindMatchingQuote[i].output);
+ JsUnit.assertEquals(`Test testsFindMatchingQuote ${i}`,
+ match, testsFindMatchingQuote[i].output);
}
for (let i = 0; i < testsFindMatchingSlash.length; i++) {
let text = testsFindMatchingSlash[i].input;
let match = JsParse.findMatchingSlash(text, text.length - 1);
- JsUnit.assertEquals('Test testsFindMatchingSlash ' + i,
- match, testsFindMatchingSlash[i].output);
+ JsUnit.assertEquals(`Test testsFindMatchingSlash ${i}`,
+ match, testsFindMatchingSlash[i].output);
}
for (let i = 0; i < testsFindMatchingBrace.length; i++) {
let text = testsFindMatchingBrace[i].input;
let match = JsParse.findMatchingBrace(text, text.length - 1);
- JsUnit.assertEquals('Test testsFindMatchingBrace ' + i,
- match, testsFindMatchingBrace[i].output);
+ JsUnit.assertEquals(`Test testsFindMatchingBrace ${i}`,
+ match, testsFindMatchingBrace[i].output);
}
for (let i = 0; i < testsGetExpressionOffset.length; i++) {
let text = testsGetExpressionOffset[i].input;
let match = JsParse.getExpressionOffset(text, text.length - 1);
- JsUnit.assertEquals('Test testsGetExpressionOffset ' + i,
- match, testsGetExpressionOffset[i].output);
+ JsUnit.assertEquals(`Test testsGetExpressionOffset ${i}`,
+ match, testsGetExpressionOffset[i].output);
}
for (let i = 0; i < testsGetDeclaredConstants.length; i++) {
let text = testsGetDeclaredConstants[i].input;
let match = JsParse.getDeclaredConstants(text);
- Assertions.assertArrayEquals('Test testsGetDeclaredConstants ' + i,
- match, testsGetDeclaredConstants[i].output);
+ Assertions.assertArrayEquals(`Test testsGetDeclaredConstants ${i}`,
+ match, testsGetDeclaredConstants[i].output);
}
for (let i = 0; i < testsIsUnsafeExpression.length; i++) {
let text = testsIsUnsafeExpression[i].input;
let unsafe = JsParse.isUnsafeExpression(text);
- JsUnit.assertEquals('Test testsIsUnsafeExpression ' + i,
- unsafe, testsIsUnsafeExpression[i].output);
+ JsUnit.assertEquals(`Test testsIsUnsafeExpression ${i}`,
+ unsafe, testsIsUnsafeExpression[i].output);
}
//
@@ -165,19 +221,17 @@ for (let i = 0; i < testsModifyScope.length; i++) {
let matches = text.match(/(.*)\.(.*)/);
if (matches) {
- let [expr, base, attrHead] = matches;
+ let [, base] = matches;
if (!JsParse.isUnsafeExpression(base)) {
- with (obj) {
- try {
- eval(HARNESS_COMMAND_HEADER + base);
- } catch (e) {
- JsUnit.assertNotEquals("Code '" + base + "' is valid code", e.constructor, SyntaxError);
- }
+ try {
+ eval(HARNESS_COMMAND_HEADER + base);
+ } catch (e) {
+ JsUnit.assertNotEquals(`Code '${base}' is valid code`, e.constructor, SyntaxError);
}
}
}
}
let propertyNames = Object.getOwnPropertyNames(obj);
- JsUnit.assertEquals("The context '" + JSON.stringify(obj) + "' was not modified", propertyNames.length, 0);
+ JsUnit.assertEquals(`The context '${JSON.stringify(obj)}' was not modified`, propertyNames.length, 0);
}
diff --git a/tests/unit/markup.js b/tests/unit/markup.js
index 603ca8194..1df1eb09b 100644
--- a/tests/unit/markup.js
+++ b/tests/unit/markup.js
@@ -8,12 +8,17 @@ const Pango = imports.gi.Pango;
const Environment = imports.ui.environment;
Environment.init();
-const Main = imports.ui.main; // unused, but needed to break dependency loop
+imports.ui.main; // eslint-disable-line no-unused-expressions
const MessageList = imports.ui.messageList;
-// Assert that @input, assumed to be markup, gets "fixed" to @output,
-// which is valid markup. If @output is null, @input is expected to
-// convert to itself
+/**
+ * Assert that `input`, assumed to be markup, gets "fixed" to `output`,
+ * which is valid markup. If `output` is null, `input` is expected to
+ * convert to itself
+ *
+ * @param {string} input the input
+ * @param {string} output the output
+ */
function assertConverts(input, output) {
if (!output)
output = input;
@@ -28,8 +33,14 @@ function assertConverts(input, output) {
JsUnit.assertEquals(true, parsed);
}
-// Assert that @input, assumed to be plain text, gets escaped to @output,
-// which is valid markup.
+
+/**
+ * Assert that `input`, assumed to be plain text, gets escaped to `output`,
+ * which is valid markup.
+ *
+ * @param {string} input the input
+ * @param {string} output the output
+ */
function assertEscapes(input, output) {
let fixed = MessageList._fixMarkup(input, false);
JsUnit.assertEquals(output, fixed);
diff --git a/tests/unit/params.js b/tests/unit/params.js
index 6ac4cc10c..a3b74df13 100644
--- a/tests/unit/params.js
+++ b/tests/unit/params.js
@@ -1,6 +1,13 @@
const JsUnit = imports.jsUnit;
const Params = imports.misc.params;
+/**
+ * Asserts that two "param" objects have the same properties
+ * with the same values.
+ *
+ * @param {object} params the parsed params
+ * @param {object} expected the expected params
+ */
function assertParamsEqual(params, expected) {
for (let p in params) {
JsUnit.assertTrue(p in expected);
@@ -11,7 +18,7 @@ function assertParamsEqual(params, expected) {
let defaults = {
foo: 'This is a test',
bar: null,
- baz: 42
+ baz: 42,
};
assertParamsEqual(
@@ -19,14 +26,14 @@ assertParamsEqual(
defaults);
assertParamsEqual(
- Params.parse({ bar: 23 }, defaults),
- { foo: 'This is a test', bar: 23, baz: 42 });
+ Params.parse({bar: 23}, defaults),
+ {foo: 'This is a test', bar: 23, baz: 42});
JsUnit.assertRaises(
() => {
- Params.parse({ extraArg: 'quz' }, defaults);
+ Params.parse({extraArg: 'quz'}, defaults);
});
assertParamsEqual(
- Params.parse({ extraArg: 'quz' }, defaults, true),
- { foo: 'This is a test', bar: null, baz: 42, extraArg: 'quz' });
+ Params.parse({extraArg: 'quz'}, defaults, true),
+ {foo: 'This is a test', bar: null, baz: 42, extraArg: 'quz'});
diff --git a/tests/unit/signalTracker.js b/tests/unit/signalTracker.js
index 6499a0f8e..c6c6d4a7e 100644
--- a/tests/unit/signalTracker.js
+++ b/tests/unit/signalTracker.js
@@ -8,17 +8,17 @@ const JsUnit = imports.jsUnit;
const Signals = imports.misc.signals;
const Environment = imports.ui.environment;
-const { TransientSignalHolder, registerDestroyableType } = imports.misc.signalTracker;
+const {TransientSignalHolder, registerDestroyableType} = imports.misc.signalTracker;
Environment.init();
const Destroyable = GObject.registerClass({
- Signals: { 'destroy': {} },
+ Signals: {'destroy': {}},
}, class Destroyable extends GObject.Object {});
registerDestroyableType(Destroyable);
const GObjectEmitter = GObject.registerClass({
- Signals: { 'signal': {} },
+ Signals: {'signal': {}},
}, class GObjectEmitter extends Destroyable {});
const emitter1 = new Signals.EventEmitter();
@@ -27,6 +27,7 @@ const emitter2 = new GObjectEmitter();
const tracked1 = new Destroyable();
const tracked2 = {};
+let transientHolder;
let count = 0;
const handler = () => count++;
diff --git a/tests/unit/url.js b/tests/unit/url.js
index 84aecc95f..de9fd0f9d 100644
--- a/tests/unit/url.js
+++ b/tests/unit/url.js
@@ -10,68 +10,114 @@ Environment.init();
const Util = imports.misc.util;
const tests = [
- { input: 'This is a test',
- output: [] },
- { input: 'This is http://www.gnome.org a test',
- output: [ { url: 'http://www.gnome.org', pos: 8 } ] },
- { input: 'This is http://www.gnome.org',
- output: [ { url: 'http://www.gnome.org', pos: 8 } ] },
- { input: 'http://www.gnome.org a test',
- output: [ { url: 'http://www.gnome.org', pos: 0 } ] },
- { input: 'http://www.gnome.org',
- output: [ { url: 'http://www.gnome.org', pos: 0 } ] },
- { input: 'Go to http://www.gnome.org.',
- output: [ { url: 'http://www.gnome.org', pos: 6 } ] },
- { input: 'Go to http://www.gnome.org/.',
- output: [ { url: 'http://www.gnome.org/', pos: 6 } ] },
- { input: '(Go to http://www.gnome.org!)',
- output: [ { url: 'http://www.gnome.org', pos: 7 } ] },
- { input: 'Use GNOME (http://www.gnome.org).',
- output: [ { url: 'http://www.gnome.org', pos: 11 } ] },
- { input: 'This is a http://www.gnome.org/path test.',
- output: [ { url: 'http://www.gnome.org/path', pos: 10 } ] },
- { input: 'This is a www.gnome.org scheme-less test.',
- output: [ { url: 'www.gnome.org', pos: 10 } ] },
- { input: 'This is a www.gnome.org/scheme-less test.',
- output: [ { url: 'www.gnome.org/scheme-less', pos: 10 } ] },
- { input: 'This is a http://www.gnome.org:99/port test.',
- output: [ { url: 'http://www.gnome.org:99/port', pos: 10 } ] },
- { input: 'This is an ftp://www.gnome.org/ test.',
- output: [ { url: 'ftp://www.gnome.org/', pos: 11 } ] },
- { input: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)',
- output: [ { url: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)', pos: 0 } ] },
- { input: 'https://www.gnome.org/(some_url_with_unbalanced_parenthesis',
- output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
- { input: 'https://www.gnome.org/ plus trailing junk',
- output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
+ {
+ input: 'This is a test',
+ output: [],
+ },
+ {
+ input: 'This is http://www.gnome.org a test',
+ output: [{url: 'http://www.gnome.org', pos: 8}],
+ },
+ {
+ input: 'This is http://www.gnome.org',
+ output: [{url: 'http://www.gnome.org', pos: 8}],
+ },
+ {
+ input: 'http://www.gnome.org a test',
+ output: [{url: 'http://www.gnome.org', pos: 0}],
+ },
+ {
+ input: 'http://www.gnome.org',
+ output: [{url: 'http://www.gnome.org', pos: 0}],
+ },
+ {
+ input: 'Go to http://www.gnome.org.',
+ output: [{url: 'http://www.gnome.org', pos: 6}],
+ },
+ {
+ input: 'Go to http://www.gnome.org/.',
+ output: [{url: 'http://www.gnome.org/', pos: 6}],
+ },
+ {
+ input: '(Go to http://www.gnome.org!)',
+ output: [{url: 'http://www.gnome.org', pos: 7}],
+ },
+ {
+ input: 'Use GNOME (http://www.gnome.org).',
+ output: [{url: 'http://www.gnome.org', pos: 11}],
+ },
+ {
+ input: 'This is a http://www.gnome.org/path test.',
+ output: [{url: 'http://www.gnome.org/path', pos: 10}],
+ },
+ {
+ input: 'This is a www.gnome.org scheme-less test.',
+ output: [{url: 'www.gnome.org', pos: 10}],
+ },
+ {
+ input: 'This is a www.gnome.org/scheme-less test.',
+ output: [{url: 'www.gnome.org/scheme-less', pos: 10}],
+ },
+ {
+ input: 'This is a http://www.gnome.org:99/port test.',
+ output: [{url: 'http://www.gnome.org:99/port', pos: 10}],
+ },
+ {
+ input: 'This is an ftp://www.gnome.org/ test.',
+ output: [{url: 'ftp://www.gnome.org/', pos: 11}],
+ },
+ {
+ input: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)',
+ output: [{url: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)', pos: 0}],
+ },
+ {
+ input: 'https://www.gnome.org/(some_url_with_unbalanced_parenthesis',
+ output: [{url: 'https://www.gnome.org/', pos: 0}],
+ },
+ {
+ input: 'https://www.gnome.org/ plus trailing junk',
+ output: [{url: 'https://www.gnome.org/', pos: 0}],
+ },
- { input: 'Visit http://www.gnome.org/ and http://developer.gnome.org',
- output: [ { url: 'http://www.gnome.org/', pos: 6 },
- { url: 'http://developer.gnome.org', pos: 32 } ] },
+ {
+ input: 'Visit http://www.gnome.org/ and http://developer.gnome.org',
+ output: [{url: 'http://www.gnome.org/', pos: 6},
+ {url: 'http://developer.gnome.org', pos: 32}],
+ },
- { input: 'This is not.a.domain test.',
- output: [ ] },
- { input: 'This is not:a.url test.',
- output: [ ] },
- { input: 'This is not:/a.url/ test.',
- output: [ ] },
- { input: 'This is not:/a.url/ test.',
- output: [ ] },
- { input: 'This is not@a.url/ test.',
- output: [ ] },
- { input: 'This is surely@not.a/url test.',
- output: [ ] }
+ {
+ input: 'This is not.a.domain test.',
+ output: [],
+ },
+ {
+ input: 'This is not:a.url test.',
+ output: [],
+ },
+ {
+ input: 'This is not:/a.url/ test.',
+ output: [],
+ },
+ {
+ input: 'This is not:/a.url/ test.',
+ output: [],
+ },
+ {
+ input: 'This is not@a.url/ test.',
+ output: [],
+ },
+ {
+ input: 'This is surely@not.a/url test.',
+ output: [],
+ },
];
for (let i = 0; i < tests.length; i++) {
let match = Util.findUrls(tests[i].input);
- JsUnit.assertEquals('Test ' + i + ' match length',
- match.length, tests[i].output.length);
+ JsUnit.assertEquals(`Test ${i} match length`,
+ match.length, tests[i].output.length);
for (let j = 0; j < match.length; j++) {
- JsUnit.assertEquals('Test ' + i + ', match ' + j + ' url',
- match[j].url, tests[i].output[j].url);
- JsUnit.assertEquals('Test ' + i + ', match ' + j + ' position',
- match[j].pos, tests[i].output[j].pos);
+ JsUnit.assertEquals(`Test ${i}, match ${j} url`, match[j].url, tests[i].output[j].url);
+ JsUnit.assertEquals(`Test ${i}, match ${j} position`, match[j].pos, tests[i].output[j].pos);
}
}
diff --git a/tests/unit/versionCompare.js b/tests/unit/versionCompare.js
index 1997a6c80..b51781818 100644
--- a/tests/unit/versionCompare.js
+++ b/tests/unit/versionCompare.js
@@ -10,43 +10,65 @@ Environment.init();
const Util = imports.misc.util;
const tests = [
- { v1: '40',
- v2: '40',
- res: 0 },
- { v1: '40',
- v2: '42',
- res: -1 },
- { v1: '42',
- v2: '40',
- res: 1 },
- { v1: '3.38.0',
- v2: '40',
- res: -1 },
- { v1: '40',
- v2: '3.38.0',
- res: 1 },
- { v1: '40',
- v2: '3.38.0',
- res: 1 },
- { v1: '40.alpha.1.1',
- v2: '40',
- res: -1 },
- { v1: '40',
- v2: '40.alpha.1.1',
- res: 1 },
- { v1: '40.beta',
- v2: '40',
- res: -1 },
- { v1: '40.1',
- v2: '40',
- res: 1 },
- { v1: '',
- v2: '40.alpha',
- res: -1 },
+ {
+ v1: '40',
+ v2: '40',
+ res: 0,
+ },
+ {
+ v1: '40',
+ v2: '42',
+ res: -1,
+ },
+ {
+ v1: '42',
+ v2: '40',
+ res: 1,
+ },
+ {
+ v1: '3.38.0',
+ v2: '40',
+ res: -1,
+ },
+ {
+ v1: '40',
+ v2: '3.38.0',
+ res: 1,
+ },
+ {
+ v1: '40',
+ v2: '3.38.0',
+ res: 1,
+ },
+ {
+ v1: '40.alpha.1.1',
+ v2: '40',
+ res: -1,
+ },
+ {
+ v1: '40',
+ v2: '40.alpha.1.1',
+ res: 1,
+ },
+ {
+ v1: '40.beta',
+ v2: '40',
+ res: -1,
+ },
+ {
+ v1: '40.1',
+ v2: '40',
+ res: 1,
+ },
+ {
+ v1: '',
+ v2: '40.alpha',
+ res: -1,
+ },
];
for (let i = 0; i < tests.length; i++) {
- name = 'Test #' + i + ' v1: ' + tests[i].v1 + ', v2: ' + tests[i].v2;
+ const name = `Test #${i} v1: ${tests[i].v1}, v2: ${tests[i].v2}`;
print(name);
- JsUnit.assertEquals(name, Util.GNOMEversionCompare (tests[i].v1, tests[i].v2), tests[i].res);
+ JsUnit.assertEquals(name, Util.GNOMEversionCompare(tests[i].v1, tests[i].v2), tests[i].res);
}