Debian Codegraph @

strip-bom-buf/test/test.js

raw
1 import fs from 'fs';
2 import path from 'path';
3 import test from 'ava';
4 import stripBomBuffer from '..';
5
6 test('strips BOM from UTF-8 buffer', t => {
7 const fixture = fs.readFileSync(path.join(__dirname, '/fixture-utf8'));
8 t.true(stripBomBuffer(fixture).equals(Buffer.from('Unicorn\n')));
9 });
10
11 test('doesn\'t strip anything that looks like a UTF-8-encoded BOM from UTF16LE', t => {
12 const fixture = fs.readFileSync(path.join(__dirname, 'fixture-utf16le'));
13 t.is(stripBomBuffer(fixture), fixture);
14 });
15
16 test('doesn\'t strip anything that looks like a UTF-8-encoded BOM from UTF16BE', t => {
17 const fixture = fs.readFileSync(path.join(__dirname, 'fixture-utf16be'));
18 t.is(stripBomBuffer(fixture), fixture);
19 });