mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
tests: Port findUrl() test to jasmine
Based on https://bugzilla.gnome.org/show_bug.cgi?id=783738 from Sam Spilsbury. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3164>
This commit is contained in:
parent
8345047c24
commit
41aa44707a
2 changed files with 111 additions and 112 deletions
|
|
@ -27,6 +27,7 @@ unit_tests = [
|
||||||
'markup',
|
'markup',
|
||||||
'params',
|
'params',
|
||||||
'signalTracker',
|
'signalTracker',
|
||||||
|
'url',
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach test : unit_tests
|
foreach test : unit_tests
|
||||||
|
|
@ -45,7 +46,6 @@ foreach test : unit_tests
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
legacy_tests = [
|
legacy_tests = [
|
||||||
'url',
|
|
||||||
'versionCompare',
|
'versionCompare',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
// Test cases for MessageTray URLification
|
// Test cases for MessageTray URLification
|
||||||
|
|
||||||
const JsUnit = imports.jsUnit;
|
|
||||||
|
|
||||||
import 'resource:///org/gnome/shell/ui/environment.js';
|
import 'resource:///org/gnome/shell/ui/environment.js';
|
||||||
|
import {findUrls} from 'resource:///org/gnome/shell/misc/util.js';
|
||||||
|
|
||||||
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
|
describe('findUrls()', () => {
|
||||||
|
const urlParameters = [
|
||||||
const tests = [
|
|
||||||
{
|
{
|
||||||
input: 'This is a test',
|
input: 'This is a test',
|
||||||
output: [],
|
output: [],
|
||||||
|
|
@ -110,13 +108,14 @@ const tests = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < tests.length; i++) {
|
for (const param of urlParameters) {
|
||||||
let match = Util.findUrls(tests[i].input);
|
const {input, output} = param;
|
||||||
|
const findsOrDoesNotFind = output.length > 0
|
||||||
|
? 'finds'
|
||||||
|
: 'does not find';
|
||||||
|
|
||||||
JsUnit.assertEquals(`Test ${i} match length`,
|
it(`${findsOrDoesNotFind} URLs in "${input}"`, () => {
|
||||||
match.length, tests[i].output.length);
|
expect(findUrls(input)).toEqual(output);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue