-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
visualization/app/codeCharta/services/3DExports/generateXML/build3mfModelConfig.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { XMLParser } from "fast-xml-parser" | ||
import { Volume } from "../serialize3mf.service" | ||
import { getXMLmodelConfig } from "./build3mfModelConfig" | ||
|
||
describe("build3mfModelConfig", () => { | ||
it("should return a valid xml with properly defined volumes", () => { | ||
const exampleVolumeList: Volume[] = [] | ||
for (let index = 0; index < 5; index++) { | ||
const aVolume: Volume = { | ||
id: index, | ||
name: "", | ||
color: "", | ||
extruder: index, | ||
firstTriangleId: index * 10, | ||
lastTriangleId: index * 10 + 9 | ||
} | ||
exampleVolumeList[index] = aVolume | ||
} | ||
|
||
const xmlContent = getXMLmodelConfig(exampleVolumeList) | ||
const xmlParser = new XMLParser({ removeNSPrefix: false, ignoreAttributes: false, parseAttributeValue: true }) | ||
const xmlObject = xmlParser.parse(xmlContent) | ||
|
||
let expectedID = 0 | ||
|
||
for (const volume of xmlObject["config"]["object"]["volume"]) { | ||
expect(volume["@_firstid"]).toBe(expectedID) | ||
expectedID = volume["@_lastid"] + 1 | ||
// name, extruder, source_object_id, source_volume_id | ||
expect(volume["metadata"][1]["@_value"]).toBeLessThanOrEqual(5) | ||
expect(volume["metadata"][2]["@_value"]).toBe(1) | ||
} | ||
}) | ||
}) |
18 changes: 18 additions & 0 deletions
18
visualization/app/codeCharta/services/3DExports/generateXML/build3mfStatics.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getXMLcontentType, getXMLrelationships } from "./build3mfStatics" | ||
import { XMLValidator } from "fast-xml-parser" | ||
|
||
describe("build3mfStatics", () => { | ||
describe("contentType", () => { | ||
it("should return valid xml", () => { | ||
const xmlContent = getXMLcontentType() | ||
expect(XMLValidator.validate(xmlContent)).toBe(true) | ||
}) | ||
}) | ||
|
||
describe("relationships", () => { | ||
it("should return valid xml", () => { | ||
const xmlContent = getXMLrelationships() | ||
expect(XMLValidator.validate(xmlContent)).toBe(true) | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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