Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #681: Updated filer/tests/spec/filer.filesystem.spec.js #695

Merged
merged 3 commits into from Feb 1, 2019
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+56 −7
Diff settings

Always

Just for now

Copy path View file
@@ -0,0 +1,47 @@
'use strict';
const Filer = require('../../src');
const util = require('../lib/test-utils.js');
const expect = require('chai').expect;

describe('Filer.FileSystem - Issue 681', function() {
beforeEach(util.setup);
afterEach(util.cleanup);

it('should properly mount new or existing filesystem', function(done) {
let provider = util.provider().provider;

// 1) Should be able to open a new filesystem, and get empty root
let fs1 = new Filer.FileSystem({provider: provider}, function() {
fs1.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
expect(entries.length).to.equal(0);

fs1.writeFile('/file', 'data', function(err) {
if(err) throw err;

// 2) Should be able to open an existing filesystem
let fs2 = new Filer.FileSystem({provider: provider}, function() {
fs2.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
expect(entries.length).to.equal(1);
expect(entries[0]).to.equal('file');


// 3) FORMAT flag should wipe an existing filesystem
let fs3 = new Filer.FileSystem({provider: provider, flags: ['FORMAT']}, function() {
fs3.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
expect(entries.length).to.equal(0);
done();
});
});
});
});
});
});
});
});
});
Copy path View file
@@ -85,6 +85,7 @@ require('./bugs/issue267.js');
require('./bugs/issue270.js');
require('./bugs/rename-dir-trailing-slash.js');
require('./bugs/issue357.js');
require('./bugs/issue681.js');
This conversation was marked as resolved by woosle1234

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

You don't need to add a new file for this bug. You're updating the code in tests/spec/filer.filesystem.spec.js, which already exists, and you've addressed below. You can remove this and tests/bugs/issue681.js:

git rm tests/bugs/issue681.js
git checkout master tests/index.js

This will undo your changes.

This comment has been minimized.

Copy link
@woosle1234

woosle1234 Jan 31, 2019

Author Contributor

Removed file and require line


// Sample code from README
require('./spec/readme.example.spec');
@@ -1,16 +1,17 @@
var Filer = require('../../src');
var util = require('../lib/test-utils.js');
var expect = require('chai').expect;
'use strict';
const Filer = require('../../src');
const util = require('../lib/test-utils.js');
const expect = require('chai').expect;

describe('Filer.FileSystem', function() {
beforeEach(util.setup);
afterEach(util.cleanup);

it('should properly mount new or existing filesystem', function(done) {
var provider = util.provider().provider;
let provider = util.provider().provider;
This conversation was marked as resolved by woosle1234

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

This can be const since provider will never change.

This comment has been minimized.

Copy link
@woosle1234

woosle1234 Jan 31, 2019

Author Contributor

changed


// 1) Should be able to open a new filesystem, and get empty root
var fs1 = new Filer.FileSystem({provider: provider}, function() {
let fs1 = new Filer.FileSystem({provider: provider}, function() {
This conversation was marked as resolved by woosle1234

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

Same thing here, use const

This comment has been minimized.

Copy link
@woosle1234

woosle1234 Jan 31, 2019

Author Contributor

changed

fs1.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
@@ -20,7 +21,7 @@ describe('Filer.FileSystem', function() {
if(err) throw err;

// 2) Should be able to open an existing filesystem
var fs2 = new Filer.FileSystem({provider: provider}, function() {
let fs2 = new Filer.FileSystem({provider: provider}, function() {
This conversation was marked as resolved by woosle1234

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

const

This comment has been minimized.

Copy link
@woosle1234

woosle1234 Jan 31, 2019

Author Contributor

changed

fs2.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
@@ -29,7 +30,7 @@ describe('Filer.FileSystem', function() {


// 3) FORMAT flag should wipe an existing filesystem
var fs3 = new Filer.FileSystem({provider: provider, flags: ['FORMAT']}, function() {
let fs3 = new Filer.FileSystem({provider: provider, flags: ['FORMAT']}, function() {
This conversation was marked as resolved by woosle1234

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

const

This comment has been minimized.

Copy link
@woosle1234

woosle1234 Jan 31, 2019

Author Contributor

changed

fs3.readdir('/', function(err, entries) {
expect(err).not.to.exist;
expect(entries).to.be.an('array');
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.