Skip to content

Commit fa1a58c

Browse files
committed
ADD: test for rawVal as Array
1 parent e1b3e7d commit fa1a58c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,12 @@ line-height: 24px;
11961196
})
11971197

11981198
it('normal nested rule', function() {
1199-
var ret = cssobj({
1199+
1200+
var ret = _cssobj({
1201+
plugins: {value: function(val, key) {
1202+
return key==='width'? val*2 : val
1203+
}}
1204+
})({
12001205
h3:{
12011206
p:{color:123}
12021207
},
@@ -1211,11 +1216,15 @@ line-height: 24px;
12111216

12121217
expect(h3.selText).equal('h3')
12131218
expect(h3.children.p.selText).equal('h3 p')
1219+
expect(h3.children.p.rawVal).deep.equal({"color":[123]})
12141220
expect(h3.children.p.prop).deep.equal({"color":[123]})
12151221
expect(Object.keys(h3)).deep.equal(["parent", "src", "key", "selPart", "obj", "prevVal", "children", "lastVal", "rawVal", "prop", "diff", "parentRule", "selText", "selTextPart", "selChild"])
12161222

12171223
expect(h4.selText).equal('h3,h4')
1218-
expect(h4.prop).deep.equal({width: [10]})
1224+
// rawVal is value array before any plugins
1225+
expect(h4.rawVal).deep.equal({width: [10]})
1226+
// prop is value array after plugins
1227+
expect(h4.prop).deep.equal({width: [20]})
12191228
expect(h4.children['p,span'].selText).equal('h3 p,h3 span,h4 p,h4 span')
12201229
expect(h4.children['p,span'].prop).deep.equal({"color":[234]})
12211230
expect(Object.keys(h4)).deep.equal(["parent", "src", "key", "selPart", "obj", "prevVal", "children", "lastVal", "rawVal", "prop", "diff", "parentRule", "selText", "selTextPart", "selChild"])

0 commit comments

Comments
 (0)