package com.atlassian.stash.internal.web.conditions;

import com.atlassian.stash.internal.avatar.InternalAvatarService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Collections;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class HasAvatarServiceEnabledConditionTest {

    @Mock
    private InternalAvatarService avatarService;

    @InjectMocks
    private HasAvatarServiceEnabledCondition condition;

    @Test
    public void testDisabledAvatars() throws Exception {
        assertFalse(condition.shouldDisplay(Collections.<String, Object>emptyMap()));
    }

    @Test
    public void testEnabledAvatars() throws Exception {
        when(avatarService.isEnabled()).thenReturn(true);
        assertTrue(condition.shouldDisplay(Collections.<String, Object>emptyMap()));
    }

}
