Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Issue #114 testing locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Anis Kadri committed Feb 22, 2016
1 parent 2b745b0 commit 0809bca
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"author": "Adobe PhoneGap Team",
"license": "APL",
"scripts": {
"test": "jasmine-node --color spec"
"test": "jasmine-node --color spec",
"paramedic": "./tests/scripts/start-server.sh && cordova-paramedic --platform ios && ./tests/scripts/stop-server.sh"
},
"devDependencies": {
"jasmine-node": "1.14.5"
Expand Down
Binary file added tests/archives/www1.zip
Binary file not shown.
Binary file added tests/archives/www2.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/scripts/start-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../archives && python -m "SimpleHTTPServer" 4321 &
1 change: 1 addition & 0 deletions tests/scripts/stop-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ps aux | grep -e "python -m SimpleHTTPServer" | grep -v grep | awk '{print "kill -1 " $2}' | sh
13 changes: 7 additions & 6 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,36 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;

var progressEvent = null;
var url = "https://github.com/timkim/zipTest/archive/master.zip";
//var url = "http://localhost:4321/www1.zip";
var sync = ContentSync.sync({ src: url, id: 'myapps/myapp', type: 'replace', copyCordovaAssets: false, headers: false });

sync.on('progress', function(progress) {
//console.log("in progress callback " + Object.getOwnPropertyNames(progress));
console.log("onProgress :: " + progress.progress + " status = " + progress.status);
//console.log("onProgress :: " + progress.progress + " status = " + progress.status);
if(!progressEvent) {
progressEvent = progress;
}
});

sync.on('complete', function(data) {
console.log("progress = " + progressEvent);
//console.log("progress = " + progressEvent);
expect(progressEvent).toBeDefined("Progress should have been received");

console.log("progressEvent.status = " + progressEvent.status);
//console.log("progressEvent.status = " + progressEvent.status);
expect(progressEvent.status).toBeDefined("Progress event should have a status prop");

expect(progressEvent.progress).toBeDefined("Progress event should have a progress prop");
console.log("progressEvent.progress = " + progressEvent.progress);
//console.log("progressEvent.progress = " + progressEvent.progress);

console.log("data = " + data);
//console.log("data = " + data);
expect(data).toBeDefined("On complete, data is not null");
done();
});

sync.on('error', function (e) {
expect(progressEvent).toBeDefined("Progress should have been received");
expect(e).toBe(null, "Error callback was called :: " + e);
console.log("got error back :: " + e);
//console.log("got error back :: " + e);
done();
});

Expand Down

0 comments on commit 0809bca

Please sign in to comment.