Skip to content

Instantly share code, notes, and snippets.

@thetallweeks
Created April 11, 2019 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetallweeks/fbe3cf22937d86ede23355b3d1a17b7a to your computer and use it in GitHub Desktop.
Save thetallweeks/fbe3cf22937d86ede23355b3d1a17b7a to your computer and use it in GitHub Desktop.
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'));
}
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