This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjasminegjsbootstrap.js
92 lines (73 loc) · 2.72 KB
/
jasminegjsbootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
var _jasmineRequire = imports.lib['jasmine-core'].jasmine;
var jasmineRequire = _jasmineRequire.getJasmineRequireObj();
var jasmine = jasmineRequire.core(jasmineRequire);
const Timer = imports.EndlessTimer;
var env = jasmine.getEnv();
function getBaseNameAndLineNumber() {
// The familiar hack to get the current line, though we want the
// second line since we're actually inside of _getBaseNameAndLineNumber ->
// jasmineInterface
const error = new Error();
const lines = error.stack.split('\n');
const lineString = lines[2];
const lineStringBasenameIndex = lineString.lastIndexOf('/') + 1;
const lineStringLinenumberIndex = lineString.lastIndexOf(':');
const baseName = lineString.slice(lineStringBasenameIndex, lineStringLinenumberIndex);
const fileBaseName = lineString.slice(lineString.lastIndexOf('/') + 1, lineStringLinenumberIndex);
const lineNumber = lineString.slice(lineStringLinenumberIndex + 1, lineString.length);
return {
baseName: fileBaseName,
lineNumber: lineNumber
};
};
var jasmineInterface = {
describe: function (description, specDefinitions) {
let suite = env.describe(description, specDefinitions);
Lang.copyProperties(getBaseNameAndLineNumber(), suite.result);
return suite;
},
xdescribe: function (description, specDefinitions) {
let suite = env.xdescribe(description, specDefinitions);
Lang.copyProperties(getBaseNameAndLineNumber(), suite.result);
return suite;
},
it: function (desc, func) {
let spec = env.it(desc, func);
Lang.copyProperties(getBaseNameAndLineNumber(), spec.result);
return spec;
},
xit: function (desc, func) {
let spec = env.xit(desc, func);
Lang.copyProperties(getBaseNameAndLineNumber(), spec.result);
return spec;
},
beforeEach: function (beforeEachFunction) {
return env.beforeEach(beforeEachFunction);
},
afterEach: function (afterEachFunction) {
return env.afterEach(afterEachFunction);
},
expect: function (actual) {
return env.expect(actual);
},
spyOn: function (obj, methodName) {
return env.spyOn(obj, methodName);
},
jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer()
})
};
Lang.copyProperties(jasmineInterface, window); // window is the GJS equivalent of global.
window.jasmine = jasmine;
jasmine.addCustomEqualityTester = function (tester) {
env.addCustomEqualityTester(tester);
};
jasmine.addMatchers = function (matchers) {
return env.addMatchers(matchers);
};
jasmine.clock = function () {
return env.clock;
};