forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabelMixedStyleSpec.js
More file actions
55 lines (52 loc) · 2.44 KB
/
LabelMixedStyleSpec.js
File metadata and controls
55 lines (52 loc) · 2.44 KB
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
import {LabelMixedTextStyle} from '../../../src/common/iServer/LabelMixedTextStyle';
import {ServerTextStyle} from '../../../src/common/iServer/ServerTextStyle';
import {ServerColor} from '../../../src/common/iServer/ServerColor';
describe('LabelMixedTextStyle', () => {
it('constructor, destroy', () => {
var options = {
defaultStyle: new ServerTextStyle(),
//文本的分隔符
separator: "",
separatorEnabled: false,
splitIndexes: [1, 3, 4, 9],
styles: [
new ServerTextStyle({backColor: new ServerColor(250, 105, 25)}),
new ServerTextStyle({backColor: new ServerColor(150, 105, 25)}),
new ServerTextStyle({backColor: new ServerColor(105, 105, 25)}),
new ServerTextStyle({backColor: new ServerColor(25, 105, 25)})
]
};
var labelMixedTextStyle = new LabelMixedTextStyle(options);
expect(labelMixedTextStyle).not.toBeNull();
expect(labelMixedTextStyle.defaultStyle).not.toBeNull();
expect(labelMixedTextStyle.separatorEnabled).toBeFalsy();
expect(labelMixedTextStyle.splitIndexes.length).toEqual(4);
expect(labelMixedTextStyle.splitIndexes[0]).toEqual(1);
expect(labelMixedTextStyle.splitIndexes[1]).toEqual(3);
expect(labelMixedTextStyle.splitIndexes[2]).toEqual(4);
expect(labelMixedTextStyle.splitIndexes[3]).toEqual(9);
expect(labelMixedTextStyle.styles.length).toEqual(4);
labelMixedTextStyle.destroy();
expect(labelMixedTextStyle.defaultStyle).toBeNull();
expect(labelMixedTextStyle.separatorEnabled).toBeNull();
expect(labelMixedTextStyle.splitIndexes).toBeNull();
expect(labelMixedTextStyle.styles).toBeNull();
});
it('fromJson', () => {
var obj = {
text: "this is a test",
styles: [
{backColor: new ServerColor(250, 105, 25)}
]
};
var newStyle = LabelMixedTextStyle.fromObj(obj);
expect(newStyle).not.toBeNull();
expect(newStyle.styles.length).toEqual(1);
expect(newStyle.styles[0].backColor.blue).toEqual(25);
expect(newStyle.styles[0].backColor.green).toEqual(105);
expect(newStyle.styles[0].backColor.red).toEqual(250);
//没有参数obj时,自动return
var result = LabelMixedTextStyle.fromObj();
expect(result).toBeUndefined();
});
});