Fix for the 'start' range of BlobDataItem when reading its stream (#85)

Set default value for 'start' option
This commit is contained in:
Nick K
2021-04-26 12:06:27 +02:00
committed by GitHub
parent cc929f3714
commit 483973cf25
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ class BlobDataItem {
constructor(options) {
this.size = options.size;
this.path = options.path;
this.start = options.start;
this.start = options.start || 0;
this.mtime = options.mtime;
}
+9
View File
@@ -163,6 +163,15 @@ test('Reading after modified should fail', async t => {
t.is(error.name, 'NotReadableError');
});
test('Reading from the stream created by blobFrom', async t => {
const blob = blobFrom('./LICENSE');
const expected = await fs.promises.readFile('./LICENSE', 'utf-8');
const actual = await getStream(blob.stream());
t.is(actual, expected);
});
test('Blob-ish class is an instance of Blob', t => {
class File {
stream() {}