//
//  BannerContentTests.swift
//  PascalTests
//
//  Created by Gilbert Lo on 2/18/20.
//  Copyright © 2020 Evidation Health, Inc. All rights reserved.
//

import XCTest
@testable import EvidationCommonUI

class BannerContentTests: EvidationCommonUITests {

    func testInit() {
        var json: [String: Any] = [
            "name": "hk_data",
            "image_url": "icon-healthApp-24",
            "body": "We're not receiving your activity and health data from the Health app.",
            "button_text": "Learn how to fix it ›",
            "link_url": "pascal://profile/faq/faq_health_app_problems",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        
        let banner = BannerContent(json: json)
        XCTAssertNotNil(banner)
        XCTAssertEqual(banner!.name, "hk_data")
        XCTAssertEqual(banner!.imageUrl, "icon-healthApp-24")
        XCTAssertEqual(banner!.body, "We're not receiving your activity and health data from the Health app.")
        XCTAssertEqual(banner!.linkUrl, "pascal://profile/faq/faq_health_app_problems")
        XCTAssertEqual(banner!.isDismissible, true)
        XCTAssertEqual(banner!.reshowPeriod, 30)
        
        // Test with nil link_url
        json = [
            "name": "hk_data",
            "image_url": "icon-healthApp-24",
            "body": "We're not receiving your activity and health data from the Health app.",
            "button_text": "Learn how to fix it ›",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        XCTAssertNotNil(BannerContent(json: json))
    }
    
    func testNilInit() {
        // Test with no name
        var json: [String: Any] = [
            "image_url": "icon-healthApp-24",
            "body": "We're not receiving your activity and health data from the Health app.",
            "button_text": "Learn how to fix it ›",
            "link_url": "pascal://profile/faq/faq_health_app_problems",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        XCTAssertNil(BannerContent(json: json))
        
        // Test with no image_url
        json = [
            "name": "hk_data",
            "body": "We're not receiving your activity and health data from the Health app.",
            "button_text": "Learn how to fix it ›",
            "link_url": "pascal://profile/faq/faq_health_app_problems",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        XCTAssertNil(BannerContent(json: json))
        
        // Test with no body
        json = [
            "name": "hk_data",
            "image_url": "icon-healthApp-24",
            "button_text": "Learn how to fix it ›",
            "link_url": "pascal://profile/faq/faq_health_app_problems",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        XCTAssertNil(BannerContent(json: json))
        
        // Test with no button text
        json = [
            "name": "hk_data",
            "image_url": "icon-healthApp-24",
            "body": "We're not receiving your activity and health data from the Health app.",
            "link_url": "pascal://profile/faq/faq_health_app_problems",
            "is_dismissible": true,
            "reshow_period": 30
        ]
        XCTAssertNil(BannerContent(json: json))
    }
    
}
