filer/tests/spec
Vladimir Rozin 5918cf6ae7 changed fs.watch.spec.js according to filed issue-666 (#680) 2019-01-31 14:12:08 -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 Add eslint --fix scripts, fix first round of lint errors 2018-07-15 13:25:35 -04:00
filer.buffer.spec.js Fix #547: update Buffer use, docs, tests to match node.js v11.3.0 2018-12-01 20:05:05 -05:00
filer.filesystem.spec.js Add eslint --fix scripts, fix first round of lint errors 2018-07-15 13:25:35 -04:00
filer.spec.js Add test API to shim indexedDB when necessary for better coverage 2019-01-03 00:08:22 -05:00
fs.access.spec.js Match node's layout for access modes on fs, with tests 2019-01-02 22:23:58 -05:00
fs.appendFile.spec.js Fix review nits, move contents to earlier scope and reuse. 2018-12-12 21:08:30 -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 Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -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 #568: switch all stats.type checks in tests/ to use is*() methods (#581) 2018-11-28 13:54:20 -05:00
fs.mkdtemp.spec.js Added mkdtemp method (issue #441) 2018-12-15 00:39:09 -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 Improve coverage: add test for rel paths with symlink 2018-11-29 16:57:06 -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 Move open files to its own module, properly close fds in tests 2018-12-29 15:11:39 -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 Support file:// URLs and Buffers for path args, throw when invalid 2019-01-02 19:46:36 -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 Support file:// URLs and Buffers for path args, throw when invalid 2019-01-02 19:46:36 -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 Issue #86: Added support for Unix Timestamps 2018-12-14 23:58:42 -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);
      });
  });
});