filer/tests/spec
Ben Heidemann 3e88aeca92
Fix issue #766: Remove describe.only from shim tests (#767)
* test: replace describe.only in shim tests with describes so all tests run

* test: move require chai to top of file for consistency with other tests

* chore: npm install

* test: replace describe.only in shim tests with describes so all tests run

* test: move require chai to top of file for consistency with other tests

* chore: npm install

* Revert "chore: npm install"

This reverts commit cddeef421b.

* Revert "test: move require chai to top of file for consistency with other tests"

This reverts commit 40df7912fb.
2021-03-21 13:57:34 -04: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 resolve relative paths, add two test cases 2020-04-13 11:49:46 -04:00
shims Fix issue #766: Remove describe.only from shim tests (#767) 2021-03-21 13:57:34 -04: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 #710: updated let to const. 2019-02-15 15:04:04 -05: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 Issue #715 Update fs.lstat.spec.js to have proper const and let instead of var and added 'use strict' (#727) 2019-02-12 14:49:20 -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 add test for fs.open with wx flag for existing file (#745) 2019-02-27 11:56:11 -05:00
fs.read.spec.js Update fs.read.spec.js (#741) 2019-02-12 16:44:21 -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 added test to fs.readlink.spec.js 2019-02-26 12:06:41 -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 Issue 728: Updated 'filer/tests/spec/fs.shell.spec.js' to use 'const/let' instead of 'var' (#730) 2019-02-12 14:50:57 -05:00
fs.spec.js Update fs.spec.js to use strict mode and changed var to let (#693) 2019-02-12 14:46:56 -05:00
fs.stat.spec.js fixed #738: consolidated stats into stat tests (#743) 2019-02-23 16:42:51 -05:00
fs.symlink.spec.js fs.lstat should return a Stats object including mode 2019-02-07 22:51:52 -05:00
fs.truncate.spec.js Fix#418-updated method 2018-12-14 19:24:55 -05:00
fs.unlink.spec.js changes made as requested 2019-02-08 11:32:27 -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 Issue 627 (#746) 2019-03-12 15:12:38 -04:00
fs.writeFile-readFile.spec.js Updated file for issue #714 (#732) 2019-02-08 15:00:45 -05:00
fs.xattr.spec.js [Issue 734] 2019-02-08 05:46:54 -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 Addressed Issue #703 (#711) 2019-03-05 15:46:23 -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);
      });
  });
});