Skip to content

Commit

Permalink
test: use instance of to assert error
Browse files Browse the repository at this point in the history
We toThrow expect Error intance, but BaseError is not
inheriting from it.
  • Loading branch information
freaz committed Nov 15, 2022
1 parent 9d1aac6 commit f6c9936
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/node/filesystem/binary.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { readFile } from 'fs/promises';
import { join as joinPath } from 'path';

import { NotFoundError } from '../../core';
import { UnexpectedError } from '../../lib';
import { BinaryFile } from './binary.node';

const path = joinPath('fixtures', 'binary.txt');
Expand Down Expand Up @@ -75,10 +76,9 @@ describe('BinaryFile class', () => {
});

// This test is fucked up for no damn reason?!
// IT MAKES NO SENSE WHAT AM I DOING WRONG
it('should throw an error if trying to get all data from a file that is not initialized', async () => {
const differentBinaryFile = new BinaryFile(path);
await expect(differentBinaryFile.getAllData()).rejects.toThrow();
await expect(differentBinaryFile.getAllData()).rejects.toBeInstanceOf(UnexpectedError);
});
});

Expand Down
1 change: 0 additions & 1 deletion src/node/filesystem/binary.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export class BinaryFile

public async getAllData(): Promise<Buffer | string> {
if (this.handle === undefined) {
console.log('throwing');
throw new UnexpectedError('File is not open');
}

Expand Down

0 comments on commit f6c9936

Please sign in to comment.