Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: updated child process so that it no longer has to compare scree…
…nshots, I have moved this functionality into its own process called compare-screenshots
- Loading branch information
matthewmacartney
committed
Sep 9, 2016
1 parent
6b68a7b
commit 238f228
Showing
9 changed files
with
121 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module.exports = function (currentDirectory) { | ||
|
||
const store = require('./store'); | ||
const inquirer = require('inquirer'); | ||
|
||
var questions = [{ | ||
type: 'list', | ||
name: 'screenShotType', | ||
message: 'Would you like to run Reference or Test screenshots?', | ||
choices: [ 'Reference', 'Test', 'Exit' ], | ||
default: 'Reference' | ||
}]; | ||
|
||
function init () { | ||
askQuestion(); | ||
} | ||
|
||
function handleChange() { | ||
var completed = store.getState()[0].completed; | ||
if (completed === false || completed === undefined) return; | ||
askQuestion(); | ||
} | ||
|
||
function askQuestion () { | ||
inquirer.prompt(questions).then(function (answers) { | ||
if (answers.screenShotType === 'Exit') return; | ||
sendQuestionResultToStore(answers.screenShotType); | ||
}); | ||
} | ||
|
||
function sendQuestionResultToStore (answer) { | ||
store.dispatch({ | ||
type: 'APP', | ||
answer: answer, | ||
completed: false | ||
}); | ||
} | ||
|
||
init(); | ||
|
||
store.subscribe(handleChange); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module.exports = function (currentDirectory) { | ||
|
||
const fs = require('fs'); | ||
const store = require('./store'); | ||
const colors = require('colors'); | ||
|
||
const message = { | ||
passed: 'Passed - ', | ||
failed: 'Failed - ', | ||
}; | ||
|
||
var obj = { | ||
test: { | ||
folder: currentDirectory + '/ocular/screenshots/reference/', | ||
base64: '' | ||
}, | ||
reference: { | ||
folder: currentDirectory + '/ocular/screenshots/test/', | ||
base64: '' | ||
} | ||
} | ||
|
||
function init () { | ||
getBase64Data('test'); | ||
getBase64Data('reference'); | ||
compareReferenceAndTestBase64(); | ||
} | ||
|
||
function getBase64Path (folder) { | ||
var str = screenshotName.replace(/\s+/g, ''); | ||
return `${folder}${str}.txt`; | ||
} | ||
|
||
function getBase64Data (type) { | ||
var folderName = obj[type].folder; | ||
|
||
fs.readFile(getBase64Path(folderName), 'utf8', function (error, data) { | ||
if (error) return; | ||
obj[type].base64 = data; | ||
}); | ||
} | ||
|
||
function compareReferenceAndTestBase64 () { | ||
var successMessage = message.passed + screenshotName; | ||
var failedMessage = message.failed + screenshotName; | ||
|
||
if (obj.test.base64 === obj.reference.base64) { | ||
console.log(successMessage.green); | ||
return; | ||
} | ||
|
||
console.log(failedMessage.red); | ||
} | ||
|
||
function handleChange () { | ||
screenshotName = store.getState()[0].name; | ||
if (screenshotName === undefined) return; | ||
init(); | ||
} | ||
|
||
store.subscribe(handleChange); | ||
}; |
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,40 +1,5 @@ | ||
module.exports = function (currentDirectory) { | ||
|
||
const store = require('./store'); | ||
const cli = require('./cli')(currentDirectory); | ||
const process = require('./process')(currentDirectory); | ||
const inquirer = require('inquirer'); | ||
const fs = require('fs'); | ||
|
||
var questions = [{ | ||
type: 'list', | ||
name: 'screenShotType', | ||
message: 'Would you like to run Reference or Test screenshots?', | ||
choices: [ 'Reference', 'Test', 'Exit' ], | ||
default: 'Reference' | ||
}]; | ||
|
||
function askQuestion () { | ||
inquirer.prompt(questions).then(function (answers) { | ||
if (answers.screenShotType === 'Exit') return; | ||
sendQuestionResultToStore(answers.screenShotType); | ||
}); | ||
} | ||
|
||
function sendQuestionResultToStore (answer) { | ||
store.dispatch({ | ||
type: 'APP', | ||
answer: answer, | ||
completed: false | ||
}); | ||
} | ||
|
||
function handleChange() { | ||
var completed = store.getState()[0].completed; | ||
if (completed === false) return; | ||
askQuestion(); | ||
} | ||
|
||
askQuestion(); | ||
|
||
store.subscribe(handleChange); | ||
const compareScreenshots = require('./compare-screenshots')(currentDirectory); | ||
} |
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