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.

306 lines
7.1 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
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. needsAuthorization: false,
  28. success: {
  29. print("banks: \($0?.count ?? 0)")
  30. expt.fulfill()
  31. },
  32. failure: {
  33. print("error: \($0.localizedDescription)")
  34. expt.fulfill()
  35. }
  36. )
  37. wait(for: [expt], timeout: 5.0)
  38. }
  39. func testRealName() {
  40. // let service = AddAccountService()
  41. // let expt = expectation(description: "testRealName")
  42. //
  43. // var params = ["CustomerId": "85074"]
  44. // params["BankCode"] = "034"
  45. // params["AccountNumber"] = "1234512345"
  46. //
  47. // service.verifyAccountService(
  48. // using: params,
  49. // success: {
  50. // expt.fulfill()
  51. // },
  52. // failure: {
  53. // print("error: \($0)")
  54. // expt.fulfill()
  55. // }
  56. // )
  57. // wait(for: [expt], timeout: 5.0)
  58. }
  59. func testFetchOrderHistory() {
  60. let service = OrderHistoryService()
  61. let expt = expectation(description: "testFetchOrderHistory")
  62. service.fetchOrderHistory(
  63. from: "2019-05-01",
  64. to: "2019-05-11",
  65. success: { _ in
  66. expt.fulfill()
  67. },
  68. failure: { _ in
  69. expt.fulfill()
  70. }
  71. )
  72. wait(for: [expt], timeout: 5.0)
  73. }
  74. func testFetchHotLines() {
  75. // let service = HomeService()
  76. // service.fetchHotLines()
  77. }
  78. func testKFTCRefrsh() {
  79. let service = AutoDebitService()
  80. let service2 = AddAccountService()
  81. let expt = expectation(description: "Test KFTC Refresh")
  82. service.refreshTokenStep1(
  83. username: "maxkim@gmeremit.com",
  84. success: {
  85. let url = "\($0?.url?.replacingOccurrences(of: "&lang=", with: "&lang=kor") ?? "")"
  86. var header = [String: String]()
  87. $0?.header?.forEach({
  88. header[$0.key ?? ""] = $0.value ?? ""
  89. })
  90. service2.fetchKftcUrlService(
  91. url: url,
  92. header: header,
  93. success: {
  94. print("Fetched URL: \($0 ?? "URL IS NULL")")
  95. expt.fulfill()
  96. },
  97. failure: {
  98. print("Fetch URL Error: \($0)")
  99. expt.fulfill()
  100. }
  101. )
  102. },
  103. failure: {
  104. print("Error: \($0)")
  105. expt.fulfill()
  106. }
  107. )
  108. wait(for: [expt], timeout: 60)
  109. }
  110. func testFetchCountryService() {
  111. // let expt = expectation(description: "testDynamicReceiver")
  112. // let service = SetupRecipientService()
  113. }
  114. func testDynamicReceiver() {
  115. let expt = expectation(description: "testDynamicReceiver")
  116. let service = SetupRecipientService()
  117. service.fetchDynamicReceiverFields(
  118. of: "104",
  119. paymentModeID: "2",
  120. success: {
  121. print($0.dynamicField?.count ?? 0)
  122. expt.fulfill()
  123. },
  124. failure: {
  125. XCTAssert(false, $0.localizedDescription)
  126. expt.fulfill()
  127. }
  128. )
  129. wait(for: [expt], timeout: 5.0)
  130. }
  131. func testFecthRecipients() {
  132. let expt = expectation(description: "testFecthRecipients")
  133. let service = RecipientsService()
  134. service.fetchRecipients(
  135. success: {
  136. print($0.accounts?.count ?? 0)
  137. print($0.recipients?.count ?? 0)
  138. XCTAssert(true)
  139. expt.fulfill()
  140. },
  141. failure: {
  142. XCTAssert(false, $0.localizedDescription)
  143. expt.fulfill()
  144. }
  145. )
  146. wait(for: [expt], timeout: 1000.0)
  147. }
  148. func testFetchBranch() {
  149. let expt = expectation(description: "textFetchBranch")
  150. let service = TablePresenterService()
  151. service.fetchBranches(
  152. countryCode: "",
  153. bankID: "",
  154. branchName: "",
  155. success: {
  156. print($0.count)
  157. expt.fulfill()
  158. XCTAssert(true)
  159. },
  160. failure: {
  161. expt.fulfill()
  162. XCTAssert(false, $0.localizedDescription)
  163. })
  164. wait(for: [expt], timeout: 5.0)
  165. }
  166. func testDomeRemitStart() {
  167. let expt = expectation(description: "testDomeRemitStart")
  168. let service = DomesticRemitService()
  169. service.fetchInformation(
  170. success: {
  171. print($0)
  172. expt.fulfill()
  173. },
  174. failure: {
  175. expt.fulfill()
  176. XCTAssert(false, $0.localizedDescription)
  177. })
  178. wait(for: [expt], timeout: 5.0)
  179. }
  180. func testRecentHistories() {
  181. let expt = expectation(description: "testRecentHistories")
  182. let service = RecentHistoriesService()
  183. service.fetchHistories(
  184. success: {
  185. print($0)
  186. expt.fulfill()
  187. },
  188. failure: {
  189. expt.fulfill()
  190. XCTAssert(false, $0.localizedDescription)
  191. })
  192. wait(for: [expt], timeout: 5.0)
  193. }
  194. func testGetName() {
  195. let expt = expectation(description: "testGetName")
  196. let service = DomesticRemitService()
  197. service.getRecipientName(
  198. account: "",
  199. bankCode: "",
  200. success: {
  201. print($0)
  202. expt.fulfill()
  203. },
  204. failure: {
  205. expt.fulfill()
  206. XCTAssert(false, $0.localizedDescription)
  207. }
  208. )
  209. wait(for: [expt], timeout: 5.0)
  210. }
  211. func testFetchBalance() {
  212. let expt = expectation(description: "testFetchBalance")
  213. let service = DomesticRemitService()
  214. service.fetchBalance(
  215. type: "",
  216. fintechUseNumber: "",
  217. success: {
  218. print($0)
  219. expt.fulfill()
  220. },
  221. failure: {
  222. expt.fulfill()
  223. XCTAssert(false, $0.localizedDescription)
  224. }
  225. )
  226. wait(for: [expt], timeout: 5.0)
  227. }
  228. func testDomesticTransactionHistories() {
  229. let expt = expectation(description: "testDomesticTransactionHistories")
  230. let service = TransactionHistoryService()
  231. service.fetchDomesticTransactionHistory(
  232. from: "",
  233. to: "",
  234. success: {
  235. print($0)
  236. expt.fulfill()
  237. },
  238. failure: {
  239. expt.fulfill()
  240. XCTAssert(false, $0.localizedDescription)
  241. }
  242. )
  243. wait(for: [expt], timeout: 5.0)
  244. }
  245. func testDomesticReceipt() {
  246. }
  247. func testLoadFormKYC() {
  248. let service = NewRegisterStep1Service()
  249. let expt = expectation(description: "testLoadFormKYC")
  250. server = .uat
  251. service.fetchInformation(
  252. success: {
  253. XCTAssert($0.cities?.count != 0 , "cities data is wrong")
  254. XCTAssert($0.idTypes?.count != 0 , "idTypes data is wrong")
  255. XCTAssert($0.branches?.count != 0 , "branches data is wrong")
  256. XCTAssert($0.banks?.count != 0 , "banks data is wrong")
  257. expt.fulfill()
  258. },
  259. failure: {
  260. XCTAssert(false, $0.localizedDescription)
  261. expt.fulfill()
  262. }
  263. )
  264. wait(for: [expt], timeout: 5.0)
  265. }
  266. }