Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feature.color-4 into main #2013

Merged
merged 68 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7ddb751
[Color 4] Update tests for Color Level 4 (#1846)
nex3 Dec 9, 2022
017ff98
Use feature branches for testing the JS API (#1853)
nex3 Dec 14, 2022
717b64d
Add tests for color.is-legacy() (#1842)
SondraE Dec 14, 2022
b81eadb
Don't auto-skip dart-sass-embedded along with dart-sass (#1857)
nex3 Dec 16, 2022
cf219a9
Add tests for color.space() (#1851)
SondraE Dec 19, 2022
b380938
[Color 4] Update tests for color.grayscale() (#1850)
dvdherron Dec 20, 2022
5ac09ad
Add tests for all Deprecated Functions (#1852)
SondraE Dec 20, 2022
0265c87
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Jan 18, 2023
1a51b04
Merge branch 'main' of github.com:sass/sass-spec into main-into-color-4
nex3 Jan 18, 2023
4507185
Merge branch 'feature.color-4' of github.com:sass/sass-spec into main…
nex3 Jan 18, 2023
0f0692e
Fix a hue test with the wrong unit
nex3 Jan 18, 2023
ae9ff9b
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Jan 27, 2023
e6687a2
[Color 4] Update tests for color.mix() and color.complement() (#1843)
dvdherron Jan 31, 2023
8c3ef6f
Add Tests for color.is-in-gamut() (#1866)
SondraE Jan 31, 2023
a0573aa
Update specs for sass/sass#3497
nex3 Mar 21, 2023
8d48c8a
Clone linked versions of the embedded compiler and protocol
nex3 Mar 21, 2023
70c8dc2
Merge pull request #1889 from sass/draft-1.4
nex3 Mar 23, 2023
6046861
Merge remote-tracking branch 'origin/main' into feature.color-4
nex3 Aug 2, 2023
acaa8b3
it.skip -> xit for Jasmine compatibility
nex3 Aug 2, 2023
4f03460
Merge branch 'main' of github.com:sass/sass-spec into merge-main
nex3 Aug 21, 2023
380093f
Merge pull request #1929 from sass/merge-main
nex3 Aug 21, 2023
b03c91e
[Color 4] Add tests for `lab()` (#1928)
nex3 Sep 28, 2023
5c8f5aa
Merge branch 'main' of github.com:sass/sass-spec into feature.color-4
nex3 Oct 6, 2023
fab4c67
Update specs for the merge
nex3 Oct 6, 2023
3f05b29
Merge pull request #1946 from sass/merge
nex3 Oct 6, 2023
554a03a
[Color 4] Add tests for oklab() (#1938)
nex3 Oct 6, 2023
248e915
Re-enable and expand tests for relative colors (#1947)
nex3 Oct 10, 2023
79d5328
[Color 4] Add tests for lch() (#1944)
nex3 Oct 11, 2023
4ea6c45
[Color 4] Add tests for the color() function (#1943)
nex3 Oct 13, 2023
081ffe5
[Color 4] Add tests for oklch() (#1945)
nex3 Oct 13, 2023
e409a92
[Color 4] Add tests for missing channels in legacy color spaces (#1948)
nex3 Oct 17, 2023
537c12a
Merge remote-tracking branch 'origin/main' into merge-main
nex3 Nov 16, 2023
7bbd759
Merge pull request #1955 from sass/merge-main
nex3 Nov 17, 2023
7c45b0b
[Color 4] JS API specs (#1949)
jamesnw Nov 17, 2023
1cd28f7
Merge branch 'main' of github.com:sass/sass-spec into feature.color-4
nex3 Mar 27, 2024
9f165a1
Merge pull request #1965 from sass/merge-main
nex3 Mar 27, 2024
fac7453
[Color 4] Update existing specs (#1966)
nex3 Apr 10, 2024
800245a
Merge remote-tracking branch 'origin/main' into merge-main
nex3 Apr 11, 2024
088d34c
Add new deprecations
nex3 Apr 11, 2024
d1f052b
Merge pull request #1976 from sass/merge-main
nex3 Apr 12, 2024
c895d27
Add better tests for the bounds of legacy color space constructors (#…
nex3 Apr 12, 2024
5693526
[Color 4] Add specs for color.to-space() (#1974)
nex3 Apr 12, 2024
5cc6620
[Color 4] Add specs for `color.is-powerless()` (#1975)
nex3 Apr 13, 2024
1760404
Update gamut-mapping specs to use the new method parameter (#1977)
nex3 Apr 19, 2024
71c13cf
Add tests for color.to-gamut() (#1980)
nex3 Apr 24, 2024
5769c74
[Color 4] Add tests for color.channel() (#1978)
nex3 Apr 24, 2024
741f09d
[Color 4] Add tests for `is-missing()` (#1981)
nex3 Apr 26, 2024
2876026
[Color 4] Update specs for `color.change()` (#1983)
nex3 May 2, 2024
231b7ef
[Color 4] Add tests for none in `color.change()` (#1985)
nex3 May 6, 2024
ae633dc
Make color.adjust() tests run against the namespaced function
nex3 May 3, 2024
b693504
Add tests for new color spaces
nex3 May 6, 2024
6c9b90b
Update error tests for `color.adjust()`
nex3 May 7, 2024
a69ff07
Merge pull request #1988 from sass/color-adjust
nex3 May 7, 2024
d6c9aff
[Color 4] Update tests for `color.scale()` (#1989)
nex3 May 9, 2024
c20c741
[Color 4] Add tests for color equality with `same()` and `==` (#1984)
nex3 May 9, 2024
916302c
[Color 4] Update tests for `color.invert()` (#1990)
nex3 May 10, 2024
a92cec7
Update grayscale specs to match other spec styles (#1991)
nex3 May 10, 2024
7e48831
[Color 4] Fix remaining Dart Sass TODOs (#1992)
nex3 May 10, 2024
12fabe2
Add relative color syntax tests for the color() function (#1993)
nex3 May 16, 2024
037a4da
Merge remote-tracking branch 'origin/main' into merge-main
nex3 May 30, 2024
96188b7
Merge pull request #1997 from sass/merge-main
nex3 May 30, 2024
e95562a
[Color 4] Add tests to match updated spec (#1995)
nex3 Jul 18, 2024
00338ba
Coisnstently use double quotes for `@use "sass:color"`
nex3 Aug 12, 2024
250a836
Merge branch 'main' of github.com:sass/sass-spec into merge
nex3 Aug 12, 2024
3756592
Fix static checks
nex3 Aug 12, 2024
c6b6286
Merge pull request #2007 from sass/merge
nex3 Aug 13, 2024
563fb47
Merge branch 'main' of github.com:sass/sass-spec into merge-main
nex3 Sep 11, 2024
80b5428
Merge pull request #2012 from sass/merge-main
nex3 Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
128 changes: 128 additions & 0 deletions js-api-spec/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,29 @@ declare global {
*/
toEqualWithHash(value: immutable.ValueObject): T;

/**
* Matches a number that is equal to `value` using `SassNumber.equals()`.
*/
toFuzzyEqual(value: number): T;

/**
* Matches a number that is equal to `value` to 5 decimal places.
*/
toLooselyEqual(value: number): T;

/**
* Matches a SassColor where each channel in `value` is equal to 5 decimal
* places.
*/
toLooselyEqualColor(value: sass.SassColor): T;

/**
* Matches an array against an Immutable List. Non-numeric values are
* exactly matched, and numbers are fuzzy matched using
* `SassNumber.equals()`.
*/
toFuzzyEqualList(value: unknown[]): T;

/**
* Matches a value that's `null` or `undefined`.
*/
Expand Down Expand Up @@ -312,6 +335,99 @@ const toEqualIgnoringWhitespace = (received: unknown, actual: string) => {
};
};

const toFuzzyEqual = (received: unknown, actual: number) => {
if (typeof received !== 'number') {
throw new Error('Received value must be a number');
}
return {
message: `expected ${received} to fuzzy equal ${actual}`,
pass: new sass.SassNumber(received).equals(new sass.SassNumber(actual)),
};
};

const toLooselyEqual = (received: unknown, actual: number) => {
if (typeof received !== 'number') {
throw new Error('Received value must be a number');
}
return {
message: `expected ${received} to loosely equal ${actual} to 5 decimal places`,
pass: Math.round((received * 10) ^ 5) === Math.round((actual * 10) ^ 5),
};
};

// The max distance two Sass numbers can be from each another before they're
// considered different (2 decimals).
//
// Uses ** instead of Math.pow() for constant folding.
// TODO: Ideally this should be more precise, but ColorJS does not always match.
const epsilon = 10 ** -2;

const toLooselyEqualColor = (received: unknown, actual: sass.SassColor) => {
function isSassColor(item: unknown): item is sass.SassColor {
return !!(item as sass.SassColor).assertColor();
}
if (!isSassColor(received)) {
throw new Error('Received value must be a SassColor');
}
const unequalIndices: number[] = [];
received.channelsOrNull.forEach((channel: number | null, index: number) => {
const actualChannel = actual.channelsOrNull.get(index);
if (channel === null) {
if (actualChannel !== null) unequalIndices.push(index);
} else if (
actualChannel === null ||
Math.abs(channel - actualChannel) > epsilon
) {
unequalIndices.push(index);
}
});
const plural = unequalIndices.length !== 1;
const indexMessage = `${plural ? 'indices' : 'index'} ${unequalIndices.join(
','
)}`;
return {
message: `expected ${received} to loosely equal ${actual}, but channels at ${indexMessage} differ`,
pass: unequalIndices.length === 0,
};
};

const toFuzzyEqualList = (received: unknown, actual: unknown[]) => {
if (!immutable.List.isList(received)) {
throw new Error('Received value must be an Immutuable List');
}
if (received.count() !== actual.length) {
return {
pass: false,
message: `expected List to have length ${
actual.length
}, received ${received.count()}`,
};
}
let pass = true;
let message = '';
received.forEach((receivedItem, index) => {
const actualItem = actual[index];
if (!pass) return;
if (typeof receivedItem !== typeof actualItem) {
pass = false;
message = `expected ${receivedItem} to be the same type as ${actual[index]} at index ${index}`;
}
if (typeof receivedItem === 'number' && typeof actualItem === 'number') {
pass = new sass.SassNumber(receivedItem).equals(
new sass.SassNumber(actualItem)
);
message = `expected ${receivedItem} to fuzzy equal ${actual[index]} at index ${index}`;
} else {
pass = receivedItem === actualItem;
message = `expected non-numeric ${receivedItem} to exactly equal ${actual[index]} at index ${index}`;
}
});
return {
message,
pass,
};
};

// Add custom matchers to Jasmine
beforeAll(() => {
jasmine.addMatchers({
Expand All @@ -330,6 +446,18 @@ beforeAll(() => {
toEqualIgnoringWhitespace: () => ({
compare: toEqualIgnoringWhitespace,
}),
toFuzzyEqual: () => ({
compare: toFuzzyEqual,
}),
toLooselyEqual: () => ({
compare: toLooselyEqual,
}),
toLooselyEqualColor: () => ({
compare: toLooselyEqualColor,
}),
toFuzzyEqualList: () => ({
compare: toFuzzyEqualList,
}),
});
jasmine.addAsyncMatchers({
toThrowSassException: () => ({
Expand Down
Loading
Loading