|
2 | 2 | // the imports don't work. We need to fully switch to jest & set up ts support |
3 | 3 | // todo: fix tests. |
4 | 4 |
|
5 | | -// import { parseCSSShadow } from "@nativescript/core/ui/styling/css-shadow"; |
6 | | -// import { zeroLength } from "@nativescript/core"; |
| 5 | +import { parseCSSShadow } from '@nativescript/core/ui/styling/css-shadow'; |
| 6 | +import { zeroLength } from '@nativescript/core'; |
| 7 | +import { assert } from 'chai'; |
7 | 8 |
|
8 | | -// describe('ui', () => { |
9 | | -// describe('styling', () => { |
10 | | -// describe('css-shadow', () => { |
11 | | -// |
12 | | -// it("empty", () => { |
13 | | -// const shadow = parseCSSShadow("") |
14 | | -// expect(shadow.inset).toBe(false) |
15 | | -// expect(shadow.offsetX).toBe(zeroLength) |
16 | | -// expect(shadow.offsetY).toBe(zeroLength) |
17 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
18 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
19 | | -// expect(shadow.color).toBe('black') |
20 | | -// }); |
21 | | -// |
22 | | -// it("1px 1px 2px black", () => { |
23 | | -// const shadow = parseCSSShadow("1px 1px 2px black") |
24 | | -// expect(shadow.inset).toBe(false) |
25 | | -// expect(shadow.offsetX).toBe(1) |
26 | | -// expect(shadow.offsetY).toBe(1) |
27 | | -// expect(shadow.blurRadius).toBe(2) |
28 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
29 | | -// expect(shadow.color).toBe('black') |
30 | | -// }); |
31 | | -// |
32 | | -// it("#fc0 1px 0 10px", () => { |
33 | | -// const shadow = parseCSSShadow("#fc0 1px 0 10px") |
34 | | -// expect(shadow.inset).toBe(false) |
35 | | -// expect(shadow.offsetX).toBe(1) |
36 | | -// expect(shadow.offsetY).toBe(zeroLength) |
37 | | -// expect(shadow.blurRadius).toBe(10) |
38 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
39 | | -// expect(shadow.color).toBe('#fc0') |
40 | | -// }); |
41 | | -// |
42 | | -// it("5px 5px #558abb", () => { |
43 | | -// const shadow = parseCSSShadow("5px 5px #558abb") |
44 | | -// expect(shadow.inset).toBe(false) |
45 | | -// expect(shadow.offsetX).toBe(5) |
46 | | -// expect(shadow.offsetY).toBe(5) |
47 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
48 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
49 | | -// expect(shadow.color).toBe('#558abb') |
50 | | -// }); |
51 | | -// |
52 | | -// it("white 2px 5px", () => { |
53 | | -// const shadow = parseCSSShadow("white 2px 5px") |
54 | | -// expect(shadow.inset).toBe(false) |
55 | | -// expect(shadow.offsetX).toBe(2) |
56 | | -// expect(shadow.offsetY).toBe(5) |
57 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
58 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
59 | | -// expect(shadow.color).toBe('white') |
60 | | -// }); |
61 | | -// |
62 | | -// it("5px 10px", () => { |
63 | | -// const shadow = parseCSSShadow("5px 10px") |
64 | | -// expect(shadow.inset).toBe(false) |
65 | | -// expect(shadow.offsetX).toBe(5) |
66 | | -// expect(shadow.offsetY).toBe(10) |
67 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
68 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
69 | | -// expect(shadow.color).toBe('black') |
70 | | -// }); |
71 | | -// |
72 | | -// // box |
73 | | -// it("60px -16px teal", () => { |
74 | | -// const shadow = parseCSSShadow("60px -16px teal") |
75 | | -// expect(shadow.inset).toBe(false) |
76 | | -// expect(shadow.offsetX).toBe(60) |
77 | | -// expect(shadow.offsetY).toBe(-16) |
78 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
79 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
80 | | -// expect(shadow.color).toBe('teal') |
81 | | -// }); |
82 | | -// |
83 | | -// it("10px 5px 5px black", () => { |
84 | | -// const shadow = parseCSSShadow("10px 5px 5px black") |
85 | | -// expect(shadow.inset).toBe(false) |
86 | | -// expect(shadow.offsetX).toBe(10) |
87 | | -// expect(shadow.offsetY).toBe(5) |
88 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
89 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
90 | | -// expect(shadow.color).toBe('black') |
91 | | -// }); |
92 | | -// |
93 | | -// it("2px 2px 2px 1px rgba(0, 0, 0, 0.2)", () => { |
94 | | -// const shadow = parseCSSShadow("2px 2px 2px 1px rgba(0, 0, 0, 0.2)") |
95 | | -// expect(shadow.inset).toBe(false) |
96 | | -// expect(shadow.offsetX).toBe(2) |
97 | | -// expect(shadow.offsetY).toBe(2) |
98 | | -// expect(shadow.blurRadius).toBe(2) |
99 | | -// expect(shadow.spreadRadius).toBe(1) |
100 | | -// expect(shadow.color).toBe('rgba(0, 0, 0, 0.2)') |
101 | | -// }); |
102 | | -// |
103 | | -// it("inset 5em 1em gold", () => { |
104 | | -// const shadow = parseCSSShadow("inset 5em 1em gold") |
105 | | -// expect(shadow.inset).toBe(true) |
106 | | -// expect(shadow.offsetX).toBe(5) |
107 | | -// expect(shadow.offsetY).toBe(1) |
108 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
109 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
110 | | -// expect(shadow.color).toBe('gold') |
111 | | -// }); |
112 | | -// |
113 | | -// it("5 10", () => { |
114 | | -// const shadow = parseCSSShadow("5 10") |
115 | | -// expect(shadow.inset).toBe(false) |
116 | | -// expect(shadow.offsetX).toBe(5) |
117 | | -// expect(shadow.offsetY).toBe(10) |
118 | | -// expect(shadow.blurRadius).toBe(zeroLength) |
119 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
120 | | -// expect(shadow.color).toBe('black') |
121 | | -// }); |
122 | | -// |
123 | | -// it("2 2 2 #333", () => { |
124 | | -// const shadow = parseCSSShadow("2 2 2 #333") |
125 | | -// expect(shadow.inset).toBe(false) |
126 | | -// expect(shadow.offsetX).toBe(2) |
127 | | -// expect(shadow.offsetY).toBe(2) |
128 | | -// expect(shadow.blurRadius).toBe(2) |
129 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
130 | | -// expect(shadow.color).toBe('#333') |
131 | | -// }); |
132 | | -// |
133 | | -// it("-1 -1 1 #333", () => { |
134 | | -// const shadow = parseCSSShadow("-1 -1 1 #333") |
135 | | -// expect(shadow.inset).toBe(false) |
136 | | -// expect(shadow.offsetX).toBe(-1) |
137 | | -// expect(shadow.offsetY).toBe(-1) |
138 | | -// expect(shadow.blurRadius).toBe(1) |
139 | | -// expect(shadow.spreadRadius).toBe(zeroLength) |
140 | | -// expect(shadow.color).toBe('#333') |
141 | | -// }); |
142 | | -// }); |
143 | | -// }); |
144 | | -// }); |
145 | | -// |
| 9 | +describe('ui', () => { |
| 10 | + describe('styling', () => { |
| 11 | + describe('css-shadow', () => { |
| 12 | + it('empty', () => { |
| 13 | + const shadow = parseCSSShadow(''); |
| 14 | + // expect(shadow.inset).toBe(false) |
| 15 | + // expect(shadow.offsetX).toBe(zeroLength) |
| 16 | + // expect(shadow.offsetY).toBe(zeroLength) |
| 17 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 18 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 19 | + // expect(shadow.color).toBe('black') |
| 20 | + assert.equal(shadow.inset, false); |
| 21 | + }); |
| 22 | + |
| 23 | + // it("1px 1px 2px black", () => { |
| 24 | + // const shadow = parseCSSShadow("1px 1px 2px black") |
| 25 | + // expect(shadow.inset).toBe(false) |
| 26 | + // expect(shadow.offsetX).toBe(1) |
| 27 | + // expect(shadow.offsetY).toBe(1) |
| 28 | + // expect(shadow.blurRadius).toBe(2) |
| 29 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 30 | + // expect(shadow.color).toBe('black') |
| 31 | + // }); |
| 32 | + |
| 33 | + // it("#fc0 1px 0 10px", () => { |
| 34 | + // const shadow = parseCSSShadow("#fc0 1px 0 10px") |
| 35 | + // expect(shadow.inset).toBe(false) |
| 36 | + // expect(shadow.offsetX).toBe(1) |
| 37 | + // expect(shadow.offsetY).toBe(zeroLength) |
| 38 | + // expect(shadow.blurRadius).toBe(10) |
| 39 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 40 | + // expect(shadow.color).toBe('#fc0') |
| 41 | + // }); |
| 42 | + |
| 43 | + // it("5px 5px #558abb", () => { |
| 44 | + // const shadow = parseCSSShadow("5px 5px #558abb") |
| 45 | + // expect(shadow.inset).toBe(false) |
| 46 | + // expect(shadow.offsetX).toBe(5) |
| 47 | + // expect(shadow.offsetY).toBe(5) |
| 48 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 49 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 50 | + // expect(shadow.color).toBe('#558abb') |
| 51 | + // }); |
| 52 | + |
| 53 | + // it("white 2px 5px", () => { |
| 54 | + // const shadow = parseCSSShadow("white 2px 5px") |
| 55 | + // expect(shadow.inset).toBe(false) |
| 56 | + // expect(shadow.offsetX).toBe(2) |
| 57 | + // expect(shadow.offsetY).toBe(5) |
| 58 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 59 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 60 | + // expect(shadow.color).toBe('white') |
| 61 | + // }); |
| 62 | + |
| 63 | + // it("5px 10px", () => { |
| 64 | + // const shadow = parseCSSShadow("5px 10px") |
| 65 | + // expect(shadow.inset).toBe(false) |
| 66 | + // expect(shadow.offsetX).toBe(5) |
| 67 | + // expect(shadow.offsetY).toBe(10) |
| 68 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 69 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 70 | + // expect(shadow.color).toBe('black') |
| 71 | + // }); |
| 72 | + |
| 73 | + // // box |
| 74 | + // it("60px -16px teal", () => { |
| 75 | + // const shadow = parseCSSShadow("60px -16px teal") |
| 76 | + // expect(shadow.inset).toBe(false) |
| 77 | + // expect(shadow.offsetX).toBe(60) |
| 78 | + // expect(shadow.offsetY).toBe(-16) |
| 79 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 80 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 81 | + // expect(shadow.color).toBe('teal') |
| 82 | + // }); |
| 83 | + |
| 84 | + // it("10px 5px 5px black", () => { |
| 85 | + // const shadow = parseCSSShadow("10px 5px 5px black") |
| 86 | + // expect(shadow.inset).toBe(false) |
| 87 | + // expect(shadow.offsetX).toBe(10) |
| 88 | + // expect(shadow.offsetY).toBe(5) |
| 89 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 90 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 91 | + // expect(shadow.color).toBe('black') |
| 92 | + // }); |
| 93 | + |
| 94 | + // it("2px 2px 2px 1px rgba(0, 0, 0, 0.2)", () => { |
| 95 | + // const shadow = parseCSSShadow("2px 2px 2px 1px rgba(0, 0, 0, 0.2)") |
| 96 | + // expect(shadow.inset).toBe(false) |
| 97 | + // expect(shadow.offsetX).toBe(2) |
| 98 | + // expect(shadow.offsetY).toBe(2) |
| 99 | + // expect(shadow.blurRadius).toBe(2) |
| 100 | + // expect(shadow.spreadRadius).toBe(1) |
| 101 | + // expect(shadow.color).toBe('rgba(0, 0, 0, 0.2)') |
| 102 | + // }); |
| 103 | + |
| 104 | + // it("inset 5em 1em gold", () => { |
| 105 | + // const shadow = parseCSSShadow("inset 5em 1em gold") |
| 106 | + // expect(shadow.inset).toBe(true) |
| 107 | + // expect(shadow.offsetX).toBe(5) |
| 108 | + // expect(shadow.offsetY).toBe(1) |
| 109 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 110 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 111 | + // expect(shadow.color).toBe('gold') |
| 112 | + // }); |
| 113 | + |
| 114 | + // it("5 10", () => { |
| 115 | + // const shadow = parseCSSShadow("5 10") |
| 116 | + // expect(shadow.inset).toBe(false) |
| 117 | + // expect(shadow.offsetX).toBe(5) |
| 118 | + // expect(shadow.offsetY).toBe(10) |
| 119 | + // expect(shadow.blurRadius).toBe(zeroLength) |
| 120 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 121 | + // expect(shadow.color).toBe('black') |
| 122 | + // }); |
| 123 | + |
| 124 | + // it("2 2 2 #333", () => { |
| 125 | + // const shadow = parseCSSShadow("2 2 2 #333") |
| 126 | + // expect(shadow.inset).toBe(false) |
| 127 | + // expect(shadow.offsetX).toBe(2) |
| 128 | + // expect(shadow.offsetY).toBe(2) |
| 129 | + // expect(shadow.blurRadius).toBe(2) |
| 130 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 131 | + // expect(shadow.color).toBe('#333') |
| 132 | + // }); |
| 133 | + |
| 134 | + // it("-1 -1 1 #333", () => { |
| 135 | + // const shadow = parseCSSShadow("-1 -1 1 #333") |
| 136 | + // expect(shadow.inset).toBe(false) |
| 137 | + // expect(shadow.offsetX).toBe(-1) |
| 138 | + // expect(shadow.offsetY).toBe(-1) |
| 139 | + // expect(shadow.blurRadius).toBe(1) |
| 140 | + // expect(shadow.spreadRadius).toBe(zeroLength) |
| 141 | + // expect(shadow.color).toBe('#333') |
| 142 | + // }); |
| 143 | + }); |
| 144 | + }); |
| 145 | +}); |
0 commit comments