You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
838 B

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