Update tests to the new npub abbreviation format
Changelog-None Closes: https://github.com/damus-io/damus/issues/3501 Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -21,9 +21,9 @@ final class EventGroupViewTests: XCTestCase {
|
||||
@MainActor
|
||||
func testEventAuthorName() {
|
||||
let damusState = test_damus_state
|
||||
let damus_name = "17ldvg64:nq5mhr77"
|
||||
let damus_name = "npub17ldv...hr77"
|
||||
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: test_pubkey), damus_name)
|
||||
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: test_pubkey_2), "1rppft3m:4qxhsgnj")
|
||||
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: test_pubkey_2), "npub1rppf...sgnj")
|
||||
XCTAssertEqual(event_author_name(profiles: damusState.profiles, pubkey: ANON_PUBKEY), "Anonymous")
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ final class EventGroupViewTests: XCTestCase {
|
||||
let repost3 = NostrEvent(content: encodedPost, keypair: pk3, kind: NostrKind.boost.rawValue, tags: [], createdAt: 1)!
|
||||
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_note, pubkeys: [], locale: enUsLocale), "??")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_note, pubkeys: [pk1.pubkey], locale: enUsLocale), "1jw906h6:6saq3vx4 reposted a note you were tagged in")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_note, pubkeys: [pk1.pubkey, pk2.pubkey], locale: enUsLocale), "1jw906h6:6saq3vx4 and 1dwdm0t9:nqtnamhd reposted a note you were tagged in")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost2])), ev: test_note, pubkeys: [pk1.pubkey, pk2.pubkey, pk3.pubkey], locale: enUsLocale), "1jw906h6:6saq3vx4 and 2 others reposted a note you were tagged in")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1])), ev: test_note, pubkeys: [pk1.pubkey], locale: enUsLocale), "npub1jw90...3vx4 reposted a note you were tagged in")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2])), ev: test_note, pubkeys: [pk1.pubkey, pk2.pubkey], locale: enUsLocale), "npub1jw90...3vx4 and npub1dwdm...amhd reposted a note you were tagged in")
|
||||
XCTAssertEqual(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [repost1, repost2, repost2])), ev: test_note, pubkeys: [pk1.pubkey, pk2.pubkey, pk3.pubkey], locale: enUsLocale), "npub1jw90...3vx4 and 2 others reposted a note you were tagged in")
|
||||
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
XCTAssertNoThrow(reacting_to_text(profiles: damusState.profiles, our_pubkey: damusState.pubkey, group: .repost(EventGroup(events: [])), ev: test_note, pubkeys: [], locale: $0), "??")
|
||||
|
||||
@@ -21,12 +21,12 @@ final class NIP05DomainTimelineHeaderViewTests: XCTestCase {
|
||||
|
||||
let ndb = Ndb(path: Ndb.db_path)!
|
||||
|
||||
let damus_name = "17ldvg64:nq5mhr77"
|
||||
let damus_name = "npub17ldv...hr77"
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name)")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name) & 1rppft3m:4qxhsgnj")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), 1rppft3m:4qxhsgnj & 1kshyfd2:cq04aze0")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3, pk4,], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 1 other in your trusted network")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3, pk4, pk5], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 2 others in your trusted network")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name) & npub1rppf...sgnj")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), npub1rppf...sgnj & npub1kshy...aze0")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3, pk4,], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), npub1rppf...sgnj, npub1kshy...aze0 & 1 other in your trusted network")
|
||||
XCTAssertEqual(friendsOfFriendsString([pk1, pk2, pk3, pk4, pk5], ndb: ndb, locale: enUsLocale), "Notes from \(damus_name), npub1rppf...sgnj, npub1kshy...aze0 & 2 others in your trusted network")
|
||||
|
||||
let pubkeys = [pk1, pk2, pk3, pk4, pk5, pk1, pk2, pk3, pk4, pk5]
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
|
||||
@@ -365,7 +365,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
func testMentionStr_Pubkey_ContainsAbbreviated() throws {
|
||||
let compatibleText = createCompatibleText(test_pubkey.npub)
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "17ldvg64:nq5mhr77")
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "npub17ldv...hr77")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -379,7 +379,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
func testMentionStr_Nprofile_ContainsAbbreviated() throws {
|
||||
let compatibleText = createCompatibleText("nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p")
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "180cvv07:wsyjh6w6")
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "npub180cv...h6w6")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
||||
@@ -29,12 +29,12 @@ final class ProfileViewTests: XCTestCase {
|
||||
|
||||
let ndb = Ndb(path: Ndb.db_path)!
|
||||
|
||||
let damus_name = "17ldvg64:nq5mhr77"
|
||||
let damus_name = "npub17ldv...hr77"
|
||||
XCTAssertEqual(followedByString([pk1], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name)")
|
||||
XCTAssertEqual(followedByString([pk1, pk2], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name) & 1rppft3m:4qxhsgnj")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj & 1kshyfd2:cq04aze0")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4,], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 1 other")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4, pk5], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 2 others")
|
||||
XCTAssertEqual(followedByString([pk1, pk2], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name) & npub1rppf...sgnj")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), npub1rppf...sgnj & npub1kshy...aze0")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4,], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), npub1rppf...sgnj, npub1kshy...aze0 & 1 other")
|
||||
XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4, pk5], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), npub1rppf...sgnj, npub1kshy...aze0 & 2 others")
|
||||
|
||||
let pubkeys = [pk1, pk2, pk3, pk4, pk5, pk1, pk2, pk3, pk4, pk5]
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
|
||||
@@ -21,9 +21,9 @@ final class RepostedTests: XCTestCase {
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 0, locale: enUsLocale), "")
|
||||
|
||||
// Verify the English pluralization variations.
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 1, locale: enUsLocale), "17ldvg64:nq5mhr77 reposted")
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 2, locale: enUsLocale), "17ldvg64:nq5mhr77 and 1 other reposted")
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 3, locale: enUsLocale), "17ldvg64:nq5mhr77 and 2 others reposted")
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 1, locale: enUsLocale), "npub17ldv...hr77 reposted")
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 2, locale: enUsLocale), "npub17ldv...hr77 and 1 other reposted")
|
||||
XCTAssertEqual(people_reposted_text(profiles: damusState.profiles, pubkey: pubkey, reposts: 3, locale: enUsLocale), "npub17ldv...hr77 and 2 others reposted")
|
||||
|
||||
// Sanity check that the non-English translations are likely not malformed.
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
|
||||
@@ -45,7 +45,7 @@ final class ZapTests: XCTestCase {
|
||||
XCTAssertEqual(zap.target, ZapTarget.note(id: note_id, author: author))
|
||||
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_title(zap), "Zap")
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_body(profiles: Profiles(ndb: test_damus_state.ndb), zap: zap), "You received 1k sats from 1q5sah9f:mqzxky65: \"⚡Non-custodial zap from my Alby Hub\"")
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_body(profiles: Profiles(ndb: test_damus_state.ndb), zap: zap), "You received 1k sats from npub1q5sa...ky65: \"⚡Non-custodial zap from my Alby Hub\"")
|
||||
|
||||
|
||||
}
|
||||
@@ -103,7 +103,7 @@ final class ZapTests: XCTestCase {
|
||||
XCTAssertEqual(zap.target, ZapTarget.profile(profile))
|
||||
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_title(zap), "Zap")
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_body(profiles: Profiles(ndb: test_damus_state.ndb), zap: zap), "You received 1k sats from 107jk7ht:2quqncxg")
|
||||
XCTAssertEqual(NotificationFormatter.zap_notification_body(profiles: Profiles(ndb: test_damus_state.ndb), zap: zap), "You received 1k sats from npub107jk...ncxg")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user