-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logic update and testing improvment (#3)
- Changed options for CLI call - Finished basic and downloader tests
- Loading branch information
Konstantin
committed
Aug 14, 2015
1 parent
8561c3a
commit 76d2f43
Showing
8 changed files
with
105 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ module.exports = { | |
|
||
return request.responseText; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,63 @@ | ||
var converter = require('../lib/converter'); | ||
var downloader = require('../lib/downloader'); | ||
var assert = require('assert'); | ||
var html2json = require("../index"); | ||
var exec = require('child_process').exec; | ||
|
||
|
||
describe('html2json command usage', function() { | ||
describe('html2json cli', function () { | ||
describe('html2json', function() { | ||
describe('CLI', function () { | ||
it('should display help topic', function(done) { | ||
exec('./index.js', function(error, stdout, stderr) { | ||
assert(stdout.indexOf('Usage:') > -1, "Don't found 'Usage' word in help topic"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should display output in console', function(done) { | ||
exec('./index.js https://google.com', function(error, stdout, stderr) { | ||
assert(stdout.indexOf('{') > -1, "Output don't appear in console, recieved: " + stdout); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should save response to file and display in console', function(done) { | ||
exec('rm output.json', function(error, stdout, stderr) { | ||
exec('./index.js -o output.json https://google.com', function(error, stdout, stderr) { | ||
exec("ls -lAh | grep output.json | cut -d' ' -f6", function(error, stdout, stderr) { | ||
assert.equal(stdout, '263\n', "Output file don't found or have incorrect size"); | ||
|
||
//Cleaning if assertion passed | ||
exec('rm output.json', function(error, stdout, stderr) { | ||
done(); | ||
}); | ||
}); | ||
assert(stdout.indexOf('{') > -1, "Output don't appear in console, recieved: " + stdout); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should save response to file', function(done) { | ||
exec('rm silent.json', function(error, stdout, stderr) { | ||
exec('./index.js -o silent.json -q https://google.com', function(error, stdout, stderr) { | ||
exec("ls -lAh | grep silent.json | cut -d' ' -f6", function(error, stdout, stderr) { | ||
assert.equal(stdout, '263\n', "Output file don't found or have incorrect size"); | ||
|
||
//Cleaning if assertion passed | ||
exec('rm silent.json', function(error, stdout, stderr) { | ||
done(); | ||
}); | ||
}); | ||
assert.equal(stdout, '', "Console output isn't empty"); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('integration', function() { | ||
it('should return parsed page', function() { | ||
|
||
var response = html2json.convertPage('https://google.com'); | ||
|
||
assert(response.indexOf('{') > -1, "Output don't appear in console, recieved: " + response); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters