Skip to content

Commit 350918f

Browse files
committed
Update and consolidate background -color tests to cover recent color parsing fixes
1 parent cb19e8f commit 350918f

1 file changed

Lines changed: 11 additions & 46 deletions

File tree

src/ExCSS.Tests/PropertyTests/BackgroundProperty.cs

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -144,60 +144,25 @@ public void BackgroundColorTealLegal()
144144
Assert.Equal("rgb(0, 128, 128)", concrete.Value);
145145
}
146146

147-
[Fact]
148-
public void BackgroundColorRgbLegal()
149-
{
150-
var snippet = "background-color : rgb(255 , 255 , 128)";
151-
var property = ParseDeclaration(snippet);
152-
Assert.Equal("background-color", property.Name);
153-
Assert.False(property.IsImportant);
154-
Assert.IsType<BackgroundColorProperty>(property);
155-
var concrete = (BackgroundColorProperty)property;
156-
Assert.False(concrete.IsInherited);
157-
Assert.True(concrete.HasValue);
158-
Assert.Equal("rgb(255, 255, 128)", concrete.Value);
159-
}
160-
161-
[Fact]
162-
public void BackgroundColorHslaLegal()
163-
{
164-
var snippet = "background-color : hsla(50, 33%, 25%, 0.75)";//equal to rgba(85, 78, 43, 0.75)
165-
var property = ParseDeclaration(snippet);
166-
Assert.Equal("background-color", property.Name);
167-
Assert.False(property.IsImportant);
168-
Assert.IsType<BackgroundColorProperty>(property);
169-
var concrete = (BackgroundColorProperty)property;
170-
Assert.False(concrete.IsInherited);
171-
Assert.True(concrete.HasValue);
172-
Assert.Equal("hsla(50deg, 33%, 25%, 0.75)", concrete.Value);
173-
}
174-
175-
[Fact]
176-
public void BackgroundColorTransparentLegal()
177-
{
178-
var snippet = "background-color : Transparent";
179-
var property = ParseDeclaration(snippet);
180-
Assert.Equal("background-color", property.Name);
181-
Assert.False(property.IsImportant);
182-
Assert.IsType<BackgroundColorProperty>(property);
183-
var concrete = (BackgroundColorProperty)property;
184-
Assert.False(concrete.IsInherited);
185-
Assert.True(concrete.HasValue);
186-
Assert.Equal("rgba(0, 0, 0, 0)", concrete.Value);
187-
}
188-
189-
[Fact]
190-
public void BackgroundColorHexLegal()
147+
[Theory]
148+
[InlineData("background-color: rgb(255, 255, 128)", "rgb(255, 255, 128)")]
149+
[InlineData("background-color: hsla(50, 33%, 25%, 0.75)", "hsla(50deg, 33%, 25%, 0.75)")]
150+
[InlineData("background-color : rgb(255 , 255 , 128)", "rgb(255, 255, 128)")]
151+
[InlineData("background-color: Transparent", "rgba(0, 0, 0, 0)")]
152+
[InlineData("background-color: #F09", "rgb(255, 0, 153)")]
153+
[InlineData("background-color: #F09F", "rgb(255, 0, 153)")]
154+
[InlineData("background-color: #AABBCC", "rgb(170, 187, 204)")]
155+
[InlineData("background-color: #AABBCC11", "rgba(170, 187, 204, 0.07)")]
156+
public void BackgroundColorRgbLegal(string snippet, string expectedValue)
191157
{
192-
var snippet = "background-color : #bbff00";
193158
var property = ParseDeclaration(snippet);
194159
Assert.Equal("background-color", property.Name);
195160
Assert.False(property.IsImportant);
196161
Assert.IsType<BackgroundColorProperty>(property);
197162
var concrete = (BackgroundColorProperty)property;
198163
Assert.False(concrete.IsInherited);
199164
Assert.True(concrete.HasValue);
200-
Assert.Equal("rgb(187, 255, 0)", concrete.Value);
165+
Assert.Equal(expectedValue, concrete.Value);
201166
}
202167

203168
[Fact]

0 commit comments

Comments
 (0)