Skip to content

Commit

Permalink
Update MetadataEventTests to verify more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiu committed Jun 28, 2024
1 parent c87aef3 commit cbb98eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Tests/NostrSDKTests/Events/MetadataEventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ final class MetadataEventTests: XCTestCase, EventCreating, EventVerifying, Fixtu
let rawUserMetadata: [String: Any] = [
"foo": "string",
"bool": true,
"number": 123,
"name": "This field should be ignored.",
"number": 123
"lud16": "[email protected]"
]

let ostrichImageURL = try XCTUnwrap(URL(string: "https://nostrsdk.com/ostrich.png"))
Expand Down Expand Up @@ -57,6 +58,8 @@ final class MetadataEventTests: XCTestCase, EventCreating, EventVerifying, Fixtu
XCTAssertEqual(event.rawUserMetadata["foo"] as? String, "string")
XCTAssertEqual(event.rawUserMetadata["bool"] as? Bool, true)
XCTAssertEqual(event.rawUserMetadata["number"] as? Int, 123)
XCTAssertEqual(event.rawUserMetadata["name"] as? String, "Nostr SDK Test :ostrich:")
XCTAssertEqual(event.rawUserMetadata["lud16"] as? String, "[email protected]")
XCTAssertEqual(event.customEmojis, customEmojis)
XCTAssertEqual(event.replaceableEventCoordinates(relayURL: nil), expectedReplaceableEventCoordinates)
XCTAssertEqual(event.tags, customEmojiTags)
Expand Down Expand Up @@ -84,6 +87,7 @@ final class MetadataEventTests: XCTestCase, EventCreating, EventVerifying, Fixtu
XCTAssertEqual(event.rawUserMetadata["nip05"] as? String, "[email protected]")
XCTAssertEqual(event.rawUserMetadata["picture"] as? String, "https://nostr.build/i/9396d5cd901304726883aea7363543f121e1d53964dd3149cadecd802608aebe.jpg")
XCTAssertEqual(event.rawUserMetadata["banner"] as? String, "https://nostr.build/i/nostr.build_90a51a2e50c9f42288260d01b3a2a4a1c7a9df085423abad7809e76429da7cdc.gif")
XCTAssertEqual(event.rawUserMetadata["lud16"] as? String, "[email protected]")

// access metadata properties from decoded object
let userMetadata = try XCTUnwrap(event.userMetadata)
Expand All @@ -93,6 +97,7 @@ final class MetadataEventTests: XCTestCase, EventCreating, EventVerifying, Fixtu
XCTAssertEqual(userMetadata.nostrAddress, "[email protected]")
XCTAssertEqual(userMetadata.pictureURL, URL(string: "https://nostr.build/i/9396d5cd901304726883aea7363543f121e1d53964dd3149cadecd802608aebe.jpg"))
XCTAssertEqual(userMetadata.bannerPictureURL, URL(string: "https://nostr.build/i/nostr.build_90a51a2e50c9f42288260d01b3a2a4a1c7a9df085423abad7809e76429da7cdc.gif"))
XCTAssertEqual(userMetadata.lightningAddress, "[email protected]")
}

func testDecodeMetadataWithEmptyWebsite() throws {
Expand Down

0 comments on commit cbb98eb

Please sign in to comment.