Skip to content

Commit

Permalink
PR feedback: created constant for color, added space; renamed method
Browse files Browse the repository at this point in the history
Consistent indentation in util file
Renamed copy to string for more familiar international speakers
  • Loading branch information
rfreitas committed Apr 30, 2019
1 parent d3067c1 commit 9bb9fe3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
17 changes: 9 additions & 8 deletions test/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import config from './config.json'
import Mocha from 'mocha'
import {createBrowserStackLocal,stopBrowserstackLocal} from './utils/browserstack'
import {eachP,asyncForEach} from './utils/async'
import {spawnP, spawnPrinter} from './utils/misc'
import {spawnP, spawnPrinter, SHELL_COLOR_BLUE} from './utils/misc'
import {exec} from 'child_process'

// Input capabilities
Expand Down Expand Up @@ -103,12 +103,13 @@ const runner = async () => {
const rubyTestSpawn = (command, args, options={}, optionCallback) =>
spawnP(command, args, {cwd: __dirname+"/../",...options}, optionCallback)

const rubyTestPrinter = outFilter => spawnPrinter("\x1b[34m", {
prefix:"Ruby:",
...(outFilter && {filter:outFilter})
},
"Ruby Error:"
)
const rubyTestPrinter = outFilter =>
spawnPrinter(SHELL_COLOR_BLUE, {
prefix:"Ruby:",
...(outFilter && {filter:outFilter})
},
"Ruby Error:"
)

await rubyTestSpawn('bundle', ['install'], {
env: {...process.env, GIT_SSH_COMMAND: process.env.CI === "true" ? "ssh -i ~/.ssh/monster_rsa" : ""}
Expand Down Expand Up @@ -152,7 +153,7 @@ const runner = async () => {

try {
const result = await rubyTestPromise
console.log("result of ruby test:",result)
console.log("result of ruby test:", result)
if (result > 0) totalFailures += 1
}
catch (e){
Expand Down
2 changes: 1 addition & 1 deletion test/js/pageobjects/DocumentSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DocumentSelection extends Base{
getTitle() { return this.$('.onfido-sdk-ui-Title-titleSpan'); }
getPassport() { return this.$('.onfido-sdk-ui-DocumentSelector-icon-passport')}

copy = (lang="en") =>
strings = (lang="en") =>
require(`../../../src/locales/${lang}.json`)["document_selector"]["identity"]
}

Expand Down
2 changes: 1 addition & 1 deletion test/js/pageobjects/DocumentUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DocumentUpload extends Base{

getUploadButton() { return this.$('.onfido-sdk-ui-Uploader-button')}

copy = (lang="en") =>
strings = (lang="en") =>
require(`../../../src/locales/${lang}.json`)
}

Expand Down
27 changes: 14 additions & 13 deletions test/js/utils/misc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import {spawn} from 'child_process'
import { spawn } from 'child_process'

export const spawnP = (command, args, options={}, optionCallback=()=>{}) => {
return new Promise(function(resolve, reject) {

const process = spawn(command, args, options);
optionCallback(process)
process.on('close', resolve);
process.on('error', reject);
});
export const spawnP = (command, args, options = {}, optionCallback = () => {}) => {
return new Promise(function(resolve, reject) {
const process = spawn(command, args, options);
optionCallback(process)
process.on('close', resolve);
process.on('error', reject);
});
}

export const spawnPrinter = (color, stdout, stderrorPrefix) => process => {
stdout = {prefix:"", filter: ()=>true, ...stdout}
stdout = { prefix: "", filter: () => true, ...stdout }

process.stdout.on('data', data => {
const output = data.toString()
if (stdout.filter(output)){
console.log(color,stdout.prefix, output)
if (stdout.filter(output)) {
console.log(color, stdout.prefix, output)
}
});
process.stderr.on('data', data => {
console.log(color,stderrorPrefix,data.toString())
console.log(color, stderrorPrefix, data.toString())
});
}

export const SHELL_COLOR_BLUE = "\x1b[34m"

0 comments on commit 9bb9fe3

Please sign in to comment.