UNPKG

bw-cli

Version:

The Brightwork (bw) command line deployment tool. Build & deploy serverless RESTful APIs in minutes.

77 lines (51 loc) 1.8 kB
'use strict'; var expect = require('chai').expect; var compress = require('../bw-compress.js'); var path = require('path'); var testData_path = path.join(path.resolve('./'), '/spec/stubs/zipTestData'); var tempFolder = path.join(path.resolve('./'), '/.tmp'); var code_folder = path.join(tempFolder, 'compressed'); var compressed_path = path.join(tempFolder, 'compressed.tar.gz'); var fs = require('fs'); describe('compress', function(){ describe('copy', function () { it('exists', function () { expect(compress.copy).to.be.a('function'); }); it('does should create the tmp folder and with only js and yml files', function (done) { compress.copy(testData_path).then(function(){ var dirList = fs.readdirSync(process.cwd()); expect(dirList).to.include('.tmp'); var subDir = fs.readdirSync(code_folder); expect(subDir).to.not.include('sample.html'); expect(subDir).to.include('sample.js'); expect(subDir).to.include('manifest.yml'); expect(subDir).to.include('index.js'); done(); }); }); }); describe('zip', function () { 'use strict'; it('exists', function () { expect(compress.zip).to.be.a('function'); }); it('does should create a tar stream', function (done) { compress.zip().then(function(stream){ expect(fs.existsSync(compressed_path)).to.be.true; done(); }); }); }); describe('cleanup', function () { 'use strict'; it('exists', function () { expect(compress.clean).to.be.a('function'); }); it('does should delete the tmp folder and files', function () { compress.clean(); var list = fs.readdirSync(process.cwd()); expect(list).to.not.include('.tmp'); }); }); });