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.

124 lines
2.8 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
  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)")
  29. expt.fulfill()
  30. },
  31. failure: {
  32. print("error: \($0)")
  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. var params = ["CustomerId": "85074"]
  42. params["BankCode"] = "034"
  43. params["AccountNumber"] = "1234512345"
  44. service.verifyAccountService(
  45. params: params,
  46. success: {
  47. expt.fulfill()
  48. },
  49. failure: {
  50. print("error: \($0)")
  51. expt.fulfill()
  52. }
  53. )
  54. wait(for: [expt], timeout: 5.0)
  55. }
  56. func testFetchOrderHistory() {
  57. let service = OrderHistoryService()
  58. let expt = expectation(description: "testFetchOrderHistory")
  59. service.fetchOrderHistory(
  60. from: "2019-05-01",
  61. to: "2019-05-11",
  62. success: { _ in
  63. expt.fulfill()
  64. },
  65. failure: { _ in
  66. expt.fulfill()
  67. }
  68. )
  69. wait(for: [expt], timeout: 5.0)
  70. }
  71. func testFetchHotLines() {
  72. // let service = HomeService()
  73. // service.fetchHotLines()
  74. }
  75. func testKFTCRefrsh() {
  76. let service = AutoDebitService()
  77. let service2 = AddAccountService()
  78. let expt = expectation(description: "Test KFTC Refresh")
  79. service.refreshTokenStep1(
  80. username: "maxkim@gmeremit.com",
  81. success: {
  82. let url = "\($0?.url?.replacingOccurrences(of: "&lang=", with: "&lang=kor") ?? "")"
  83. var header = [String: String]()
  84. $0?.header?.forEach({
  85. header[$0.key ?? ""] = $0.value ?? ""
  86. })
  87. service2.fetchKftcUrlService(
  88. url: url,
  89. header: header,
  90. success: {
  91. print("Fetched URL: \($0 ?? "URL IS NULL")")
  92. expt.fulfill()
  93. },
  94. failure: {
  95. print("Fetch URL Error: \($0)")
  96. expt.fulfill()
  97. }
  98. )
  99. },
  100. failure: {
  101. print("Error: \($0)")
  102. expt.fulfill()
  103. }
  104. )
  105. wait(for: [expt], timeout: 60)
  106. }
  107. }