Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from TootSDK/add-post-edited
Adds Post.editedAt, introduced in Mastodon 4.2
- Loading branch information
Showing
4 changed files
with
160 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Created by konstantin on 23/04/2024. | ||
|
||
import XCTest | ||
|
||
@testable import TootSDK | ||
|
||
final class PostTests: XCTestCase { | ||
|
||
func testPostEdited() throws { | ||
// arrange | ||
let json = localContent("post_edited") | ||
let decoder = TootDecoder() | ||
|
||
// act | ||
let result = try decoder.decode(Post.self, from: json) | ||
|
||
// assert | ||
XCTAssertNotNil(result) | ||
XCTAssertEqual(result.id, "112300188527054704") | ||
XCTAssertEqual(result.filtered, []) | ||
XCTAssertEqual(result.mentions, []) | ||
XCTAssertEqual(result.emojis, []) | ||
XCTAssertEqual(result.mediaAttachments, []) | ||
XCTAssertEqual(result.tags.count, 1) | ||
XCTAssertEqual(result.favourited, false) | ||
XCTAssertEqual(result.reposted, false) | ||
XCTAssertNotNil(result.createdAt) | ||
|
||
// let's test if the date was correctly parsed | ||
var calendar = Calendar(identifier: .gregorian) | ||
calendar.timeZone = TimeZone(identifier: "UTC")! | ||
let components = DateComponents(year: 2024, month: 04, day: 19, hour: 22, minute: 15, second: 22) | ||
let expectedDate = calendar.date(from: components)! | ||
XCTAssertNotNil(result.editedAt) | ||
XCTAssertEqual(result.editedAt!.timeIntervalSince1970, expectedDate.timeIntervalSince1970) | ||
|
||
XCTAssertNil(result.inReplyToId) | ||
XCTAssertFalse(result.sensitive) | ||
XCTAssertNotNil(result.content) | ||
XCTAssertNil(result.poll) | ||
XCTAssertNotNil(result.card) | ||
XCTAssertNotNil(result.url) | ||
XCTAssertEqual(result.spoilerText, "") | ||
XCTAssertEqual(result.language, "en") | ||
XCTAssertEqual(result.visibility, .public) | ||
XCTAssertEqual(result.pinned, false) | ||
XCTAssertEqual(result.muted, false) | ||
XCTAssertEqual(result.favouritesCount, 1) | ||
XCTAssertEqual(result.repliesCount, 1) | ||
XCTAssertEqual(result.bookmarked, true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"filtered": [], | ||
"reblog": null, | ||
"application": { | ||
"name": "Elk", | ||
"website": "https://elk.zone" | ||
}, | ||
"language": "en", | ||
"account": { | ||
"acct": "person", | ||
"bot": false, | ||
"locked": false, | ||
"avatar_static": "https://media.example.com/accounts/avatars/109/821/003/814/913/641/original/d15a73c9d3b22e27.jpeg", | ||
"statuses_count": 14881, | ||
"url": "https://example.com/@person", | ||
"following_count": 394, | ||
"emojis": [], | ||
"discoverable": true, | ||
"last_status_at": "2024-04-20", | ||
"group": false, | ||
"uri": "https://example.com/users/person", | ||
"id": "109821003814913641", | ||
"roles": [], | ||
"header_static": "https://media.example.com/accounts/headers/109/821/003/814/913/641/original/6a6d879a38c226fd.jpeg", | ||
"followers_count": 424, | ||
"note": "<p>This is my talk (and block) about anything account.</p>", | ||
"avatar": "https://media.example.com/accounts/avatars/109/821/003/814/913/641/original/d15a73c9d3b22e27.jpeg", | ||
"display_name": "Person", | ||
"header": "https://media.example.com/accounts/headers/109/821/003/814/913/641/original/6a6d879a38c226fd.jpeg", | ||
"created_at": "2023-02-07T00:00:00.000Z", | ||
"noindex": false, | ||
"fields": [ | ||
{ | ||
"name": "Example", | ||
"value": "<a href=\"https://example.com/technicat\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">example.com/person</span><span class=\"invisible\"></span></a>", | ||
"verified_at": null | ||
} | ||
], | ||
"username": "person" | ||
}, | ||
"spoiler_text": "", | ||
"url": "https://example.com/@person/112300188527054704", | ||
"media_attachments": [], | ||
"sensitive": false, | ||
"replies_count": 1, | ||
"tags": [ | ||
{ | ||
"name": "ub40", | ||
"url": "https://example.com/tags/ub40" | ||
} | ||
], | ||
"emojis": [], | ||
"muted": false, | ||
"mentions": [], | ||
"visibility": "public", | ||
"card": { | ||
"description": "UB45 by UB40", | ||
"provider_url": "", | ||
"embed_url": "", | ||
"image_description": "UB45 by UB40", | ||
"blurhash": "UJEfG_n#02R+ofRjWBxu4:kDxtobWAs;s;Ri", | ||
"published_at": null, | ||
"provider_name": "Album Example", | ||
"width": 1400, | ||
"url": "https://example.com/albums/8513", | ||
"author_url": "", | ||
"type": "link", | ||
"title": "UB45 by UB40", | ||
|
||
"image": "https://media.example.com/cache/preview_cards/images/024/062/128/original/1c7d0494ae037a8f.jpg", | ||
"language": "en", | ||
"height": 1400, | ||
"author_name": "", | ||
"html": "" | ||
}, | ||
"poll": null, | ||
"uri": "https://example.com/users/technicat/statuses/112300188527054704", | ||
"edited_at": "2024-04-19T22:15:22.000Z", | ||
"id": "112300188527054704", | ||
"reblogs_count": 0, | ||
"favourited": false, | ||
"reblogged": false, | ||
"in_reply_to_account_id": null, | ||
"created_at": "2024-04-19T22:14:48.415Z", | ||
"in_reply_to_id": null, | ||
"pinned": false, | ||
"favourites_count": 1, | ||
"bookmarked": true, | ||
"content": "<p>listening to <a href=\"https://example.com/tags/UB40\" class=\"mention hashtag\" rel=\"tag\">#<span>UB40</span></a> </p><p><a href=\"https://example.com/albums/8513\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><span class=\"invisible\">https://</span><span class=\"\">example.com/albums/8513</span><span class=\"invisible\"></span></a></p>" | ||
} |