mirror of
https://github.com/encounter/JSONAPI.git
synced 2026-03-30 11:18:38 -07:00
Complete test coverage of APIDescription
This commit is contained in:
@@ -10,6 +10,17 @@ import JSONAPI
|
||||
|
||||
class APIDescriptionTests: XCTestCase {
|
||||
|
||||
func test_init() {
|
||||
let _ = APIDescription<NoMetadata>(version: "hello",
|
||||
meta: .none)
|
||||
let _ = APIDescription<TestMetadata>(version: "world",
|
||||
meta: .init(hello: "there",
|
||||
number: 2))
|
||||
let _ = NoAPIDescription()
|
||||
|
||||
XCTAssertEqual(NoAPIDescription(), NoAPIDescription.none)
|
||||
}
|
||||
|
||||
func test_NoDescriptionString() {
|
||||
XCTAssertEqual(String(describing: NoAPIDescription()), "No JSON:API Object")
|
||||
}
|
||||
@@ -18,12 +29,18 @@ class APIDescriptionTests: XCTestCase {
|
||||
let description = decoded(type: APIDescription<NoMetadata>.self, data: api_description_empty)
|
||||
|
||||
XCTAssertEqual(description.version, "1.0")
|
||||
|
||||
test_DecodeEncodeEquality(type: APIDescription<NoMetadata>.self,
|
||||
data: api_description_empty)
|
||||
}
|
||||
|
||||
func test_WithVersion() {
|
||||
let description = decoded(type: APIDescription<NoMetadata>.self, data: api_description_with_version)
|
||||
|
||||
XCTAssertEqual(description.version, "1.5")
|
||||
|
||||
test_DecodeEncodeEquality(type: APIDescription<NoMetadata>.self,
|
||||
data: api_description_with_version)
|
||||
}
|
||||
|
||||
func test_WithMeta() {
|
||||
@@ -32,6 +49,9 @@ class APIDescriptionTests: XCTestCase {
|
||||
XCTAssertEqual(description.version, "1.0")
|
||||
XCTAssertEqual(description.meta.hello, "world")
|
||||
XCTAssertEqual(description.meta.number, 10)
|
||||
|
||||
test_DecodeEncodeEquality(type: APIDescription<TestMetadata>.self,
|
||||
data: api_description_with_meta)
|
||||
}
|
||||
|
||||
func test_WithVersionAndMeta() {
|
||||
@@ -40,6 +60,9 @@ class APIDescriptionTests: XCTestCase {
|
||||
XCTAssertEqual(description.version, "2.0")
|
||||
XCTAssertEqual(description.meta.hello, "world")
|
||||
XCTAssertEqual(description.meta.number, 10)
|
||||
|
||||
test_DecodeEncodeEquality(type: APIDescription<TestMetadata>.self,
|
||||
data: api_description_with_version_and_meta)
|
||||
}
|
||||
|
||||
func test_failsMissingMeta() {
|
||||
|
||||
Reference in New Issue
Block a user