forked from GMOD/bam-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtsget.test.ts
61 lines (57 loc) · 1.7 KB
/
htsget.test.ts
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
// @ts-nocheck
import { HtsgetFile } from '../src'
import * as fs from 'fs'
const fetch = req => {
const result = fs.readFileSync(
require.resolve('./htsget/result.json'),
'utf8',
)
if (
req ===
'http://htsnexus.rnd.dnanex.us/v1/reads/BroadHiSeqX_b37/NA12878?referenceName=na&class=header'
) {
return new Response(result, { status: 200 })
} else if (
req ===
'https://dl.dnanex.us/F/D/Pb1QjgQx9j2bZ8Q44x50xf4fQV3YZBgkvkz23FFB/NA12878_recompressed.bam'
) {
const result = fs.readFileSync(require.resolve('./htsget/data.bam'))
return new Response(result, { status: 206 })
} else {
return new Response(result, { status: 200 })
}
}
beforeEach(() => {
jest.restoreAllMocks()
})
xdescribe('htsspec htsget wtsi', () => {
it('wtsi', async () => {
const ti = new HtsgetFile({
baseUrl: 'https://htsget.wtsi-npg-test.co.uk:9090/npg_ranger',
trackId: 'ga4gh/sample/NA12878',
})
await ti.getHeader()
console.log(ti)
})
})
test('dnanexus with mock', async () => {
global.fetch = jest.fn().mockImplementation(fetch)
const ti = new HtsgetFile({
baseUrl: 'http://htsnexus.rnd.dnanex.us/v1/reads',
trackId: 'BroadHiSeqX_b37/NA12878',
})
const header = await ti.getHeader()
expect(header).toBeTruthy()
const records = await ti.getRecordsForRange(1, 2000000, 2000001)
expect(records.length).toBe(39)
})
test('dnanexus without mock', async () => {
const ti = new HtsgetFile({
baseUrl: 'http://htsnexus.rnd.dnanex.us/v1/reads',
trackId: 'BroadHiSeqX_b37/NA12878',
})
const header = await ti.getHeader()
expect(header).toBeTruthy()
const records = await ti.getRecordsForRange(1, 2000000, 2000001)
expect(records.length).toBe(39)
})