-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
42 lines (36 loc) · 1.32 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
(function () {
'use strict';
var assert = require('assert');
var Vinyl = require('vinyl');
var gulpRtlcss = require('./index');
const strigfy = (str) => {
return str
.replace(/(\r\n|\n|\r)/gm, '')
.replace(/ /g, '')
}
it('should convert LTR CSS to RTL', function (cb) {
var stream = gulpRtlcss();
stream.on('data', function (file) {
assert.equal(strigfy(file.contents.toString()), strigfy('[dir="ltr"] .selector { float: left; } [dir="rtl"] .selector { float: right; }'));
cb();
});
stream.write(new Vinyl({
path: 'styles.css',
contents: Buffer.from('.selector { float: left; /* comment */ }')
}));
});
it('should accept rtlcss configuration', function (cb) {
var stream = gulpRtlcss({
ltrPrefix: '[lang="latin"]',
rtlPrefix: '[lang="arabic"]'
});
stream.on('data', function (file) {
assert.equal(strigfy(file.contents.toString()), strigfy('[lang="latin"] .selector { float: left; } [lang="arabic"] .selector { float: right; }'));
cb();
});
stream.write(new Vinyl({
path: 'styles.css',
contents: Buffer.from(".selector { float: left; /* comment */ }")
}));
});
})();