Skip to content

Commit 8733373

Browse files
committed
test: customAttributes, issue #36
1 parent 33f6cc7 commit 8733373

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

test/plugin.js

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test('name gen', t => {
9090
</body>
9191
</html>
9292
`;
93-
return posthtml().use(plugin({ filter })).process(html)
93+
return posthtml().use(plugin({filter})).process(html)
9494
.then(result => {
9595
t.is(result.html, expected);
9696
});
@@ -184,7 +184,7 @@ test('emoji name gen', t => {
184184
</body>
185185
</html>
186186
`;
187-
return posthtml().use(plugin({ filter, genNameClass: 'genNameEmoji', genNameId: 'genNameEmoji' })).process(html)
187+
return posthtml().use(plugin({filter, genNameClass: 'genNameEmoji', genNameId: 'genNameEmoji'})).process(html)
188188
.then(result => {
189189
t.is(result.html, expected);
190190
});
@@ -278,7 +278,7 @@ test('emoji string name gen', t => {
278278
</body>
279279
</html>
280280
`;
281-
return posthtml().use(plugin({ filter, genNameClass: 'genNameEmojiString', genNameId: 'genNameEmojiString' })).process(html)
281+
return posthtml().use(plugin({filter, genNameClass: 'genNameEmojiString', genNameId: 'genNameEmojiString'})).process(html)
282282
.then(result => {
283283
t.is(result.html, expected);
284284
});
@@ -372,14 +372,14 @@ test('ignored pattern should not affect use#href', t => {
372372
</body>
373373
</html>
374374
`;
375-
return posthtml().use(plugin({ filter })).process(html)
375+
return posthtml().use(plugin({filter})).process(html)
376376
.then(result => {
377377
t.is(result.html, expected);
378378
});
379379
});
380380

381381
test('should work with xlink:href and href', t => {
382-
const filter = /^#icon-/;
382+
const filter = /^#icon-/;
383383
const html = `
384384
<style>
385385
#icon-location {
@@ -418,7 +418,7 @@ const filter = /^#icon-/;
418418
<use xlink:href="#icon-location"></use>
419419
</svg>
420420
`;
421-
return posthtml().use(plugin({ filter })).process(html)
421+
return posthtml().use(plugin({filter})).process(html)
422422
.then(result => {
423423
t.is(result.html, expected);
424424
});
@@ -502,7 +502,7 @@ test('ignore ids', t => {
502502
</body>
503503
</html>
504504
`;
505-
return posthtml().use(plugin({ filter, genNameId: false })).process(html)
505+
return posthtml().use(plugin({filter, genNameId: false})).process(html)
506506
.then(result => {
507507
t.is(result.html, expected);
508508
});
@@ -586,7 +586,7 @@ test('ignore classes', t => {
586586
</body>
587587
</html>
588588
`;
589-
return posthtml().use(plugin({ filter, genNameClass: false })).process(html)
589+
return posthtml().use(plugin({filter, genNameClass: false})).process(html)
590590
.then(result => {
591591
t.is(result.html, expected);
592592
});
@@ -719,7 +719,56 @@ test('strips unnecessary whitespaces when removing classes that do not match any
719719
`;
720720

721721
return posthtml().use(plugin()).process(html)
722-
.then(result => {
723-
t.is(result.html, expected);
724-
});
722+
.then(result => {
723+
t.is(result.html, expected);
724+
});
725+
});
726+
727+
test('Custom attribute names that will be involved in the process #36', t => {
728+
const html = `
729+
<html>
730+
<style>
731+
.baz {
732+
color: blue;
733+
}
734+
.biz {
735+
color: green;
736+
}
737+
.buz {
738+
color: red;
739+
}
740+
</style>
741+
<body>
742+
<div
743+
x-transition:enter="baz"
744+
x-transition:enter-start="biz"
745+
x-transition:enter-end="buz"
746+
>customAttributes</div>
747+
</body>
748+
</html>
749+
`;
750+
751+
const expected = `
752+
<html>
753+
<style>
754+
.a {
755+
color: blue;
756+
}
757+
.b {
758+
color: green;
759+
}
760+
.c {
761+
color: red;
762+
}
763+
</style>
764+
<body>
765+
<div x-transition:enter="a" x-transition:enter-start="b" x-transition:enter-end="buz">customAttributes</div>
766+
</body>
767+
</html>
768+
`;
769+
770+
return posthtml().use(plugin({customAttributes: ['x-transition:enter', 'x-transition:enter-start']})).process(html)
771+
.then(result => {
772+
t.is(result.html, expected);
773+
});
725774
});

0 commit comments

Comments
 (0)