Skip to content

Commit

Permalink
fix: PersistentFile.toString() doesn't throw (#796)
Browse files Browse the repository at this point in the history
* fix: PersistentFile.toString() doesn't throw

* add test
  • Loading branch information
pedroslopez committed Dec 6, 2021
1 parent 5706c14 commit 8355c64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PersistentFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PersistentFile extends EventEmitter {
}

toString() {
return `PersistentFile: ${this._file.newFilename}, Original: ${this._file.originalFilename}, Path: ${this._file.filepath}`;
return `PersistentFile: ${this.newFilename}, Original: ${this.originalFilename}, Path: ${this.filepath}`;
}

write(buffer, cb) {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/persistent-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const file = new PersistentFile({
type: 'image/png',
lastModifiedDate: now,
originalFilename: 'cat.png',
newFilename: 'dff1d2eaab9752165764dcd00',
mimetype: 'image/png',
});

Expand All @@ -31,6 +32,11 @@ describe('PersistentFile', () => {
expect(obj.originalFilename).toBe('cat.png');
});

test('toString()', () => {
const result = file.toString();
expect(result).toBe('PersistentFile: dff1d2eaab9752165764dcd00, Original: cat.png, Path: /tmp/cat.png')
});

test('destroy()', () => {
file.open();
file.destroy();
Expand Down

0 comments on commit 8355c64

Please sign in to comment.