Skip to content

Commit 6811fff

Browse files
committed
test: More ignores.
1 parent 5b52419 commit 6811fff

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/io/event-stream.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function readableStream<T>(func: (stream: any, i: number) => Promise<T |
3535

3636
function get(err?: Error, data: T | null = null) {
3737

38+
/* istanbul ignore if */
3839
if (err) {
3940
stream.emit('error', err);
4041
if (!continueOnError) {

lib/io/ole-doc.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class Header {
6262
public static load(buffer: Buffer): Header {
6363
const header = new Header();
6464
for (let i = 0; i < 8; i++) {
65+
/* istanbul ignore if */
6566
if (header.oleId[i] !== buffer[i]) {
6667
throw new Error(`Doesn't look like a valid compound document (wrong ID, 0x${header.oleId[i].toString(16)} must be equal to 0x${buffer[i].toString(16)}).`);
6768
}
@@ -238,6 +239,7 @@ export class Storage {
238239
}
239240

240241
public storage(storageName: string): Storage {
242+
/* istanbul ignore if */
241243
if (!this.dirEntry.storages[storageName]) {
242244
throw new Error(`No such storage "${storageName}".`);
243245
}
@@ -282,6 +284,7 @@ export class Storage {
282284
offset = 0;
283285
return buffer;
284286

287+
/* istanbul ignore next */
285288
} catch (err) {
286289
stream.emit('error', err);
287290
stream.emit('end');
@@ -318,6 +321,7 @@ export class Storage {
318321
*/
319322
public async streamFiltered<T>(streamName: string, offset: number, next: (data: ReadResult) => Promise<number | null>): Promise<void> {
320323
const streamEntry = this.dirEntry.streams[streamName];
324+
/* istanbul ignore if */
321325
if (!streamEntry) {
322326
throw new Error('No such stream "' + streamName + '" in document.');
323327
}
@@ -366,6 +370,7 @@ export class Storage {
366370
// read missing sectors
367371
const remainingLen = -len - resultBuffer.length;
368372
const numSecs = Math.ceil(remainingLen / secSize);
373+
/* istanbul ignore if */
369374
if (remainingLen > bytes - storageOffset) {
370375
throw new Error(`Cannot read ${remainingLen} bytes when only ${bytes - storageOffset} remain in stream.`);
371376
}
@@ -407,6 +412,7 @@ export class Storage {
407412
return new Promise<Buffer>((resolve, reject) => {
408413
const strm = this.stream(key, offset, bytesToRead);
409414
const bufs: Buffer[] = [];
415+
/* istanbul ignore if */
410416
if (!strm) {
411417
return reject(new Error('No such stream "' + key + '".'));
412418
}
@@ -455,6 +461,7 @@ export class OleCompoundDoc extends EventEmitter {
455461
return doc;
456462
}
457463

464+
/* istanbul ignore next: Don't currently need this (at all) */
458465
public async readWithCustomHeader(size: number): Promise<Buffer> {
459466
this.skipBytes = size;
460467
await this.openFile();
@@ -477,10 +484,10 @@ export class OleCompoundDoc extends EventEmitter {
477484
return this.rootStorage.storage(storageName);
478485
}
479486

480-
public stream(streamName: string, offset: number = 0, len: number = -1) {
481-
this.assertLoaded();
482-
return this.rootStorage.stream(streamName, offset, len);
483-
}
487+
// public stream(streamName: string, offset: number = 0, len: number = -1) {
488+
// this.assertLoaded();
489+
// return this.rootStorage.stream(streamName, offset, len);
490+
// }
484491

485492
public async readSector(secId: number, offset: number = 0, bytesToRead: number = 0) {
486493
this.assertLoaded();
@@ -553,6 +560,7 @@ export class OleCompoundDoc extends EventEmitter {
553560
}
554561

555562
private assertLoaded() {
563+
/* istanbul ignore if */
556564
if (!this.fd) {
557565
throw new Error('Document must be loaded first.');
558566
}
@@ -615,6 +623,7 @@ export class OleCompoundDoc extends EventEmitter {
615623

616624
private async readSSAT(): Promise<void> {
617625
const secIds = this.SAT.getSecIdChain(this.header.SSATSecId);
626+
/* istanbul ignore if */
618627
if (secIds.length !== this.header.SSATSize) {
619628
throw new Error('Invalid Short Sector Allocation Table');
620629
}
@@ -649,6 +658,7 @@ export class OleCompoundDoc extends EventEmitter {
649658
private async read(buffer: Buffer, offset: number, length: number, position: number): Promise<[ number, Buffer ]> {
650659
return new Promise((resolve, reject) => {
651660
read(this.fd, buffer, offset, length, position, (err, bytesRead, data) => {
661+
/* istanbul ignore if */
652662
if (err) {
653663
reject(err);
654664
return;

0 commit comments

Comments
 (0)