-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
45 lines (34 loc) · 1.75 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
'use strict';
var os = require('os');
require('mocha');
var assert = require('assert');
var appendBuffer = require('./');
describe('appendBuffer', function() {
it('should append the buffer suffix to the buffer prefix with \\r\\n', function() {
assert.deepEqual(appendBuffer(new Buffer('abc\r\n'), new Buffer('def')), new Buffer('abc\r\ndef\r\n'));
});
it('should append the buffer suffix to the buffer prefix with \\n:', function() {
assert.deepEqual(appendBuffer(new Buffer('abc\n'), new Buffer('def')), new Buffer('abc\ndef\n'));
});
it('should append the buffer suffix to the buffer prefix without EOL', function() {
assert.deepEqual(appendBuffer(new Buffer('abc'), new Buffer('def')), new Buffer('abc' + os.EOL + 'def'));
});
it('should append the string suffix to the buffer prefix with \\r\\n', function() {
assert.deepEqual(appendBuffer(new Buffer('abc\r\n'), 'def'), new Buffer('abc\r\ndef\r\n'));
});
it('should append the string suffix to the buffer prefix with \\n:', function() {
assert.deepEqual(appendBuffer(new Buffer('abc\n'), 'def'), new Buffer('abc\ndef\n'));
});
it('should append the string suffix to the buffer prefix without EOL', function() {
assert.deepEqual(appendBuffer(new Buffer('abc'), 'def'), new Buffer('abc' + os.EOL + 'def'));
});
it('should not append EOL when suffix is empty', function() {
assert.deepEqual(appendBuffer(new Buffer('abc'), new Buffer('')), new Buffer('abc'));
});
it('should not append EOL when suffix is undefined', function() {
assert.deepEqual(appendBuffer(new Buffer('abc')), new Buffer('abc'));
});
it('should not append EOL when suffix is empty string', function() {
assert.deepEqual(appendBuffer(new Buffer('abc'), ''), new Buffer('abc'));
});
});