forked from igvteam/igv.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestBrowser.js
154 lines (122 loc) · 4.39 KB
/
testBrowser.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import {createBrowser, removeBrowser} from "../js/igv-create.js";
function runBrowserTests() {
// Mock objects
const div = document.createElement("div");
QUnit.test("Test navigation option", function (assert) {
var done = assert.async();
const options = {
genome: "hg19",
showNavigation: false
};
createBrowser(div, options)
.then(function (browser) {
assert.ok(browser);
done();
})
.catch(function (error) {
assert.ok(false);
console.log(error);
done();
})
});
QUnit.test("Test ruler option", function (assert) {
var done = assert.async();
const options = {
genome: "hg19",
showRuler: false
};
createBrowser(div, options)
.then(function (browser) {
assert.ok(browser);
done();
})
.catch(function (error) {
assert.ok(false);
console.log(error);
done();
})
});
QUnit.test("Test addTrackToFactory method", function (assert) {
var done = assert.async();
const options = {
genome: "hg19",
};
createBrowser(div, options)
.then(function (browser) {
assert.ok(browser);
browser.addTrackToFactory('mocktrack', (config, browser) => true);
assert.ok(browser.createTrack({type: 'mocktrack'}));
done();
})
.catch(function (error) {
assert.ok(false);
console.log(error);
done();
})
});
QUnit.test("Test remove browser", function (assert) {
var done = assert.async();
// Create and remove "n" browsers.
const n = 5;
let i = 0;
createRemove();
function createRemove() {
createBrowser(div, {
genome: "hg19",
locus: "myc"
})
.then(function (browser) {
removeBrowser(browser);
if (i++ < 10) {
createRemove();
} else {
assert.ok(true);
done();
}
})
.catch(function (error) {
console.error(error);
assert.ok(false);
done();
})
}
})
QUnit.test("Test custom Ensembl search backend", function (assert) {
var done = assert.async();
// The Ensembl REST API for symbol lookup (https://rest.ensembl.org/documentation/info/symbol_lookup)
// enables searching genes for a wider array of organisms than those supported by default
// in https://igv.org/genomes/locus.php.
//
// This tests handling for the Ensembl lookup API as a custom igv.js search backend.
//
// The example below uses a human reference, to avoid complexity around also mocking support
// for custom reference genomes. The search itself uses crab-eating macaque (Macaca
// fascicularis) -- the original motivation to support a custom Ensembl search backend.
// In real-world examples, the `genome` would use a custom reference for Macaca fascicularis.
createBrowser(div, {
genome: "hg19",
locus: "myc",
search: {
url: 'https://rest.ensembl.org/lookup/symbol/macaca_fascicularis/$FEATURE$?content-type=application/json',
chromosomeField: 'seq_region_name',
displayName: 'display_name'
}
})
.then(function (browser) {
browser.search('BRCA2').then(function (genomicState) {
// console.log('genomicState')
// console.log(JSON.stringify(genomicState))
assert.equal(genomicState[0].chromosome.name, 'chr17');
assert.equal(genomicState[0].start, 11863385);
assert.equal(genomicState[0].end, 11957305);
done();
})
})
.catch(function (error) {
console.error(error);
assert.ok(false);
done();
})
})
}
export default runBrowserTests;