-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathelement.spec.ts
35 lines (34 loc) · 1.58 KB
/
element.spec.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
import { hyphenateCssProperty } from '../src/dom/UniCSSStyleDeclaration'
import { UniElement } from '../src/dom/UniElement'
describe('uni-mp-vue: UniElement', () => {
it('UniCSSStyleDeclaration', () => {
const element = new UniElement()
element.style['color'] = 'red'
expect(element.style['color']).toBe('red')
expect(element.style.getPropertyValue('color')).toBe('red')
expect(element.style.cssText).toBe('color:red;')
element.style.setProperty('color', 'blue')
expect(element.style['color']).toBe('blue')
expect(element.style.getPropertyValue('color')).toBe('blue')
expect(element.style.cssText).toBe('color:blue;')
element.style.setProperty('margin-top', '10px')
expect(element.style['margin-top']).toBe('10px')
expect(element.style.getPropertyValue('margin-top')).toBe('10px')
expect(element.style.cssText).toBe('color:blue;margin-top:10px;')
element.style.setProperty('marginBottom', '10px')
expect(element.style['marginBottom']).toBe('10px')
expect(element.style.getPropertyValue('marginBottom')).toBe('10px')
expect(element.style['margin-bottom']).toBe('10px')
expect(element.style.getPropertyValue('margin-bottom')).toBe('10px')
expect(element.style.cssText).toBe(
'color:blue;margin-top:10px;margin-bottom:10px;'
)
})
it('hyphenateCssProperty', () => {
expect(hyphenateCssProperty('WebkitTransform')).toBe('-webkit-transform')
expect(hyphenateCssProperty('WebkitTransitionOpacity')).toBe(
'-webkit-transition-opacity'
)
expect(hyphenateCssProperty('marginTop')).toBe('margin-top')
})
})