|
9 | 9 | ) |
10 | 10 |
|
11 | 11 | func TestType_IsValid(t *testing.T) { |
12 | | - t.Run("When type is empty, should not be valid", func(t *testing.T) { |
| 12 | + t.Run("When type is None, should not be valid", func(t *testing.T) { |
13 | 13 | // Arrange |
14 | | - borderType := border.Type("") |
| 14 | + borderType := border.None |
15 | 15 |
|
16 | 16 | // Act & Assert |
17 | 17 | assert.False(t, borderType.IsValid()) |
@@ -52,3 +52,132 @@ func TestType_IsValid(t *testing.T) { |
52 | 52 | assert.True(t, borderType.IsValid()) |
53 | 53 | }) |
54 | 54 | } |
| 55 | + |
| 56 | +func TestType_HasBorders(t *testing.T) { |
| 57 | + t.Run("When type is None, should not have any border", func(t *testing.T) { |
| 58 | + // Arrange |
| 59 | + borderType := border.None |
| 60 | + |
| 61 | + // Act & Assert |
| 62 | + assert.False(t, borderType.HasLeft()) |
| 63 | + assert.False(t, borderType.HasTop()) |
| 64 | + assert.False(t, borderType.HasRight()) |
| 65 | + assert.False(t, borderType.HasBottom()) |
| 66 | + }) |
| 67 | + |
| 68 | + t.Run("When type is Full, should have all borders", func(t *testing.T) { |
| 69 | + // Arrange |
| 70 | + borderType := border.Full |
| 71 | + |
| 72 | + // Act & Assert |
| 73 | + assert.True(t, borderType.HasLeft()) |
| 74 | + assert.True(t, borderType.HasTop()) |
| 75 | + assert.True(t, borderType.HasRight()) |
| 76 | + assert.True(t, borderType.HasBottom()) |
| 77 | + }) |
| 78 | + |
| 79 | + t.Run("When type is Left, should have only left border", func(t *testing.T) { |
| 80 | + // Arrange |
| 81 | + borderType := border.Left |
| 82 | + |
| 83 | + // Act & Assert |
| 84 | + assert.True(t, borderType.HasLeft()) |
| 85 | + assert.False(t, borderType.HasTop()) |
| 86 | + assert.False(t, borderType.HasRight()) |
| 87 | + assert.False(t, borderType.HasBottom()) |
| 88 | + }) |
| 89 | + |
| 90 | + t.Run("When type is combined (Left|Top), should have left and top borders", func(t *testing.T) { |
| 91 | + // Arrange |
| 92 | + borderType := border.Left | border.Top |
| 93 | + |
| 94 | + // Act & Assert |
| 95 | + assert.True(t, borderType.HasLeft()) |
| 96 | + assert.True(t, borderType.HasTop()) |
| 97 | + assert.False(t, borderType.HasRight()) |
| 98 | + assert.False(t, borderType.HasBottom()) |
| 99 | + }) |
| 100 | + |
| 101 | + t.Run("When type is combined (Left|Right), should have left and right borders", func(t *testing.T) { |
| 102 | + // Arrange |
| 103 | + borderType := border.Left | border.Right |
| 104 | + |
| 105 | + // Act & Assert |
| 106 | + assert.True(t, borderType.HasLeft()) |
| 107 | + assert.False(t, borderType.HasTop()) |
| 108 | + assert.True(t, borderType.HasRight()) |
| 109 | + assert.False(t, borderType.HasBottom()) |
| 110 | + }) |
| 111 | + |
| 112 | + t.Run("When type is combined (Top|Bottom), should have top and bottom borders", func(t *testing.T) { |
| 113 | + // Arrange |
| 114 | + borderType := border.Top | border.Bottom |
| 115 | + |
| 116 | + // Act & Assert |
| 117 | + assert.False(t, borderType.HasLeft()) |
| 118 | + assert.True(t, borderType.HasTop()) |
| 119 | + assert.False(t, borderType.HasRight()) |
| 120 | + assert.True(t, borderType.HasBottom()) |
| 121 | + }) |
| 122 | + |
| 123 | + t.Run("When type is combined (Left|Top|Right), should have left, top and right borders", func(t *testing.T) { |
| 124 | + // Arrange |
| 125 | + borderType := border.Left | border.Top | border.Right |
| 126 | + |
| 127 | + // Act & Assert |
| 128 | + assert.True(t, borderType.HasLeft()) |
| 129 | + assert.True(t, borderType.HasTop()) |
| 130 | + assert.True(t, borderType.HasRight()) |
| 131 | + assert.False(t, borderType.HasBottom()) |
| 132 | + }) |
| 133 | +} |
| 134 | + |
| 135 | +func TestType_String(t *testing.T) { |
| 136 | + t.Run("When type is None, should return empty string", func(t *testing.T) { |
| 137 | + // Arrange |
| 138 | + borderType := border.None |
| 139 | + |
| 140 | + // Act & Assert |
| 141 | + assert.Equal(t, "", borderType.String()) |
| 142 | + }) |
| 143 | + |
| 144 | + t.Run("When type is Full, should return 'LTRB'", func(t *testing.T) { |
| 145 | + // Arrange |
| 146 | + borderType := border.Full |
| 147 | + |
| 148 | + // Act & Assert |
| 149 | + assert.Equal(t, "LTRB", borderType.String()) |
| 150 | + }) |
| 151 | + |
| 152 | + t.Run("When type is Left, should return 'L'", func(t *testing.T) { |
| 153 | + // Arrange |
| 154 | + borderType := border.Left |
| 155 | + |
| 156 | + // Act & Assert |
| 157 | + assert.Equal(t, "L", borderType.String()) |
| 158 | + }) |
| 159 | + |
| 160 | + t.Run("When type is combined (Left|Top), should return 'LT'", func(t *testing.T) { |
| 161 | + // Arrange |
| 162 | + borderType := border.Left | border.Top |
| 163 | + |
| 164 | + // Act & Assert |
| 165 | + assert.Equal(t, "LT", borderType.String()) |
| 166 | + }) |
| 167 | + |
| 168 | + t.Run("When type is combined (Left|Right), should return 'LR'", func(t *testing.T) { |
| 169 | + // Arrange |
| 170 | + borderType := border.Left | border.Right |
| 171 | + |
| 172 | + // Act & Assert |
| 173 | + assert.Equal(t, "LR", borderType.String()) |
| 174 | + }) |
| 175 | + |
| 176 | + t.Run("When type is combined (Left|Top|Right), should return 'LTR'", func(t *testing.T) { |
| 177 | + // Arrange |
| 178 | + borderType := border.Left | border.Top | border.Right |
| 179 | + |
| 180 | + // Act & Assert |
| 181 | + assert.Equal(t, "LTR", borderType.String()) |
| 182 | + }) |
| 183 | +} |
0 commit comments