Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
testOptions.forEach(options => {
const { source } = options;
const classname = safePrintType(source);
it(`can slice a ${classname}`, async () => {
const stream = new SlicerStream({ ...options, outputSize });
const output: Array = [];
stream.on('data', (data) => { output.push(data); });
const testPromise = new Promise((resolve, reject) => {
stream.on('error', reject);
stream.on('end', () => {
try {
expect(output).to.have.lengthOf(Math.ceil(bytes.length / outputSize));
output.forEach((chunk, index) => {
expect(chunk).to.be.an.instanceOf(Uint8Array);
expect(chunk).to.deep.equal(bytes.subarray(index * outputSize, (index + 1) * outputSize));
});