Skip to content

Commit

Permalink
Add a few Lesshint fs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Jan 28, 2017
1 parent 80d62f4 commit f0535dc
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/specs/lesshint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

const expect = require('chai').expect;
const rimraf = require('rimraf');
const path = require('path');
const fs = require('fs');

describe('lesshint', function () {
const testDir = path.join(path.dirname(__dirname), '/data/files');
Expand Down Expand Up @@ -110,6 +112,23 @@ describe('lesshint', function () {
expect(result).to.have.length(3);
});
});

it('should reject on inaccessible paths', function () {
const lesshint = new Lesshint();

lesshint.configure();

const filePath = testDir + '/tmp.less';

fs.writeFileSync(filePath, '');
fs.chmodSync(filePath, 222); // Don't allow read access

return lesshint.checkDirectory(filePath).catch(function (err) {
expect(err).to.be.an.instanceof(Error);

rimraf(filePath, function () {});
});
});
});

describe('checkFile', function () {
Expand All @@ -122,6 +141,23 @@ describe('lesshint', function () {
expect(result).to.have.length(1);
});
});

it('should reject on inaccessible files', function () {
const lesshint = new Lesshint();

lesshint.configure();

const filePath = testDir + '/tmp.less';

fs.writeFileSync(filePath, '');
fs.chmodSync(filePath, 222); // Don't allow read access

return lesshint.checkFile(filePath).catch(function (err) {
expect(err).to.be.an.instanceof(Error);

rimraf(filePath, function () {});
});
});
});

describe('checkPath', function () {
Expand Down Expand Up @@ -162,6 +198,23 @@ describe('lesshint', function () {
expect(result).to.have.length(0);
});
});

it('should reject on inaccessible paths', function () {
const lesshint = new Lesshint();

lesshint.configure();

const filePath = testDir + '/tmp.less';

fs.writeFileSync(filePath, '');
fs.chmodSync(filePath, 222); // Don't allow read access

return lesshint.checkPath(filePath).catch(function (err) {
expect(err).to.be.an.instanceof(Error);

rimraf(filePath, function () {});
});
});
});

describe('checkString', function () {
Expand Down

0 comments on commit f0535dc

Please sign in to comment.