-
Notifications
You must be signed in to change notification settings - Fork 308
/
Copy pathprice.test.ts
50 lines (45 loc) · 1.22 KB
/
price.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
import { parseRec } from '../../src'
describe('parseRec', () => {
it('invalid symbols return null', () => {
expect(parseRec('')).toEqual(null)
expect(parseRec('FXSPTUSDAEDSPT:GBL.BIL.QTE.RTM')).toEqual(null)
expect(parseRec('FXSPTUSDAEDSPT!IC')).toEqual(null)
expect(parseRec('FXSPTUSDAEDSPT')).toEqual(null)
})
it('parses a forex spot symbol', () => {
expect(parseRec('FXSPTUSDAEDSPT:GBL.BIL.QTE.RTM!IC')).toEqual({
market: 'FXSPT',
base: 'USD',
quote: 'AED',
source: 'GBL',
stream: 'IC',
})
})
it('parses a metals spot symbol', () => {
expect(parseRec('CESPTUSDXPTSPT:GBL.BIL.QTE.RTM!TP')).toEqual({
market: 'CESPT',
base: 'USD',
quote: 'XPT',
source: 'GBL',
stream: 'TP',
})
})
it('parses a metals forward symbol', () => {
expect(parseRec('CEFWDXAUUSDSPT06M:LDN.BIL.QTE.RTM!TP')).toEqual({
market: 'CEFWD',
base: 'XAU',
quote: 'USD',
source: 'LDN',
stream: 'TP',
})
})
it('parses an overridden symbol', () => {
expect(parseRec('CEOILOTRWTSBOM:LDN.BIL.QTE.RTM!TP')).toEqual({
market: 'CEOIL',
base: 'WTI',
quote: 'USD',
source: 'LDN',
stream: 'TP',
})
})
})