Skip to content

Commit

Permalink
Test color deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak committed Sep 16, 2024
1 parent 2e5a522 commit f3c949f
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions js-api-spec/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

import {
compileString,
compileStringAsync,

Check warning on line 7 in js-api-spec/deprecations.test.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'compileStringAsync' is defined but never used
deprecations,
renderSync,
Deprecation,
Importer,
Value,
Version,
SassColor,
SassNumber,
} from 'sass';

import {captureStdio, URL} from './utils';
import {captureStdio, captureStdioAsync, runOnlyForImpl, URL} from './utils';

Check warning on line 17 in js-api-spec/deprecations.test.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'captureStdioAsync' is defined but never used

Check warning on line 17 in js-api-spec/deprecations.test.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'runOnlyForImpl' is defined but never used

describe('a warning', () => {
it('is emitted with no flags', done => {
Expand Down Expand Up @@ -227,3 +230,49 @@ describe('for a future deprecation,', () => {
});
});
});

describe('color deprecations', () => {
it('emit a warning outside of any compilation', () => {
const stdio = captureStdio(() => {
new SassColor({red: 255, green: 0, blue: 0, space: 'rgb'}).red;
});
expect(stdio.err).toContain('color-4-api');
});

it('emit a warning when compilation not silenced', () => {
const stdio = captureStdio(() => {
compileString('a { b: fn(red); }', {
functions: {
'fn($color)': (args: Value[]) =>
new SassNumber(args[0].assertColor().red),
},
});
});
expect(stdio.err).toContain('color-4-api');
});

it('emit no warning when silenced in current compilation', () => {
const stdio = captureStdio(() => {
compileString('a { b: fn(red); }', {
silenceDeprecations: ['color-4-api'],
functions: {
'fn($color)': (args: Value[]) =>
new SassNumber(args[0].assertColor().red),
},
});
});
expect(stdio.err).toEqual('');
});

it('throw an error when made fatal in current compilation', () => {
expect(() =>
compileString('a { b: fn(red); }', {
fatalDeprecations: ['color-4-api'],
functions: {
'fn($color)': (args: Value[]) =>
new SassNumber(args[0].assertColor().red),
},
})
).toThrowError();
});
});

0 comments on commit f3c949f

Please sign in to comment.