@infinito/id3
Version:
ID3 Tag Reader/Writer
34 lines (32 loc) • 1.37 kB
JavaScript
import assert from 'assert';
import setSyncSafe from '../src/set.syncsafe.js';
describe('setSyncSafe',function () {
it('should throw a TypeError when not given a Uint8Array for buf parameter', function () {
assert.throws(() => setSyncSafe(0,0,0,0),TypeError);
});
it('should throw a TypeError when not given a number for pos parameter', function () {
assert.throws(() => setSyncSafe(new Uint8Array(2),"",0,0),TypeError);
});
it('should throw a TypeError when not given a number for size parameter', function () {
assert.throws(() => setSyncSafe(new Uint8Array(2),0,"",0),TypeError);
});
it('should throw a TypeError when not given a number for bytes parameter', function () {
assert.throws(() => setSyncSafe(new Uint8Array(2),0,3,""),TypeError);
});
it('should set Uint8Array of length 4 to all zeroes when given (buf,0,0,4) as parameters', function () {
let buf = new Uint8Array(4);
let bench = new Uint8Array([0,0,0,0])
setSyncSafe(buf,0,0,4);
for(let i=0;i<4;i++) {
assert.strictEqual(buf[i],bench[i]);
}
});
it('should set Uint8Array of length 4 to [1,2,3,4] when given (buf,0,2130308,4) as parameters', function () {
let buf = new Uint8Array(4);
let bench = new Uint8Array([1,2,3,4])
setSyncSafe(buf,0,2130308,4);
for(let i=0;i<4;i++) {
assert.strictEqual(buf[i],bench[i]);
}
});
});