2017-08-22 02:46:39 +00:00
|
|
|
/* global describe, it */
|
|
|
|
|
|
|
|
import { expect } from 'chai'
|
|
|
|
import outdent from 'outdent'
|
|
|
|
|
|
|
|
import XMLParser from '../../src/MetamapsXMLParser'
|
|
|
|
|
|
|
|
describe('Metamaps.XMLParser.js', function() {
|
|
|
|
describe('parseSchema', function() {
|
|
|
|
it('View:Projection nodes', function() {
|
|
|
|
const xml = outdent`
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<View:ColumnView name="ZPalletToBoxes">
|
|
|
|
<viewNode xsi:type="View:Projection" name="NTREE_DATA">
|
|
|
|
<element name="MANDT">
|
|
|
|
<inlineType primitiveType="NVARCHAR" length="3" precision="3" scale="0"/>
|
|
|
|
</element>
|
|
|
|
</viewNode>
|
|
|
|
</View:ColumnView>`
|
2017-08-22 03:18:33 +00:00
|
|
|
|
2017-08-22 02:46:39 +00:00
|
|
|
{ topics, synapses } = XMLParser.parseSchema(xml)
|
2017-08-22 03:18:33 +00:00
|
|
|
|
|
|
|
expect(topics[0].name).to.equal("NTREE_DATA")
|
|
|
|
expect(topics[0].metacode).to.equal("Activity")
|
|
|
|
|
|
|
|
expect(topics[1].name).to.equal("MANDT")
|
|
|
|
expect(topics[1].metacode).to.equal("Wildcard")
|
2017-08-22 02:46:39 +00:00
|
|
|
|
|
|
|
expect(synapses.length).to.equal(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('lays nodes out correctly', function() {
|
|
|
|
const xml = outdent`
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<View:ColumnView name="ZPalletToBoxes">
|
|
|
|
<viewNode xsi:type="View:Projection" name="NTREE_DATA">
|
|
|
|
<element name="MANDT">
|
|
|
|
<inlineType primitiveType="NVARCHAR" length="3" precision="3" scale="0"/>
|
|
|
|
</element>
|
|
|
|
<layout xCoordinate="176" yCoordinate="569" width="-1" height="-1" expanded="true"/>
|
|
|
|
</viewNode>
|
|
|
|
</View:ColumnView>`
|
|
|
|
{ topics, synapses } = XMLParser.parseSchema(xml)
|
2017-08-22 03:18:33 +00:00
|
|
|
|
2017-08-22 02:46:39 +00:00
|
|
|
expect(topics[0].x).to.equal(176)
|
|
|
|
expect(topics[0].y).to.equal(569)
|
2017-08-22 03:18:33 +00:00
|
|
|
expect(topics[1].x).to.equal(176 + 20)
|
|
|
|
expect(topics[1].y).to.equal(569)
|
2017-08-22 02:46:39 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|