-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
104 lines (96 loc) · 2.44 KB
/
test.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var assert = require('assert');
var posthtml = require('posthtml');
var m = require('./');
var test = function(input, output, opts, done) {
posthtml()
.use(m(opts))
.process(input)
.then(function(result) {
assert.equal(result.html, output);
done();
})
.catch(function(err) {
done(err);
});
};
it('Standard test', function(done) {
test(
'<input type="text" class="form-control" name="testInput" autofocus autocomplete="off" id="testId">',
'<input class="form-control" id="testId" name="testInput" type="text" autofocus autocomplete="off">',
{},
done
);
});
it('Angular test', function(done) {
test(
'<a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}" alt="{{phone.name}}"></a>',
'<a class="thumb" href="#/phones/{{phone.id}}"><img ng-src="{{phone.imageUrl}}" alt="{{phone.name}}"></a>',
{},
done
);
});
it('Aria test', function(done) {
test(
'<span onclick="return checkBoxEvent(event);" role="checkbox" aria-checked="mixed">A checkbox label</span>',
'<span role="checkbox" aria-checked="mixed" onclick="return checkBoxEvent(event);">A checkbox label</span>',
{},
done
);
});
it('Custom config test', function(done) {
test(
'<a id="testId" href="#" class="testClass"></a>',
'<a href="#" id="testId" class="testClass"></a>',
{
order: ['href', 'id', 'class']
},
done
);
});
it('Empty config test', function(done) {
test(
'<a id="testId" href="#" class="testClass"></a>',
'<a id="testId" href="#" class="testClass"></a>',
{
order: []
},
done
);
});
it('Custom config bug (issue #12)', function(done) {
test(
'<img width="20" src="../images/image.png" height="40" alt="image" class="cls" id="id2">',
'<img id="id2" class="cls" src="../images/image.png" width="20" height="40" alt="image">',
{
order: [
'id',
'class',
'src',
'width',
'height',
'for',
'type',
'href',
'title',
'alt',
'value'
]
},
done
);
});
it('Put unsorted in specific location', function(done) {
test(
'<img width="20" src="../images/image.png" height="40" alt="image" class="cls" id="id2">',
'<img src="../images/image.png" id="id2" width="20" height="40" alt="image" class="cls">',
{
order: [
'src',
'id',
'$unknown$',
'class'
]
},
done
);
});