|
1 | 1 | /* eslint-env node, mocha */ |
| 2 | + |
2 | 3 | 'use strict'; |
3 | 4 |
|
4 | 5 | const assert = require('assert'); |
5 | 6 | const should = require('should'); |
6 | 7 | const File = require('../lib/models/File'); |
| 8 | +const Uid = require('../lib/models/Uid'); |
7 | 9 |
|
8 | 10 | describe('File', () => { |
9 | 11 |
|
10 | 12 | describe('constructor', () => { |
11 | | - it('must be given either a upload_length or upload_defer_length', (done) => { |
| 13 | + it('must require a file_name', () => { |
12 | 14 | assert.throws(() => { new File(); }, Error); |
13 | | - done(); |
14 | 15 | }); |
15 | 16 |
|
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(); |
| 17 | + it('must be given either a upload_length or upload_defer_length', () => { |
| 18 | + assert.throws(() => { new File(Uid.rand()); }, Error); |
21 | 19 | }); |
22 | 20 |
|
23 | | - it('should set properties given', (done) => { |
| 21 | + it('should set properties given', () => { |
| 22 | + const file_id = Uid.rand(); |
24 | 23 | const upload_length = 1234; |
25 | 24 | const upload_defer_length = 1; |
26 | 25 | const upload_metadata = 'metadata'; |
27 | | - const file = new File(upload_length, upload_defer_length, upload_metadata); |
| 26 | + const file = new File(file_id, upload_length, upload_defer_length, upload_metadata); |
| 27 | + assert.equal(file.id, file_id); |
28 | 28 | assert.equal(file.upload_length, upload_length); |
29 | 29 | assert.equal(file.upload_defer_length, upload_defer_length); |
30 | 30 | assert.equal(file.upload_metadata, upload_metadata); |
31 | | - done(); |
32 | 31 | }); |
33 | 32 | }); |
34 | 33 | }); |
0 commit comments