From 1df891ce06467c3ec78f05cd089bebf619939bd9 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Tue, 6 Aug 2019 08:55:49 -0700 Subject: [PATCH] Add test that uses JSONAPIDocument protocol in generic context --- .../JSONAPITests/Document/DocumentTests.swift | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Tests/JSONAPITests/Document/DocumentTests.swift b/Tests/JSONAPITests/Document/DocumentTests.swift index 5f9c18b..be10f7c 100644 --- a/Tests/JSONAPITests/Document/DocumentTests.swift +++ b/Tests/JSONAPITests/Document/DocumentTests.swift @@ -11,6 +11,34 @@ import Poly class DocumentTests: XCTestCase { + func test_genericDocFunc() { + func test(_ doc: Doc) { + let _ = encoded(value: doc) + + XCTAssert(Doc.PrimaryResourceBody.self == NoResourceBody.self) + XCTAssert(Doc.MetaType.self == NoMetadata.self) + XCTAssert(Doc.LinksType.self == NoLinks.self) + XCTAssert(Doc.IncludeType.self == NoIncludes.self) + XCTAssert(Doc.APIDescription.self == NoAPIDescription.self) + XCTAssert(Doc.Error.self == UnknownJSONAPIError.self) + } + + test(JSONAPI.Document< + NoResourceBody, + NoMetadata, + NoLinks, + NoIncludes, + NoAPIDescription, + UnknownJSONAPIError + >( + apiDescription: .none, + body: .none, + includes: .none, + meta: .none, + links: .none + )) + } + func test_singleDocumentNull() { let document = decoded(type: Document, NoMetadata, NoLinks, NoIncludes, NoAPIDescription, UnknownJSONAPIError>.self, data: single_document_null)