Skip to content

Commit 4b5ec2f

Browse files
author
Ben Stahl
committed
Finish tests for File
1 parent 8607abe commit 4b5ec2f

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

test/Test-File.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
/* eslint-env node, mocha */
12
'use strict';
3+
24
const assert = require('assert');
35
const should = require('should');
46
const File = require('../lib/models/File');
5-
const Uid = require('../lib/models/Uid');
67

78
describe('File', () => {
8-
it('should have an ID', (done) => {
9-
const file = new File(1);
10-
file.should.have.property('id');
11-
assert.equal(typeof file.id, 'string');
12-
done();
9+
10+
describe('constructor', () => {
11+
it('must be given either a upload_length or upload_defer_length', (done) => {
12+
assert.throws(() => { new File(); }, Error);
13+
done();
14+
});
15+
16+
it('should generate an the ID for the file', (done) => {
17+
const file = new File(1);
18+
file.should.have.property('id');
19+
assert.equal(typeof file.id, 'string');
20+
done();
21+
});
22+
23+
it('should set properties given', (done) => {
24+
const upload_length = 1234;
25+
const upload_defer_length = 1;
26+
const upload_metadata = 'metadata';
27+
const file = new File(upload_length, upload_defer_length, upload_metadata);
28+
assert.equal(file.upload_length, upload_length);
29+
assert.equal(file.upload_defer_length, upload_defer_length);
30+
assert.equal(file.upload_metadata, upload_metadata);
31+
done();
32+
});
1333
});
1434
});

0 commit comments

Comments
 (0)