Skip to content

Commit 5e3d145

Browse files
committed
More tests
1 parent b167677 commit 5e3d145

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/Test-FileStore.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,22 @@ describe('FileStore', () => {
8686
});
8787

8888
describe('create', () => {
89+
const invalidReq = { headers: {}, url: STORE_PATH };
8990
const req = { headers: { 'upload-length': 1000 }, url: STORE_PATH };
9091

92+
it('should reject if both upload-length and upload-defer-length are not provided', () => {
93+
const file_store = new FileStore({ path: STORE_PATH });
94+
return file_store.create(invalidReq)
95+
.should.be.rejected();
96+
});
97+
98+
it('should reject when namingFunction is invalid', () => {
99+
const namingFunction = (incomingReq) => incomingReq.body.filename.replace(/\//g, '-');
100+
const file_store = new FileStore({ path: STORE_PATH, namingFunction });
101+
return file_store.create(req)
102+
.should.be.rejected();
103+
});
104+
91105
it('should reject when the directory doesnt exist', () => {
92106
const file_store = new FileStore({ path: STORE_PATH });
93107
file_store.directory = 'some_new_path';
@@ -116,6 +130,7 @@ describe('FileStore', () => {
116130
const file_store = new FileStore({ path: STORE_PATH, namingFunction });
117131
file_store.create(req)
118132
.then((newFile) => {
133+
assert.equal(newFile instanceof File, true);
119134
assert.equal(newFile.id, '-files');
120135
return done();
121136
})

0 commit comments

Comments
 (0)