UNPKG

llearn

Version:

Bad-ass developers create awesome apps

100 lines (88 loc) 3.39 kB
console.log("Starting helper_io.test.js..."); // helper_io.test.js // Purpose: The purpose of this.... // Date Created: 6/3/2018 // Created by : Perez Lamed van Niekerk // ------------------------------------------------------ /*jshint esversion: 6 */ const _log = console.log; const _JSONstr = (object) => JSON.stringify(object, undefined, 2); const _logJSON = (object) => console.log(_JSONstr(object)); // ------------------------------------------------------ // https://devhints.io/jest const _expect = require('expect'); // https://facebook.github.io/jest/docs/en/expect.html#expectvalue const _helper_io = require('../src/helper_io'); var path0 = __dirname.replace('\\test', '') ; /* root folder */ var path1 = path0 + "\\templates\\JSN\\about\\"; var path2 = path0 + "\\templates\\JSN\\"; var file = path0 + "\\templates\\JSN\\about\\about_startNewApp.js"; describe('helper_io.js', () => { describe('exist', () =>{ it("exist folder", (done) => { // _log({path1}); _helper_io.IO().exist(path1) .then(done()) .catch( () => { throw new Error(`Path '${path1}' does not exist.`) }); }); it("exist folder not", (done) => { _helper_io.IO().exist(path1+"2") .then( () =>{ throw new Error(`Path '${path1+"2"}' does exist.`) }) .catch((err) => {done()}); }); it("exist file", (done) => { _helper_io.IO().exist(file) .then(done()) .catch( () => { throw new Error(`Path '${path1}' does not exist.`) }); }); it("exist file not", (done) => { _helper_io.IO().exist(file+"2") .then( () =>{ throw new Error(`Path '${file+"2"}' does exist.`) }) .catch((err) => {done()}); }); it('exist package.json', (done) => { _helper_io.IO().exist('./package.json') .then(done()) .catch(() => { throw new Error(`Path '${path1}' does not exist.`) }); }); }); describe('readFile', () => { it('should read file package.json', (done) => { _helper_io.IO().readFile('./package.json') .then((text ) => { done(); }) .catch(() => {throw new Error(`Path '${path1+"2"}' does exist.`)}); }); }); describe('Folder', () => { it(path1, (done) => { _helper_io.IO().folderFiles(path1) .then((files) => { // _log({files}); _expect(files.length).toBeGreaterThan(0); done(); }) .catch((error) => {_log(error) }); }); it(path2, (done) => { _helper_io.IO().folderFolders(path2) .then((folders) => { _expect(folders.length).toBeGreaterThan(0); done(); }) .catch((error) => {_log(error) }); }); }); }); // Exports -------------------------- module.exports = {};