//
//  MCPlusAPIClientTests.swift
//  MCPlusTests
//
//  Created by seo ha on 19/03/2019.
//  Copyright © 2019 KangSH. All rights reserved.
//

import XCTest
@testable import kunkuk

class MCPlusAPIClientTests: XCTestCase {
    
    override func setUp() {
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }
    
    func testVersionCheck(){
        // given
        let promise = expectation(description: "Status code: 200")
        
        // when
        var param = [String:Any]()
        param["platformType"] = Constants.PLATFORM_TYPE
        param["appName"] = MCarePlusConstants.APP_NAME
        param["certType"] = MCarePlusConstants.CERT_TYPE
        
        var isSuccess = false
        
        APIClient("\(MCarePlusConstants.DOMAIN_NAME)\(MCarePlusConstants.APP_NAME)\(Constants.API_TYPE_VERSION_CHECK).json")
            .param(reqParam: param)
            .enType(.json)
            .connect { (result:[String:Any]) in
                
                let versionOrder = result["versionOrder"] as? Float ?? 0
                if versionOrder > 0{
                    isSuccess = true
                }
                
                promise.fulfill()
        }
        
        waitForExpectations(timeout: 5, handler: nil)
        
        //then
        XCTAssertTrue(isSuccess)
        
    }
    
    
}
