Skip to content

Commit

Permalink
Add tests for embed posts (mattmassicotte#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
unnamedd authored Feb 9, 2025
1 parent b705fbf commit af562a6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Tests/ATATTests/PostTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,38 @@ struct PostTests {
#expect(videoAspectRatio.height == 1920)
#expect(videoAspectRatio.width == 1920)
}

@Test func embedViewImageWithoutAspectRatio() throws {
let json = """
{"thumb":"https://bsky.com/thumbnail.jpg","fullsize":"https://bsky.com/img/feed_fullsize/plain/did:plc:z7ja/bafk@jpeg","alt":""}
"""

let embed = try ATJSONDecoder()
.decode(
Bsky.Embed.Images.ViewImage.self,
from: Data(json.utf8)
)

#expect(embed.thumb == "https://bsky.com/thumbnail.jpg")
#expect(embed.fullsize == "https://bsky.com/img/feed_fullsize/plain/did:plc:z7ja/bafk@jpeg")
#expect(embed.alt == "")
#expect(embed.aspectRatio == nil)
}

@Test func embedViewVideoWithoutAspectRatio() throws {
let json = """
{"$type":"app.bsky.embed.video#view","cid":"123abcde890","playlist":"https://example-url.bsky.com/playlist.m3u8","thumbnail":"https://example-url.bsky.com/thumbnail.jpg"}
"""

let embed = try ATJSONDecoder()
.decode(
Bsky.Embed.Video.View.self,
from: Data(json.utf8)
)

#expect(embed.cid == "123abcde890")
#expect(embed.playlist == "https://example-url.bsky.com/playlist.m3u8")
#expect(embed.thumbnail == "https://example-url.bsky.com/thumbnail.jpg")
#expect(embed.aspectRatio == nil)
}
}

0 comments on commit af562a6

Please sign in to comment.