Created
April 11, 2019 17:17
-
-
Save thetallweeks/fbe3cf22937d86ede23355b3d1a17b7a to your computer and use it in GitHub Desktop.
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
function findTableIds(properties) { | |
const ids = map(properties, (property, key) => { | |
if (get(property, 'lhv_table')) { | |
return key; | |
} | |
else if (key === 'input') { | |
return findTableIds(get(property, 'properties')); | |
} | |
}); | |
return flatten(compact(ids)); | |
} | |
export function getTableVariablesId(config) { | |
return findTableIds(get(config, 'property_schema.properties')); | |
} |
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
import {expect} from 'chai'; | |
import {getTableVariablesId} from './index'; | |
describe('utils - workflow', () => { | |
describe.only('getTableVariablesId', () => { | |
it('should get all table ids from the config properties and input properties', () => { | |
const config = { | |
property_schema: { | |
properties: { | |
'table': { | |
id: 'table', | |
lhv_table: true | |
}, | |
'nottable': { | |
id: 'nottable' | |
}, | |
input: { | |
properties: { | |
'inputtable': { | |
id: 'table', | |
lhv_table: true | |
}, | |
'notinputtable': { | |
id: 'notinputtable' | |
} | |
} | |
} | |
} | |
} | |
}; | |
expect(getTableVariablesId(config)).to.eql(['table', 'inputtable']); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment