Newer
Older
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
import * as util from 'common/util'
import { getRgb } from './layerCtrl.util'
describe('> layerCtrl.util.ts', () => {
describe('> #getRgb', () => {
let strToRgbSpy: jasmine.Spy
let strToRgbValue: [number, number, number]
beforeEach(() => {
strToRgbSpy = spyOn(util, 'strToRgb')
strToRgbValue = [1,2,3]
strToRgbSpy.and.returnValue(strToRgbValue)
})
describe('> region has rgb defined', () => {
const labelIndex = 1020
const region = {
ngId: 'foo-bar',
rgb: [100, 200, 255] as [number, number, number]
}
it('> should return region rgb', () => {
expect(
getRgb(labelIndex, region)
).toEqual({
red: 100,
green: 200,
blue: 255
})
})
})
describe('> if region does not have rgb defined', () => {
describe('> if labelIndex > 65500', () => {
const region = {
ngId: 'foo-bar',
}
const labelIndex = 65535
it('> should return white', () => {
expect(
getRgb(labelIndex, region)
).toEqual({
red: 255,
green: 255,
blue: 255
})
})
})
describe('> otherwise', () => {
const region = {
ngId: 'foo-bar',
}
const labelIndex = 12
it('> should call strToRgb', () => {
getRgb(labelIndex, region)
expect(strToRgbSpy).toHaveBeenCalledWith(`${region.ngId}${labelIndex}`)
})
it('> returns what strToRgb returns', () => {
expect(
getRgb(labelIndex, region)
).toEqual({
red: 1,
green: 2,
blue: 3
})
})
})
})
})
})