-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
75 lines (53 loc) · 2.07 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
'use strict';
var chai = require('chai');
var assert = chai.assert;
var File = require('vinyl');
var accents = require('./');
function processFile(process, contents, callback) {
var file = new File({
contents: Buffer.from(contents)
});
process.write(file);
process.once('data', function (file) {
assert.isTrue(file.isBuffer());
callback(file);
});
}
describe('gulp-html-accents unit tests', function () {
var input = '<p>Olá! Tudo bem com você?</p>';
it('module exports a function', function () {
assert.typeOf(accents, 'function');
});
it('encode using default options', function (done) {
var expectedOutput = '<p>Olá! Tudo bem com você?</p>';
processFile(accents(), input, function (file) {
var processedOutput = file.contents.toString('utf8');
assert.equal(processedOutput, expectedOutput);
done();
});
});
it('encode unsafe HTML characters', function (done) {
var expectedOutput = '<p>Olá! Tudo bem com você?</p>';
processFile(accents({ allowUnsafeSymbols: false }), input, function (file) {
var processedOutput = file.contents.toString('utf8');
assert.equal(processedOutput, expectedOutput);
done();
});
});
it('encode using name references when possible', function (done) {
var expectedOutput = '<p>Olá! Tudo bem com você?</p>';
processFile(accents({ useNamedReferences: true }), input, function (file) {
var processedOutput = file.contents.toString('utf8');
assert.equal(processedOutput, expectedOutput);
done();
});
});
it('encode every character', function (done) {
var expectedOutput = '<p>Olá! Tudo bem com você?</p>';
processFile(accents({ encodeEverything: true }), input, function (file) {
var processedOutput = file.contents.toString('utf8');
assert.equal(processedOutput, expectedOutput);
done();
});
});
});