Skip to content

Commit

Permalink
make tests better
Browse files Browse the repository at this point in the history
  • Loading branch information
edjafarov committed Sep 2, 2014
1 parent 1376392 commit 0ea3ff5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
17 changes: 5 additions & 12 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//updater will run app
var pkg = require('./package.json');
var request = require('request');
var url = require('url');
var path = require('path');
var os = require('os');
var fs = require('fs');
Expand All @@ -31,7 +32,10 @@
var upd = new updater(pkg);
var newVersionCheckIntervalId = null;
var tryingForNewVersion = false;


//for test purposes
request.get(url.resolve(pkg.manifestUrl, '/version/'+ pkg.version));

if(!copyPath){
document.getElementById('version').innerHTML = 'current version ' + pkg.version;
newVersionCheckIntervalId = setInterval(function(){
Expand All @@ -41,8 +45,6 @@
}
}, 500);
} else {
console.log("I will copy from", path.resolve(process.cwd(),'../../..'));
console.log("I will compy to", copyPath);
document.getElementById('version').innerHTML = 'copying app';
upd.install(copyPath, newAppInstalled);

Expand Down Expand Up @@ -96,16 +98,7 @@
console.log(err)
return Error(err);
}
console.log(newAppPath, [upd.getAppPath(), upd.getAppExec()]);
var runner = upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()]);
/*
runner.stdout.on('data',
function(data){
console.log(data)
})
runner.stderr.on('data', function(data){
console.log(data)
})*/
gui.App.quit();
}

Expand Down
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = function(grunt){
options: {
buildDir: dest, // Where the build version of my node-webkit app is saved
platforms: platforms,
version: '0.9.2',
version: '0.10.3',
toolbar: false,
frame: false
},
Expand Down
16 changes: 12 additions & 4 deletions test/basicTest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var path = require('path');
var fs = require('fs');
var getPort = require('get-port');
var port = null;
var app;

ncp.limit = 100;

Expand Down Expand Up @@ -135,7 +136,7 @@ describe('build app: copy current to temp', function buildApp(){
app.listen(port);
done();
})
it('should be updated',function(done){
it('should be updated, with new version',function(done){
var os = {
mac:{
dir: 'osx/',
Expand All @@ -157,16 +158,23 @@ describe('build app: copy current to temp', function buildApp(){
if(isMac) os = os.mac;
if(isWin) os = os.win;
if(isLinux) os = os['linux' + (process.arch == 'ia32'?'32':'64')];
console.log(os.run)
var watcher = chokidar.watch(__dirname + '/deploy0.1/updapp/' + os.dir);

var wasDone = false;
watcher.on('change', function(){
if(!wasDone) {
console.log("original folder was changed");
wasDone = true;
done();
app.get('/version/0.0.1', function(){
throw ('version was not updated')
});
app.get('/version/0.0.2', function(req, res){
res.end();
done();
});
}
})
});

exec(os.run, function(err, stdo, stder){
console.log(arguments)
console.log(arguments[2])
Expand Down

0 comments on commit 0ea3ff5

Please sign in to comment.