Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix using assert.include #252

Merged
merged 1 commit into from
Apr 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"aws-sdk-mock": "^1.6.1",
"chai": "^2.0.0",
"hoek": "^2.11.1",
"lodash": "^4.17.4",
"mocha": "",
"should": ""
},
Expand Down
49 changes: 21 additions & 28 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var program = require('commander');
var fs = require('fs-extra');
var Hoek = require('hoek');
var lambda = require(path.join(__dirname, '..', 'lib', 'main'));
var _ = require('lodash');
var zip = require('node-zip');
var rimraf = require('rimraf');

Expand Down Expand Up @@ -279,10 +278,7 @@ describe('node-lambda', function () {

lambda._npmInstall(program, codeDirectory, function (err, result) {
var contents = fs.readdirSync(codeDirectory);

result = _.includes(contents, 'node_modules');
assert.equal(result, true);

assert.include(contents, 'node_modules');
done();
});
});
Expand Down Expand Up @@ -364,12 +360,10 @@ describe('node-lambda', function () {

lambda._zip(program, codeDirectory, function (err, data) {
var archive = new zip(data);
var contents = _.map(archive.files, function (f) {
return f.name.toString();
var contents = Object.keys(archive.files).map(function (k) {
return archive.files[k].name.toString();
});
var result = _.includes(contents, 'index.js');
assert.equal(result, true);

assert.include(contents, 'index.js');
done();
});
});
Expand All @@ -381,13 +375,11 @@ describe('node-lambda', function () {

lambda._archive(program, function (err, data) {
var archive = new zip(data);
var contents = _.map(archive.files, function (f) {
return f.name.toString();
var contents = Object.keys(archive.files).map(function (k) {
return archive.files[k].name.toString();
});
var result = _.includes(contents, 'index.js');
assert.equal(result, true);
result = _.includes(contents, path.join('node_modules', 'async', 'lib', 'async.js'));
assert.equal(result, true);
assert.include(contents, 'index.js');
assert.include(contents, path.join('node_modules', 'async', 'lib', 'async.js'));
done();
});
});
Expand All @@ -408,13 +400,16 @@ describe('node-lambda', function () {
program.prebuiltDirectory = buildDir;
lambda._archive(program, function (err, data) {
var archive = new zip(data);
var contents = _.map(archive.files, function (f) {
return f.name.toString();
var contents = Object.keys(archive.files).map(function (k) {
return archive.files[k].name.toString();
});
[
'testa',
path.join('d', 'testb'),
path.join('node_modules', 'a')
].forEach(function (needle) {
assert.include(contents, needle, `Target: "${needle}"`);
});
var result = _.includes(contents, 'testa') &&
_.includes(contents, path.join('d', 'testb')) &&
_.includes(contents, path.join('node_modules', 'a'));
assert.equal(result, true);
done();
});
});
Expand Down Expand Up @@ -474,13 +469,11 @@ describe('node-lambda', function () {
lambda._archive(_program, function (err, data) {
// same test as "installs and zips with an index.js file and node_modules/async"
var archive = new zip(data);
var contents = _.map(archive.files, function (f) {
return f.name.toString();
var contents = Object.keys(archive.files).map(function (k) {
return archive.files[k].name.toString();
});
var result = _.includes(contents, 'index.js');
assert.equal(result, true);
result = _.includes(contents, path.join('node_modules', 'async', 'lib', 'async.js'));
assert.equal(result, true);
assert.include(contents, 'index.js');
assert.include(contents, path.join('node_modules', 'async', 'lib', 'async.js'));
done();
});
});
Expand Down