Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: improve test coverage of internal/blob
  • Loading branch information
kuriyosh committed Jan 14, 2022
commit 15b4cd40bdf897fe2fd3ee7405ed4ed928237494
30 changes: 30 additions & 0 deletions test/parallel/test-blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ assert.throws(() => new Blob({}), {
const b = new Blob();
assert.strictEqual(inspect(b, { depth: null }),
'Blob { size: 0, type: \'\' }');
assert.strictEqual(inspect(b, { depth: 1 }),
'Blob { size: 0, type: \'\' }');
assert.strictEqual(inspect(b, { depth: -1 }), '[Blob]');
}

Expand Down Expand Up @@ -228,8 +230,36 @@ assert.throws(() => new Blob({}), {
code: 'ERR_INVALID_ARG_VALUE',
});
});

assert.throws(() => new Blob([new Uint8Array(0xffffffff), [1]]), {
code: 'ERR_BUFFER_TOO_LARGE',
});
}

{
assert.throws(() => Reflect.get(Blob.prototype, 'type', {}), {
code: 'ERR_INVALID_THIS',
});
assert.throws(() => Reflect.get(Blob.prototype, 'size', {}), {
code: 'ERR_INVALID_THIS',
});
assert.throws(() => Blob.prototype.slice(Blob.prototype, 0, 1), {
code: 'ERR_INVALID_THIS',
});
assert.throws(() => Blob.prototype.stream.call(), {
code: 'ERR_INVALID_THIS',
});
}

(async () => {
assert.rejects(async () => Blob.prototype.arrayBuffer.call(), {
code: 'ERR_INVALID_THIS',
});
assert.rejects(async () => Blob.prototype.text.call(), {
code: 'ERR_INVALID_THIS',
});
})().then(common.mustCall());

(async () => {
const blob = new Blob([
new Uint8Array([0x50, 0x41, 0x53, 0x53]),
Expand Down