serverless/lib/utils/fs/readFileIfExists.test.js
Mariusz Nowak 4944f471b1
Prettify
2019-06-26 12:43:01 +02:00

23 lines
723 B
JavaScript

'use strict';
const path = require('path');
const chai = require('chai');
const readFileIfExists = require('./readFileIfExists');
// Configure chai
chai.use(require('chai-as-promised'));
chai.use(require('sinon-chai'));
const expect = require('chai').expect;
describe('#readFileIfExists()', () => {
it('should resolve with file content if file exists', () =>
readFileIfExists(__filename).then(content => {
expect(content).to.not.equal(false);
expect(content).to.not.equal(undefined);
expect(typeof content).to.equal('string');
}));
it('should resolve with false if file does not exist', () =>
expect(readFileIfExists(path.join(__dirname, 'XYZ.json'))).to.eventually.equal(false));
});