9546860d05
Unit tests currently load shell sources directly from the filesystem. This is currently blocking generated sources - namely config.js - to ESM, because a relative import from the source dir will fail to locate the file in the build dir. Address this by using the same GResource as gnome-shell instead of direct filesystem access, as the resource will always include all sources files at the expected location. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2880>
74 lines
1.2 KiB
JavaScript
74 lines
1.2 KiB
JavaScript
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
// Test cases for version comparison
|
|
|
|
const JsUnit = imports.jsUnit;
|
|
|
|
import 'resource:///org/gnome/shell/ui/environment.js';
|
|
|
|
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
|
|
|
|
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,
|
|
},
|
|
];
|
|
|
|
for (let i = 0; i < tests.length; i++) {
|
|
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);
|
|
}
|