Skip to content

Commit

Permalink
Add case customXml to Relationship.SchemaType (#88)
Browse files Browse the repository at this point in the history
* Add `case customXml` to Relationship.SchemaType
* Add end-to-end test for the new SchemaType
  • Loading branch information
MaxDesiatov committed Nov 7, 2019
1 parent 8d86fbb commit 2094752
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/CoreXLSX/Relationships.swift
Expand Up @@ -90,6 +90,11 @@ public struct Relationship: Codable, Equatable {
http://schemas.openxmlformats.org/officeDocument/2006/relationships/\
externalLink
"""
case customXml =
"""
http://schemas.openxmlformats.org/officeDocument/2006/relationships/\
customXml
"""
}

public let id: String
Expand Down
22 changes: 22 additions & 0 deletions Tests/CoreXLSXTests/Relationships.swift
Expand Up @@ -70,6 +70,28 @@ final class RelationshipsTests: XCTestCase {
XCTAssertEqual(relationshipsFromFile, Relationships(items: parsed))
}

func testCustomXmlSchemaType() throws {
guard let file =
XLSXFile(filepath: "\(currentWorkingPath)/jewelershealthcare.com-census.1.xlsx") else {
XCTAssert(false, "failed to open the file")
return
}

let relationshipsFromFile = try file.parseRelationships()

let expected = Relationships(items: [
Relationship(id: "rId3", type: .extendedProperties, target: "docProps/app.xml"),
Relationship(id: "rId2", type: .packageCoreProperties, target: "docProps/core.xml"),
Relationship(id: "rId1", type: .officeDocument, target: "xl/workbook.xml"),
Relationship(id: "rId4", type: .customProperties, target: "docProps/custom.xml"),
])

XCTAssertEqual(relationshipsFromFile, expected)

let paths = try file.parseWorksheetPaths()
XCTAssertEqual(paths, ["xl/worksheets/sheet1.xml"])
}

static let allTests = [
("testRelationships", testRelationships),
]
Expand Down
Binary file not shown.

0 comments on commit 2094752

Please sign in to comment.