You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // APITest.swift
  3. // GMERemittanceTests
  4. //
  5. // Created by InKwon Devik Kim on 03/05/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import GME_Remit
  10. class APITest: XCTestCase {
  11. func testProductList() {
  12. let service = RewardService()
  13. let expt = expectation(description: "ProductList")
  14. service.fetchProductList(success: {
  15. print("success: \($0?.count ?? 0)")
  16. expt.fulfill()
  17. }, failure: {
  18. print("Error: \($0.localizedDescription)")
  19. expt.fulfill()
  20. })
  21. wait(for: [expt], timeout: 5.0)
  22. }
  23. func testFetchBankList() {
  24. let service = AddAccountService()
  25. let expt = expectation(description: "testFetchBankList")
  26. service.fetchBankList(
  27. success: {
  28. print("banks: \($0?.count ?? 0)")
  29. expt.fulfill()
  30. },
  31. failure: {
  32. print("error: \($0.localizedDescription)")
  33. expt.fulfill()
  34. }
  35. )
  36. wait(for: [expt], timeout: 5.0)
  37. }
  38. func testRealName() {
  39. // let service = AddAccountService()
  40. // let expt = expectation(description: "testRealName")
  41. //
  42. // var params = ["CustomerId": "85074"]
  43. // params["BankCode"] = "034"
  44. // params["AccountNumber"] = "1234512345"
  45. //
  46. // service.verifyAccountService(
  47. // using: params,
  48. // success: {
  49. // expt.fulfill()
  50. // },
  51. // failure: {
  52. // print("error: \($0)")
  53. // expt.fulfill()
  54. // }
  55. // )
  56. // wait(for: [expt], timeout: 5.0)
  57. }
  58. func testFetchOrderHistory() {
  59. let service = OrderHistoryService()
  60. let expt = expectation(description: "testFetchOrderHistory")
  61. service.fetchOrderHistory(
  62. from: "2019-05-01",
  63. to: "2019-05-11",
  64. success: { _ in
  65. expt.fulfill()
  66. },
  67. failure: { _ in
  68. expt.fulfill()
  69. }
  70. )
  71. wait(for: [expt], timeout: 5.0)
  72. }
  73. func testFetchHotLines() {
  74. // let service = HomeService()
  75. // service.fetchHotLines()
  76. }
  77. func testKFTCRefrsh() {
  78. let service = AutoDebitService()
  79. let service2 = AddAccountService()
  80. let expt = expectation(description: "Test KFTC Refresh")
  81. service.refreshTokenStep1(
  82. username: "maxkim@gmeremit.com",
  83. success: {
  84. let url = "\($0?.url?.replacingOccurrences(of: "&lang=", with: "&lang=kor") ?? "")"
  85. var header = [String: String]()
  86. $0?.header?.forEach({
  87. header[$0.key ?? ""] = $0.value ?? ""
  88. })
  89. service2.fetchKftcUrlService(
  90. url: url,
  91. header: header,
  92. success: {
  93. print("Fetched URL: \($0 ?? "URL IS NULL")")
  94. expt.fulfill()
  95. },
  96. failure: {
  97. print("Fetch URL Error: \($0)")
  98. expt.fulfill()
  99. }
  100. )
  101. },
  102. failure: {
  103. print("Error: \($0)")
  104. expt.fulfill()
  105. }
  106. )
  107. wait(for: [expt], timeout: 60)
  108. }
  109. func testFetchCountryService() {
  110. // let expt = expectation(description: "testDynamicReceiver")
  111. // let service = SetupRecipientService()
  112. }
  113. func testDynamicReceiver() {
  114. let expt = expectation(description: "testDynamicReceiver")
  115. let service = SetupRecipientService()
  116. service.fetchDynamicReceiverFields(
  117. of: "104",
  118. paymentModeID: "2",
  119. success: {
  120. print($0.dynamicField)
  121. expt.fulfill()
  122. },
  123. failure: {
  124. XCTAssert(false, $0.localizedDescription)
  125. expt.fulfill()
  126. }
  127. )
  128. wait(for: [expt], timeout: 5.0)
  129. }
  130. func testFecthRecipients() {
  131. let expt = expectation(description: "testFecthRecipients")
  132. let service = RecipientsService()
  133. service.fetchRecipients(
  134. success: {
  135. print($0.accounts?.count ?? 0)
  136. print($0.recipients?.count ?? 0)
  137. XCTAssert(true)
  138. expt.fulfill()
  139. },
  140. failure: {
  141. XCTAssert(false, $0.localizedDescription)
  142. expt.fulfill()
  143. }
  144. )
  145. wait(for: [expt], timeout: 1000.0)
  146. }
  147. func testFetchBranch() {
  148. let expt = expectation(description: "textFetchBranch")
  149. let service = TablePresenterService()
  150. service.fetchBranches(
  151. countryCode: "",
  152. bankID: "",
  153. branchName: "",
  154. success: {
  155. print($0.count)
  156. expt.fulfill()
  157. XCTAssert(true)
  158. },
  159. failure: {
  160. expt.fulfill()
  161. XCTAssert(false, $0.localizedDescription)
  162. })
  163. wait(for: [expt], timeout: 5.0)
  164. }
  165. }