15
15
16
16
#import " CommentResource.h"
17
17
#import " PeopleResource.h"
18
- #import " PostResource .h"
18
+ #import " ArticleResource .h"
19
19
20
20
@interface JSONAPITests : XCTestCase
21
21
@@ -28,7 +28,7 @@ - (void)setUp {
28
28
29
29
[JSONAPIResourceDescriptor addResource: [CommentResource class ]];
30
30
[JSONAPIResourceDescriptor addResource: [PeopleResource class ]];
31
- [JSONAPIResourceDescriptor addResource: [PostResource class ]];
31
+ [JSONAPIResourceDescriptor addResource: [ArticleResource class ]];
32
32
}
33
33
34
34
- (void )tearDown {
@@ -43,18 +43,18 @@ - (void)testMeta {
43
43
XCTAssertEqualObjects (jsonAPI.meta [@" hehe" ], @" hoho" , @" Meta's 'hehe' should equal 'hoho'" );
44
44
}
45
45
46
- - (void )testDataPosts {
46
+ - (void )testDataArticles {
47
47
NSDictionary *json = [self mainExampleJSON ];
48
48
JSONAPI *jsonAPI = [JSONAPI jsonAPIWithDictionary: json];
49
49
50
50
XCTAssertNotNil (jsonAPI.resource , @" Resource should not be nil" );
51
51
XCTAssertNotNil (jsonAPI.resources , @" Resources should not be nil" );
52
52
XCTAssertEqual (jsonAPI.resources .count , 1 , @" Resources should contain 1 resource" );
53
53
54
- PostResource *post = jsonAPI.resource ;
55
- XCTAssert ([post isKindOfClass: [PostResource class ]], @" Post should be a PostResource " );
56
- XCTAssertEqualObjects (post .ID , @" 1" , @" Post id should be 1" );
57
- XCTAssertEqualObjects (post .title , @" JSON API paints my bikeshed!" , @" Post title should be 'JSON API paints my bikeshed!'" );
54
+ ArticleResource *article = jsonAPI.resource ;
55
+ XCTAssert ([article isKindOfClass: [ArticleResource class ]], @" Article should be a ArticleResource " );
56
+ XCTAssertEqualObjects (article .ID , @" 1" , @" Article id should be 1" );
57
+ XCTAssertEqualObjects (article .title , @" JSON API paints my bikeshed!" , @" Article title should be 'JSON API paints my bikeshed!'" );
58
58
}
59
59
60
60
- (void )testIncludedPeopleAndComments {
@@ -66,14 +66,14 @@ - (void)testIncludedPeopleAndComments {
66
66
67
67
}
68
68
69
- - (void )testDataPostAuthorAndComments {
69
+ - (void )testDataArticleAuthorAndComments {
70
70
NSDictionary *json = [self mainExampleJSON ];
71
71
JSONAPI *jsonAPI = [JSONAPI jsonAPIWithDictionary: json];
72
72
73
- PostResource *post = jsonAPI.resource ;
74
- XCTAssertNotNil (post .author , @" Post's author should not be nil" );
75
- XCTAssertNotNil (post .comments , @" Post's comments should not be nil" );
76
- XCTAssertEqual (post .comments .count , 2 , @" Post should contain 2 comments" );
73
+ ArticleResource *article = jsonAPI.resource ;
74
+ XCTAssertNotNil (article .author , @" Article author should not be nil" );
75
+ XCTAssertNotNil (article .comments , @" Article comments should not be nil" );
76
+ XCTAssertEqual (article .comments .count , 2 , @" Article should contain 2 comments" );
77
77
}
78
78
79
79
- (void )testIncludedCommentIsLinked {
@@ -82,7 +82,7 @@ - (void)testIncludedCommentIsLinked {
82
82
83
83
CommentResource *comment = [jsonAPI includedResource: @" 5" withType: @" comments" ];
84
84
XCTAssertNotNil (comment.author , @" Comment's author should not be nil" );
85
- XCTAssertEqualObjects (comment.author .ID , @" 9 " , @" Comment's author's ID should be 9 " );
85
+ XCTAssertEqualObjects (comment.author .ID , @" 2 " , @" Comment's author's ID should be 2 " );
86
86
}
87
87
88
88
- (void )testNoError {
@@ -115,12 +115,12 @@ - (void)testSerializeSimple {
115
115
}
116
116
117
117
- (void )testSerializeWithFormat {
118
- PostResource *newPost = [[PostResource alloc ] init ];
119
- newPost .title = @" Title" ;
120
- newPost .date = [NSDate date ];
118
+ ArticleResource *newArticle = [[ArticleResource alloc ] init ];
119
+ newArticle .title = @" Title" ;
120
+ newArticle .date = [NSDate date ];
121
121
122
- NSDictionary *json = [JSONAPIResourceParser dictionaryFor: newPost ];
123
- XCTAssertEqualObjects (json[@" type" ], @" posts " , @" Did not create post !" );
122
+ NSDictionary *json = [JSONAPIResourceParser dictionaryFor: newArticle ];
123
+ XCTAssertEqualObjects (json[@" type" ], @" articles " , @" Did not create article !" );
124
124
XCTAssertNotNil (json[@" attributes" ][@" date" ], @" Wrong date!" );
125
125
XCTAssertTrue ([json[@" attributes" ][@" date" ] isKindOfClass: [NSString class ]], @" Date should be string!." );
126
126
}
@@ -137,14 +137,14 @@ - (void)testSerializeComplex {
137
137
newComment.author = newAuthor;
138
138
newComment.text = @" First!" ;
139
139
140
- PostResource *newPost = [[PostResource alloc ] init ];
141
- newPost .title = @" Title" ;
142
- newPost .author = newAuthor;
143
- newPost .date = [NSDate date ];
144
- newPost .comments = [[NSArray alloc ] initWithObjects: newComment, nil ];
140
+ ArticleResource *newArticle = [[ArticleResource alloc ] init ];
141
+ newArticle .title = @" Title" ;
142
+ newArticle .author = newAuthor;
143
+ newArticle .date = [NSDate date ];
144
+ newArticle .comments = [[NSArray alloc ] initWithObjects: newComment, nil ];
145
145
146
- NSDictionary *json = [JSONAPIResourceParser dictionaryFor: newPost ];
147
- XCTAssertEqualObjects (json[@" type" ], @" posts " , @" Did not create Post !" );
146
+ NSDictionary *json = [JSONAPIResourceParser dictionaryFor: newArticle ];
147
+ XCTAssertEqualObjects (json[@" type" ], @" articles " , @" Did not create Article !" );
148
148
XCTAssertNotNil (json[@" relationships" ], @" Did not create links!" );
149
149
XCTAssertNotNil (json[@" relationships" ][@" author" ], @" Did not create links!" );
150
150
XCTAssertNotNil (json[@" relationships" ][@" author" ][@" data" ], @" Did not create links!" );
0 commit comments