filer/tests/spec
David Humphrey 8a2e64f9ea Fix #736: use ms vs. s resolution on all times 2019-02-07 16:36:17 -05:00
..
node-js/simple Support file:// URLs and Buffers for path args, throw when invalid 2019-01-02 19:46:36 -05:00
providers Remove WebSQL provider (last supported in v0.0.44) 2019-01-02 13:22:51 -05:00
shell Issue #86: Added support for Unix Timestamps 2018-12-14 23:58:42 -05:00
errors.spec.js Update errors.spec.js (#718) 2019-02-05 13:51:29 -05:00
filer.buffer.spec.js Fix Issue 684: Replace var with const, let in filer/tests/spec/filer.buffer.spec.js (#697) 2019-02-01 12:45:54 -05:00
filer.filesystem.spec.js Fix issue #681: Updated filer/tests/spec/filer.filesystem.spec.js (#695) 2019-01-31 20:23:57 -05:00
filer.spec.js 'Use strict' @top and updated the file with const/let [issue-702] (#726) 2019-02-05 13:46:58 -05:00
fs.access.spec.js Fixed #665: Replaced var with let or const and added strict mode fs.a… (#688) 2019-01-31 16:08:19 -05:00
fs.appendFile.spec.js Fixed #708: Added 'use strict' and replaced var with let/const in fs.appendFile.spec.js (#713) 2019-01-31 18:42:50 -05:00
fs.chmod.spec.js Fixes Issue#674: Refactored var declarations to const or let declarations to address i… (#676) 2019-01-31 14:00:48 -05:00
fs.chown.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
fs.close.spec.js code refactoring, added strict mode (#704) 2019-01-31 15:25:57 -05:00
fs.copyFile.spec.js Adding more tests for fs.copyFile 2018-12-17 16:18:06 -05:00
fs.exists.spec.js Fix issue #475 - Add test for fs.exits() when resulting path of a symbolic link is not found (#519) 2018-10-09 14:31:15 -04:00
fs.fsync.spec.js Update docs, fix test failure 2018-12-02 00:05:57 -05:00
fs.ftruncate.spec.js fix #635: added test for fs.ftruncate() 2018-12-20 15:07:17 -05:00
fs.link.spec.js Fix review issues 2018-12-12 21:31:27 -05:00
fs.lseek.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
fs.lstat.spec.js Fix #514: add test for fsPromises.lstat with directory 2018-12-17 16:30:21 -05:00
fs.mkdir.spec.js Fix issue #672 : Refactor "filer/tests/spec/fs.mkdir.spec.js" to follow ES6 syntax with "const/let" instead of "var" (#722) 2019-02-05 14:20:48 -05:00
fs.mkdtemp.spec.js Issue-686 - rfs.mkdtemp.spec.js (#717) 2019-02-05 13:58:01 -05:00
fs.mknod.spec.js Fix #568: switch all stats.type checks in tests/ to use is*() methods (#581) 2018-11-28 13:54:20 -05:00
fs.open.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
fs.read.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
fs.readdir.spec.js Fixed #667: Replaced var with const and added strict mode in fs.readdir.spec.js (#675) 2019-01-31 14:07:31 -05:00
fs.readlink.spec.js Fix issue #660: Updated the code to replace var with let, const in strict mode (#694) 2019-01-31 15:11:07 -05:00
fs.rename.spec.js Issue 417 - Added test for fs.promises.rename to rename existing directory (#460) 2018-10-16 11:07:10 -04:00
fs.rmdir.spec.js Fix lint issues in #521 2018-12-14 22:18:25 -05:00
fs.shell.spec.js Fixes #422: Add nyc lcov-based code coverage for tests (#565) 2018-11-28 19:24:03 -05:00
fs.spec.js Fix #568: switch all stats.type checks in tests/ to use is*() methods (#581) 2018-11-28 13:54:20 -05:00
fs.stat.spec.js Fix #736: use ms vs. s resolution on all times 2019-02-07 16:36:17 -05:00
fs.stats.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
fs.symlink.spec.js Fixes #661: replaced var with const (#669) 2019-01-31 13:52:39 -05:00
fs.truncate.spec.js Fix#418-updated method 2018-12-14 19:24:55 -05:00
fs.unlink.spec.js Fix #431: add test for fsPromises.unlink 2018-12-12 20:59:41 -05:00
fs.unwatchFile.spec.js Included unwatchFile in test index.js 2018-12-17 16:39:44 -05:00
fs.utimes.spec.js Issue #86: Added support for Unix Timestamps 2018-12-14 23:58:42 -05:00
fs.watch.spec.js changed fs.watch.spec.js according to filed issue-666 (#680) 2019-01-31 14:12:08 -05:00
fs.write.spec.js fixes issue #667 (#678) 2019-02-01 20:53:12 -05:00
fs.writeFile-readFile.spec.js Fix #547: update Buffer use, docs, tests to match node.js v11.3.0 2018-12-01 20:05:05 -05:00
fs.xattr.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
path-resolution.spec.js Fixed #699 Replacing var with let/const and adding strict mode (#706) 2019-01-31 16:42:38 -05:00
readme.example.spec.js Add Filer.fs to support creating a filesystem like node.js (#651) 2019-01-02 21:21:25 -05:00
time-flags.spec.js Fix ssue #692: Update code in filer/tests/spec/time-flags.spec.js (#696) 2019-02-01 15:04:15 -05:00
times.spec.js Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -05:00
trailing-slashes.spec.js Update package.json + tests/ to support browser property for bundlers, delete old useless tests for AMD 2018-07-14 10:53:23 -04:00

readme.example.spec.js

const { path } = require('../../src');
var util = require('../lib/test-utils.js');
var expect = require('chai').expect;

describe('README example code', function() {
  beforeEach(util.setup);
  afterEach(util.cleanup);

  it('should run the code in the README overview example', function(done) {
    // Slightly modified version of the first example code in the README
    // See <a name="overviewExample"></a>
    const fs = util.fs();

    fs.mkdir('/docs', (err) => {
      if (err) throw err;
      
      const filename = path.join('/docs', 'first.txt');
      const data = 'Hello World!\n';
    
      fs.writeFile(filename, data, (err) => {
        if (err) throw err;
    
        fs.stat(filename, (err, stats) => {
          if (err) throw err;
          expect(stats.size).to.equal(data.length);
          done();
        });
      });
    });
  });

  it('should run the fsPromises example code', function() {
    const fs = util.fs().promises;
    const filename = '/myfile';
    const data = 'some data';

    return fs.writeFile(filename, data)
      .then(() => fs.stat(filename))
      .then(stats => { 
        expect(stats.size).to.equal(data.length);
      });
  });
});