mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-21 21:31:11 +01:00
Add tests for SassNumber.valueInRange() (#212)
This commit is contained in:
parent
9d207b13ec
commit
b1b9eca66a
@ -48,6 +48,19 @@ main() {
|
|||||||
expect(value.valueInUnits(["abc"], ["def"]), equals(123));
|
expect(value.valueInUnits(["abc"], ["def"]), equals(123));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group("valueInRange()", () {
|
||||||
|
test("returns its value within a given range", () {
|
||||||
|
expect(value.valueInRange(0, 123), equals(123));
|
||||||
|
expect(value.valueInRange(123, 123), equals(123));
|
||||||
|
expect(value.valueInRange(123, 1000), equals(123));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("rejects a value outside the range", () {
|
||||||
|
expect(() => value.valueInRange(0, 122), throwsSassScriptException);
|
||||||
|
expect(() => value.valueInRange(124, 1000), throwsSassScriptException);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("equals the same number", () {
|
test("equals the same number", () {
|
||||||
expect(value, equalsWithHash(new SassNumber(123)));
|
expect(value, equalsWithHash(new SassNumber(123)));
|
||||||
});
|
});
|
||||||
@ -136,6 +149,19 @@ main() {
|
|||||||
equalsWithHash(
|
equalsWithHash(
|
||||||
new SassNumber(123 - math.pow(10, -SassNumber.precision - 1))));
|
new SassNumber(123 - math.pow(10, -SassNumber.precision - 1))));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group("valueInRange()", () {
|
||||||
|
test("clamps within the given range", () {
|
||||||
|
expect(value.valueInRange(0, 123), equals(123));
|
||||||
|
expect(value.valueInRange(123, 123), equals(123));
|
||||||
|
expect(value.valueInRange(123, 1000), equals(123));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("rejects a value outside the range", () {
|
||||||
|
expect(() => value.valueInRange(0, 122), throwsSassScriptException);
|
||||||
|
expect(() => value.valueInRange(124, 1000), throwsSassScriptException);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group("an integer with a single numerator unit", () {
|
group("an integer with a single numerator unit", () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user