Skip to content

Commit

Permalink
[Color 4] Update tests for Color Level 4 (#1846)
Browse files Browse the repository at this point in the history
This updates most tests for the currently-implemented chunk of the
Color 4 feature. A few tests that need more thorough reworking (such
as being moved out of `error/` for things that are no longer intended
to be errors) are marked as "todo" instead.

See #1828
See sass/sass#2831
  • Loading branch information
nex3 authored Dec 9, 2022
1 parent 360a369 commit 7ddb751
Show file tree
Hide file tree
Showing 149 changed files with 2,332 additions and 4,824 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,8 @@ on:
pull_request:

jobs:
unit_tests_rb:
name: "Unit tests | Ruby"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with: {bundler-cache: true}
- name: Run tests
run: bundle exec rspec tests/

unit_tests_ts:
name: "Unit tests | Typescript"
unit_tests:
name: "Unit tests"
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -59,17 +48,21 @@ jobs:
- run: npm run lint-spec

dart_sass_language:
name: "Language | Dart Sass"
name: "Language | Dart Sass | Dart ${{ matrix.dart_channel }}"
runs-on: ubuntu-latest
if: "github.event_name != 'pull_request' || !contains(github.event.pull_request.body, 'skip dart-sass')"

strategy:
matrix:
dart_channel: [stable, dev]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with: {node-version: "${{ env.NODE_VERSION }}"}
- run: npm install
- uses: dart-lang/setup-dart@v1
with: {sdk: stable}
with: {sdk: "${{ matrix.dart_channel }}"}

- name: Install dart-sass
run: |
Expand Down Expand Up @@ -164,7 +157,10 @@ jobs:
js_api_sass_embedded:
name: "JS API | sass-embedded | Node ${{ matrix.node_version }} | ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
if: "github.event_name != 'pull_request' || !contains(github.event.pull_request.body, 'skip sass-embedded')"
if: >-
github.event_name != 'pull_request' ||
(!contains(github.event.pull_request.body, 'skip sass-embedded') &&
!contains(github.event.pull_request.body, 'skip dart-sass'))
strategy:
fail-fast: false
Expand Down
15 changes: 0 additions & 15 deletions Gemfile

This file was deleted.

106 changes: 0 additions & 106 deletions Gemfile.lock

This file was deleted.

36 changes: 21 additions & 15 deletions js-api-spec/value/color.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ describe('SassColor', () => {
expect(() => rgb(255, 255, 255, 1)).not.toThrow();
});

it('disallows invalid values', () => {
// TODO(#1828): Update these expectations
it.skip('disallows invalid values', () => {
expect(() => rgb(-1, 0, 0, 0)).toThrow();
expect(() => rgb(0, -1, 0, 0)).toThrow();
expect(() => rgb(0, 0, -1, 0)).toThrow();
Expand All @@ -80,7 +81,8 @@ describe('SassColor', () => {
expect(() => rgb(0, 0, 0, 1.1)).toThrow();
});

it('rounds channels to the nearest integer', () => {
// TODO(#1828): Update these expectations
it.skip('rounds channels to the nearest integer', () => {
expect(rgb(0.1, 50.4, 90.3)).toEqualWithHash(rgb(0, 50, 90));
expect(rgb(-0.1, 50.5, 90.7)).toEqualWithHash(rgb(0, 51, 91));
});
Expand Down Expand Up @@ -178,15 +180,16 @@ describe('SassColor', () => {

it('has HWB channels', () => {
expect(color.hue).toBe(120);
expect(color.whiteness).toBe(24.313725490196077);
expect(color.blackness).toBe(40.3921568627451);
expect(color.whiteness).toBe(24.360000000000003);
expect(color.blackness).toBe(40.36000000000001);
});

it('has an alpha channel', () => {
expect(color.alpha).toBe(1);
});

it('equals the same color', () => {
// TODO(#1828): Update these expectations
it.skip('equals the same color', () => {
expect(color).toEqualWithHash(rgb(62, 152, 62));
expect(color).toEqualWithHash(hsl(120, 42, 42));
expect(color).toEqualWithHash(
Expand Down Expand Up @@ -214,21 +217,22 @@ describe('SassColor', () => {

it('has HSL channels', () => {
expect(color.hue).toBe(120);
expect(color.saturation).toBe(16.078431372549026);
expect(color.saturation).toBe(16.000000000000007);
expect(color.lightness).toBe(50);
});

it('has HWB channels', () => {
expect(color.hue).toBe(120);
expect(color.whiteness).toBe(41.96078431372549);
expect(color.blackness).toBe(41.96078431372548);
expect(color.whiteness).toBe(42);
expect(color.blackness).toBe(42);
});

it('has an alpha channel', () => {
expect(color.alpha).toBe(1);
});

it('equals the same color', () => {
// TODO(#1828): Update these expectations
it.skip('equals the same color', () => {
expect(color).toEqualWithHash(rgb(107, 148, 107));
expect(color).toEqualWithHash(hsl(120, 16.078431372549026, 50));
expect(color).toEqualWithHash(
Expand Down Expand Up @@ -272,7 +276,8 @@ describe('SassColor', () => {
expect(color.change({alpha: 1}).alpha).toBe(1);
});

it('disallows invalid values', () => {
// TODO(#1828): Update these expectations
it.skip('disallows invalid values', () => {
expect(() => color.change({red: -1})).toThrow();
expect(() => color.change({red: 256})).toThrow();
expect(() => color.change({green: -1})).toThrow();
Expand All @@ -283,7 +288,8 @@ describe('SassColor', () => {
expect(() => color.change({alpha: 1.1})).toThrow();
});

it('rounds channels to the nearest integer', () => {
// TODO(#1828): Update these expectations
it.skip('rounds channels to the nearest integer', () => {
expect(
color.change({red: 0.1, green: 50.4, blue: 90.3})
).toEqualWithHash(rgb(0, 50, 90));
Expand Down Expand Up @@ -371,11 +377,11 @@ describe('SassColor', () => {

it('allows valid values', () => {
expect(color.change({whiteness: 0}).whiteness).toBe(0);
expect(color.change({whiteness: 100}).whiteness).toBe(60.0);
expect(color.change({blackness: 0}).blackness).toBe(0);
expect(color.change({blackness: 100}).blackness).toBe(
93.33333333333333
expect(color.change({whiteness: 100}).whiteness).toBe(
60.141509433962256
);
expect(color.change({blackness: 0}).blackness).toBe(0);
expect(color.change({blackness: 100}).blackness).toBe(93.4065934065934);
expect(color.change({alpha: 0}).alpha).toBe(0);
expect(color.change({alpha: 1}).alpha).toBe(1);
});
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion lib-js/compiler.ts → lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export class DartCompiler implements Compiler {
throw new Error(`${repoPath} is not a valid Dart Sass repository`);
}
const dartFile = `
// @dart=2.9
import "dart:convert";
import "dart:io";
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions lib/sass_spec.rb

This file was deleted.

6 changes: 0 additions & 6 deletions lib/sass_spec/annotate.rb

This file was deleted.

Loading

0 comments on commit 7ddb751

Please sign in to comment.