ProfileViewTests.swift (2102B)
1 // 2 // ProfileViewTests.swift 3 // damusTests 4 // 5 // Created by Terry Yiu on 2/24/23. 6 // 7 8 import XCTest 9 @testable import damus 10 11 final class ProfileViewTests: XCTestCase { 12 13 let enUsLocale = Locale(identifier: "en-US") 14 15 override func setUpWithError() throws { 16 // Put setup code here. This method is called before the invocation of each test method in the class. 17 } 18 19 override func tearDownWithError() throws { 20 // Put teardown code here. This method is called after the invocation of each test method in the class. 21 } 22 23 func testFollowedByString() throws { 24 let pk1 = test_pubkey 25 let pk2 = test_pubkey_2 26 let pk3 = Pubkey(hex: "b42e44b555013239a0d5dcdb09ebde0857cd8a5a57efbba5a2b6ac78833cb9f0")! 27 let pk4 = Pubkey(hex: "cc590e46363d0fa66bb27081368d01f169b8ffc7c614629d4e9eef6c88b38670")! 28 let pk5 = Pubkey(hex: "f2aa579bb998627e04a8f553842a09446360c9d708c6141dd119c479f6ab9d29")! 29 30 let ndb = Ndb(path: Ndb.db_path)! 31 32 let damus_name = "17ldvg64:nq5mhr77" 33 XCTAssertEqual(followedByString([pk1], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name)") 34 XCTAssertEqual(followedByString([pk1, pk2], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name) & 1rppft3m:4qxhsgnj") 35 XCTAssertEqual(followedByString([pk1, pk2, pk3], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj & 1kshyfd2:cq04aze0") 36 XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4,], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 1 other") 37 XCTAssertEqual(followedByString([pk1, pk2, pk3, pk4, pk5], ndb: ndb, locale: enUsLocale), "Followed by \(damus_name), 1rppft3m:4qxhsgnj, 1kshyfd2:cq04aze0 & 2 others") 38 39 let pubkeys = [pk1, pk2, pk3, pk4, pk5, pk1, pk2, pk3, pk4, pk5] 40 Bundle.main.localizations.map { Locale(identifier: $0) }.forEach { 41 for count in 1...10 { 42 XCTAssertNoThrow(followedByString(pubkeys.prefix(count).map { $0 }, ndb: ndb, locale: $0)) 43 } 44 } 45 } 46 47 }