refact: depreicated importTables for setTables
This commit is contained in:
parent
07cb1e3fe5
commit
715be52128
@ -44,13 +44,18 @@ class Nodule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
importTables = tablesToImport => {
|
importTables = tablesToImport => {
|
||||||
const validateTablesResponse = this._validateTables(tablesToImport)
|
console.log('Function importTables has been depricated, please use "setTables()"')
|
||||||
|
this.setTables(tablesToImport)
|
||||||
|
}
|
||||||
|
|
||||||
|
setTables = tablesToSet => {
|
||||||
|
const validateTablesResponse = this._validateTables(tablesToSet)
|
||||||
if (validateTablesResponse.status === 'ERR') {
|
if (validateTablesResponse.status === 'ERR') {
|
||||||
throw validateTablesResponse
|
throw validateTablesResponse
|
||||||
} else {
|
} else {
|
||||||
let tables = []
|
let tables = []
|
||||||
if (!Array.isArray(tablesToImport)) tables = [tablesToImport]
|
if (!Array.isArray(tablesToSet)) tables = [tablesToSet]
|
||||||
else tables = tablesToImport
|
else tables = tablesToSet
|
||||||
this.tables = tables
|
this.tables = tables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +66,7 @@ class Nodule {
|
|||||||
this.type = 'Nodule'
|
this.type = 'Nodule'
|
||||||
this.isValid = true
|
this.isValid = true
|
||||||
|
|
||||||
if (props.tables) this.importTables(props.tables)
|
if (props.tables) this.setTables(props.tables)
|
||||||
else this.tables = []
|
else this.tables = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +113,54 @@ const failToExport = () => {
|
|||||||
else return false
|
else return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setTables = () => {
|
||||||
|
const initialTable = new Table({
|
||||||
|
id: 'XYZ',
|
||||||
|
label: 'Test Table',
|
||||||
|
rows: [{ id: 'xyz', data: 'lh' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
const overrideTable = new Table({
|
||||||
|
id: 'XYZ',
|
||||||
|
label: 'Test Table',
|
||||||
|
rows: [{ id: 'abc', data: 'row' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
const expectedOutput = {
|
||||||
|
id: 'ABC',
|
||||||
|
label: 'Test Node',
|
||||||
|
type: 'Nodule',
|
||||||
|
tables: [{
|
||||||
|
id: 'XYZ',
|
||||||
|
label: 'Test Table',
|
||||||
|
rows: [{ id: 'abc', data: 'row' }],
|
||||||
|
type: 'Table',
|
||||||
|
isValid: true
|
||||||
|
}],
|
||||||
|
isValid: true
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const nodule = new Nodule({
|
||||||
|
id: 'ABC',
|
||||||
|
label: 'Test Node',
|
||||||
|
tables: initialTable
|
||||||
|
})
|
||||||
|
nodule.setTables(overrideTable)
|
||||||
|
const nodeProps = nodule.getProperties()
|
||||||
|
|
||||||
|
if (JSON.stringify(nodeProps) == JSON.stringify(expectedOutput)) return true
|
||||||
|
else return false
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{ name: 'Entity | Get Nodule Properties', test: getNodeProperties },
|
{ name: 'Entity | Get Nodule Properties', test: getNodeProperties },
|
||||||
{ name: 'Entity | Create Nodule Without Tables', test: createNodeWithoutTables },
|
{ name: 'Entity | Create Nodule Without Tables', test: createNodeWithoutTables },
|
||||||
{ name: 'Entity | Import Tables to Nodule', test: importTables },
|
{ name: 'Entity | Import Tables to Nodule', test: importTables },
|
||||||
{ name: 'Entity | Fail to Export', test: failToExport }
|
{ name: 'Entity | Fail to Export', test: failToExport },
|
||||||
|
{ name: 'Entity | Nodule setTables', test: setTables }
|
||||||
]
|
]
|
Loading…
x
Reference in New Issue
Block a user