Skip to content

Commit 3dc6089

Browse files
author
Evan You
committed
unit test for utils.attr()
1 parent 2c0d8a4 commit 3dc6089

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/unit/specs/utils.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@ describe('UNIT: Utils', function () {
1111

1212
})
1313

14+
describe('attr', function () {
15+
16+
var el = document.createElement('div')
17+
el.setAttribute('sd-transition-class', 'test')
18+
19+
it('should append the prefix and return the attribute value', function () {
20+
var val = utils.attr(el, 'transition-class')
21+
assert.strictEqual(val, 'test')
22+
})
23+
24+
it('should remove the attribute', function () {
25+
assert.notOk(el.hasAttribute('sd-transition-class'))
26+
})
27+
28+
it('should work with different prefix', function () {
29+
30+
Seed.config({ prefix: 'test' })
31+
32+
var el = document.createElement('div')
33+
el.setAttribute('test-transition-class', 'test')
34+
var val = utils.attr(el, 'transition-class')
35+
assert.strictEqual(val, 'test')
36+
assert.notOk(el.hasAttribute('test-transition-class'))
37+
38+
Seed.config({ prefix: 'sd' })
39+
})
40+
41+
})
42+
1443
describe('defProtected', function () {
1544

1645
it('should define a protected property', function () {

0 commit comments

Comments
 (0)