package com.braintreepayments.cardform.utils;

import android.app.Activity;

import com.braintreepayments.cardform.R;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

import static com.braintreepayments.cardform.test.ColorTestUtils.getColor;
import static com.braintreepayments.cardform.test.ColorTestUtils.setupActivity;
import static junit.framework.Assert.assertEquals;

@RunWith(RobolectricTestRunner.class)
public class ExpirationDateDialogThemeTest {

    @Test
    public void detectTheme_detectsBlackBackgroundAndReturnsLightTheme() {
        Activity activity = setupActivity(R.color.bt_black);

        ExpirationDateDialogTheme theme = ExpirationDateDialogTheme.detectTheme(activity);

        assertEquals(ExpirationDateDialogTheme.LIGHT, theme);
        assertEquals(getColor(R.color.bt_black_87), theme.getItemTextColor());
        assertEquals(getColor(R.color.bt_white_87), theme.getItemInvertedTextColor());
        assertEquals(getColor(R.color.bt_black_38), theme.getItemDisabledTextColor());
    }

    @Test
    public void detectTheme_detectsWhiteBackgroundAndReturnsDarkTheme() {
        Activity activity = setupActivity(R.color.bt_white);

        ExpirationDateDialogTheme theme = ExpirationDateDialogTheme.detectTheme(activity);

        assertEquals(ExpirationDateDialogTheme.DARK, theme);
        assertEquals(getColor(R.color.bt_white_87), theme.getItemTextColor());
        assertEquals(getColor(R.color.bt_black_87), theme.getItemInvertedTextColor());
        assertEquals(getColor(R.color.bt_white_38), theme.getItemDisabledTextColor());
    }

    @Test
    public void getSelectedItemBackground_returnsDefaultColorWhenThereIsNoAccentColor() {
        Activity activity = setupActivity(R.color.bt_white);

        ExpirationDateDialogTheme theme = ExpirationDateDialogTheme.detectTheme(activity);

        assertEquals(getColor(R.color.bt_blue), theme.getSelectedItemBackground());
    }
}

@@ -580,13 +580,12 @@
 urns
-Light
+Dark
 Them
@@ -795,13 +795,12 @@
 eme.
-LIGHT
+DARK
 , th
@@ -838,37 +838,37 @@
 olor(R.color.bt_
-black
+white
 _87), theme.getI
@@ -917,37 +917,37 @@
 olor(R.color.bt_
-white
+black
 _87), theme.getI
@@ -1012,21 +1012,21 @@
 olor.bt_
-black
+white
 _38), th
@@ -1127,36 +1127,37 @@
 groundAndReturns
-Dark
+Light
 Theme() %7B%0A      
@@ -1343,36 +1343,37 @@
 DateDialogTheme.
-DARK
+LIGHT
 , theme);%0A      
@@ -1399,37 +1399,37 @@
 olor(R.color.bt_
-white
+black
 _87), theme.getI
@@ -1478,37 +1478,37 @@
 olor(R.color.bt_
-black
+white
 _87), theme.getI
@@ -1565,37 +1565,37 @@
 olor(R.color.bt_
-white
+black
 _38), theme.getI

Update expiration date tests