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.

116 lines
2.9 KiB

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