diff --git a/Tests/JSONAPITests/Test Helpers/EncodedAttributeTest.swift b/Tests/JSONAPITests/Test Helpers/EncodedAttributeTest.swift index de0a502..6bb3777 100644 --- a/Tests/JSONAPITests/Test Helpers/EncodedAttributeTest.swift +++ b/Tests/JSONAPITests/Test Helpers/EncodedAttributeTest.swift @@ -19,7 +19,7 @@ private struct Wrapper: Coda } /// This function attempts to just cast to the type, so it only works -/// for Attributes of primitive types. +/// for Attributes of primitive types (primitive to JSON). func testEncodedPrimitive(attribute: TransformedAttribute) { let encodedAttributeData = encoded(value: Wrapper(x: attribute)) let wrapperObject = try! JSONSerialization.jsonObject(with: encodedAttributeData, options: []) as! [String: Any] diff --git a/Tests/JSONAPITests/Test Helpers/EncodedEntityPropertyTest.swift b/Tests/JSONAPITests/Test Helpers/EncodedEntityPropertyTest.swift index b623ca8..c15c43f 100644 --- a/Tests/JSONAPITests/Test Helpers/EncodedEntityPropertyTest.swift +++ b/Tests/JSONAPITests/Test Helpers/EncodedEntityPropertyTest.swift @@ -17,6 +17,18 @@ func testEncoded(entity: E) { XCTAssertNotNil(jsonDict) + let jsonId = jsonDict?["id"] + + if E.EntityRawIdType.self == Unidentified.self { + XCTAssertNil(jsonId) + } else { + XCTAssertNotNil(jsonId) + } + + let jsonType = jsonDict?["type"] as? String + + XCTAssertEqual(jsonType, E.type) + let jsonAttributes = jsonDict?["attributes"] as? [String: Any] if E.Attributes.self == NoAttributes.self {