Skip to content

Commit

Permalink
better poly proxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Nov 30, 2018
1 parent 689517c commit 8668311
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Tests/JSONAPITests/Poly/PolyProxyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,29 @@ public class PolyProxyTests: XCTestCase {
XCTAssertEqual(polyUserA.relationships, .none)
}

func test_UserAEncode() {
func test_UserAAndBEncodeEquality() {
test_DecodeEncodeEquality(type: User.self, data: poly_user_stub_1)
test_DecodeEncodeEquality(type: User.self, data: poly_user_stub_2)
}

func test_AsymmetricEncodeDecodeUserA() {
let userA = decoded(type: UserA.self, data: poly_user_stub_1)
let polyUserA = decoded(type: User.self, data: poly_user_stub_1)

let encodedPoly = try! JSONEncoder().encode(polyUserA)

XCTAssertEqual(decoded(type: UserA.self, data: encodedPoly), userA)
}

func test_AsymmetricEncodeDecodeUserB() {
let userB = decoded(type: UserB.self, data: poly_user_stub_2)
let polyUserB = decoded(type: User.self, data: poly_user_stub_2)

let encodedPoly = try! JSONEncoder().encode(polyUserB)

XCTAssertEqual(decoded(type: UserB.self, data: encodedPoly), userB)
}

func test_UserBDecode() {
let polyUserB = decoded(type: User.self, data: poly_user_stub_2)
let userB = decoded(type: UserB.self, data: poly_user_stub_2)
Expand Down

0 comments on commit 8668311

Please sign in to comment.