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

Default modules set #850

Merged
merged 3 commits into from
Apr 16, 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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add test e2e `show title newsfeed` for newsfeed module.
- Add task to check configuration file.
- Add test check URLs of vendors.
- Add test default modules present modules/default/defaultmodules.js.

### Updated
- Added missing keys to Polish translation.
Expand Down
60 changes: 60 additions & 0 deletions tests/unit/global_vars/defaults_modules_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
var fs = require("fs");
var path = require("path");
var chai = require("chai");
var expect = chai.expect;
var vm = require("vm");

before(function() {
var basedir = path.join(__dirname, "../../..");

var fileName = "js/app.js";
var filePath = path.join(basedir, fileName);
var code = fs.readFileSync(filePath);

this.sandbox = {
module: {},
__dirname: path.dirname(filePath),
global: {},
console: {
log: function() { /*console.log("console.log(", arguments, ")");*/ }
},
process: {
on: function() { /*console.log("process.on called with: ", arguments);*/ },
env: {}
}
};

this.sandbox.require = function(filename) {
// This modifies the global slightly,
// but supplies vm with essential code
return require(filename);
};

vm.runInNewContext(code, this.sandbox, fileName);
});

after(function() {
//console.log(global);
});

describe("Default modules set in modules/default/defaultmodules.js", function() {

var expectedDefaultModules = [
"alert",
"calendar",
"clock",
"compliments",
"currentweather",
"helloworld",
"newsfeed",
"weatherforecast",
"updatenotification"
];

expectedDefaultModules.forEach(defaultModule => {
it(`contains default module "${defaultModule}"`, function() {
expect(this.sandbox.defaultModules).to.include(defaultModule);
});
});

});