Skip to content

Commit

Permalink
Fixes to exercise config form and empty configs
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Dec 1, 2017
1 parent 8df5b4c commit 64e7e6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ const validate = ({ config }) => {
defaultMessage="Input files are not properly paired with their names. Please make sure each file has a name."
/>
);
for (const inputFilePair of test.inputFiles) {
const inFilesArr =
test.inputFiles && Array.isArray(test.inputFiles) ? test.inputFiles : [];
for (const inputFilePair of inFilesArr) {
if (
(!inputFilePair.first || inputFilePair.first === '') &&
inputFilePair.second !== ''
Expand Down
27 changes: 16 additions & 11 deletions src/helpers/exerciseSimpleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ export const transformAndSendTestsValues = (
};

export const getSimpleConfigInitValues = (config, tests, locale) => {
const confTests = config[0].tests.sort((a, b) =>
a.name.localeCompare(b.name, locale)
);
const confTests =
config[0] && config[0].tests
? config[0].tests.sort((a, b) => a.name.localeCompare(b.name, locale))
: [];

let res = [];
for (let test of confTests) {
Expand All @@ -91,13 +92,15 @@ export const getSimpleConfigInitValues = (config, tests, locale) => {
variable => variable.name === 'actual-inputs'
);
if (inputFiles) {
testObj.inputFiles = inputFiles.value.map((value, i) => ({
first: value,
second:
actualInputs && actualInputs.value && actualInputs.value[i]
? actualInputs.value[i]
: ''
}));
testObj.inputFiles = inputFiles.value
? inputFiles.value.map((value, i) => ({
first: value,
second:
actualInputs && actualInputs.value && actualInputs.value[i]
? actualInputs.value[i]
: ''
}))
: [];
}

const expectedOutput = variables.find(
Expand Down Expand Up @@ -210,7 +213,9 @@ export const transformAndSendConfigValues = (

let inputFiles = [];
let renamedNames = [];
for (const item of test.inputFiles) {
const inFilesArr =
test.inputFiles && Array.isArray(test.inputFiles) ? test.inputFiles : [];
for (const item of inFilesArr) {
inputFiles.push(item.first);
renamedNames.push(item.second);
}
Expand Down

0 comments on commit 64e7e6e

Please sign in to comment.