aboutsummaryrefslogtreecommitdiff
path: root/tests/test_colors.py
blob: 787495adba488da903ba4dc9c09af962afdfe751 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# ############################################################################ #
#                                                                              #
#                                                         :::      ::::::::    #
#    test_colors.py                                     :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: cacharle <me@cacharle.xyz>                 +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2021/03/03 07:56:43 by cacharle          #+#    #+#              #
#    Updated: 2021/03/03 10:00:43 by cacharle         ###   ########.fr        #
#                                                                              #
# ############################################################################ #

import pytest

from minishell_test import colors


@pytest.fixture
def texts():
    return [
        "",
        "foo",
        "aslkdfj;asdkflaskdjfalskdjflasdf",
        "\n\n\n\n",
        "\t\t\t\t",
    ]


def test_green(texts):
    colors.enable()
    for text in texts:
        assert colors._DEFAULTS["green"] + text + colors._DEFAULTS["close"] == colors.green(text)


def test_red(texts):
    colors.enable()
    for text in texts:
        assert colors._DEFAULTS["red"] + text + colors._DEFAULTS["close"] == colors.red(text)


def test_blue(texts):
    colors.enable()
    for text in texts:
        assert colors._DEFAULTS["blue"] + text + colors._DEFAULTS["close"] == colors.blue(text)


def test_bold(texts):
    colors.enable()
    for text in texts:
        assert colors._DEFAULTS["bold"] + text + colors._DEFAULTS["close"] == colors.bold(text)


def test_toggling(texts):
    colors.disable()
    for text in texts:
        assert text == colors.green(text)
        assert text == colors.red(text)
        assert text == colors.blue(text)
        assert text == colors.bold(text)
    colors.enable()
    for text in texts:
        assert text != colors.green(text)
        assert text != colors.red(text)
        assert text != colors.blue(text)
        assert text != colors.bold(text)
    colors.disable()