from src.gameplay.core.tasks.setChatOff import SetChatOffTask


def test_does_not_reopen_chat_after_sending():
    context = {'ng_screenshot': object()}

    assert SetChatOffTask().do(context) is context


def test_waits_until_chat_is_off(mocker):
    context = {'ng_screenshot': object()}
    get_status = mocker.patch(
        'src.gameplay.core.tasks.setChatOff.getChatStatus',
        side_effect=[((1497, 1060, 64, 16), True), ((1494, 1060, 64, 16), False)],
    )
    task = SetChatOffTask()

    assert task.did(context) is False
    assert task.did(context) is True
    assert get_status.call_count == 2
