arnaucube
arnaucube/comunicationLeapPublic Self-hosted repository
comunicationLeap/node_modules/formidable/test/unit/test-file.js
node_modules/formidable/test/unit/test-file.jsRaw
 1var common       = require('../common');
 2var test         = require('utest');
 3var assert       = common.assert;
 4var File = common.require('file');
 5
 6var file;
 7var now = new Date;
 8test('IncomingForm', {
 9  before: function() {
10    file = new File({
11      size: 1024,
12      path: '/tmp/cat.png',
13      name: 'cat.png',
14      type: 'image/png',
15      lastModifiedDate: now,
16      filename: 'cat.png',
17      mime: 'image/png'
18    })
19  },
20
21  '#toJSON()': function() {
22    var obj = file.toJSON();
23    var len = Object.keys(obj).length;
24    assert.equal(1024, obj.size);
25    assert.equal('/tmp/cat.png', obj.path);
26    assert.equal('cat.png', obj.name);
27    assert.equal('image/png', obj.type);
28    assert.equal('image/png', obj.mime);
29    assert.equal('cat.png', obj.filename);
30    assert.equal(now, obj.mtime);
31    assert.equal(len, 8);
32  }
33});