Skip to content

Commit

Permalink
Update fs.read.spec.js (#741)
Browse files Browse the repository at this point in the history
* Update fs.read.spec.js

* Update fs.read.spec.js
  • Loading branch information
ael-mas authored and humphd committed Feb 12, 2019
1 parent 9487e8e commit 7ab6f5e
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions tests/spec/fs.read.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
var util = require('../lib/test-utils.js');
var expect = require('chai').expect;
'use strict';
const util = require('../lib/test-utils.js');
const expect = require('chai').expect;

describe('fs.read', function() {
beforeEach(util.setup);
afterEach(util.cleanup);

it('should be a function', function() {
var fs = util.fs();
const fs = util.fs();
expect(fs.read).to.be.a('function');
});

it('should read data from a file', function(done) {
var fs = util.fs();
var wbuffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
var rbuffer = Buffer.alloc(wbuffer.length);
const fs = util.fs();
const wbuffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
const rbuffer = Buffer.alloc(wbuffer.length);

fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error;
Expand All @@ -33,10 +34,10 @@ describe('fs.read', function() {
});

it('should update the current file position', function(done) {
var fs = util.fs();
var wbuffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
var rbuffer = Buffer.alloc(wbuffer.length);
var _result = 0;
const fs = util.fs();
const wbuffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
const rbuffer = Buffer.alloc(wbuffer.length);
let _result = 0;

fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error;
Expand All @@ -63,9 +64,9 @@ describe('fs.read', function() {
});

it('should fail to read a directory', function(done) {
var fs = util.fs();
var buf = Buffer.alloc(20);
var buf2 = Buffer.alloc(20);
const fs = util.fs();
const buf = Buffer.alloc(20);
const buf2 = Buffer.alloc(20);

fs.mkdir('/mydir', function(error) {
if(error) throw error;
Expand All @@ -85,10 +86,10 @@ describe('fs.read', function() {
});

it('should fail to read a file that does not exist', function(done) {
var fs = util.fs();
const fs = util.fs();

var fd = 0;
var rbuffer = Buffer.alloc(8);
const fd = 0;
const rbuffer = Buffer.alloc(8);

fs.read(fd, rbuffer, 0, rbuffer.length, 0, function(error, result) {
expect(error).to.exist;
Expand Down

0 comments on commit 7ab6f5e

Please sign in to comment.