index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var co = require('co');
  2. var fs = require('..');
  3. var assert = require('assert');
  4. describe('.exists()', function(){
  5. it('should work', function(done){
  6. co(function *(){
  7. var ret = yield fs.exists('test/fixtures/msg.txt');
  8. assert(true === ret);
  9. var ret = yield fs.exists('test/fixtures');
  10. assert(true === ret);
  11. var ret = yield fs.exists('test/fixtures/hey');
  12. assert(false === ret);
  13. })(done);
  14. })
  15. })
  16. describe('.createReadStream()', function(){
  17. it('should work', function(done){
  18. co(function *(){
  19. var read = fs.createReadStream('test/fixtures/msg.txt');
  20. assert('hello\n' == (yield read()).toString());
  21. })(done);
  22. })
  23. })
  24. describe('others', function(){
  25. it('should be wrapped', function(done){
  26. co(function *(){
  27. var ret = yield fs.stat('test/fixtures/msg.txt');
  28. assert(ret.size);
  29. var ret = yield fs.readFile('test/fixtures/msg.txt');
  30. assert(Buffer.isBuffer(ret));
  31. var ret = yield fs.readFile('test/fixtures/msg.txt', 'utf8');
  32. assert('hello\n' == ret);
  33. })(done);
  34. })
  35. })