Skip to content

Commit

Permalink
fixup! Feat(variables-scss): Formatting color tokens #DS-1461
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Sep 12, 2024
1 parent 2b46337 commit f988888
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 55 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import fs from 'fs';
import path from 'path';
import { formatCSS } from '../cssFormatter';

const mockedUnformattedCSS = fs.readFileSync(path.join(__dirname, '../__fixtures__/unformattedExample.scss'), 'utf-8');
const mockedUnformattedCSS = fs.readFileSync(
path.join(__dirname, '../../../tests/fixtures/unformattedExample.scss'),
'utf-8',
);

const mockedFormattedCSS = fs.readFileSync(path.join(__dirname, '../__fixtures__/formattedExample.scss'), 'utf-8');
const mockedFormattedCSS = fs.readFileSync(
path.join(__dirname, '../../../tests/fixtures/formattedExample.scss'),
'utf-8',
);

describe('formatCSS', () => {
it('should correctly format CSS string', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import fs from 'fs';
import path from 'path';
import { Token, TokenGroup, TokenType } from '@supernovaio/sdk-exporters';
import { generateFileContent, addDisclaimer, filterTokensByTypeAndGroup } from '../contentGenerator';
import { exampleMockedGroups, exampleMockedTokens } from '../../formatters/__fixtures__/mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../../tests/fixtures/mockedExampleTokens';
import { FileData } from '../../config/fileConfig';

const mockedExpectedResult = fs.readFileSync(
path.join(__dirname, '../../formatters/__fixtures__/exampleFileContent.scss'),
path.join(__dirname, '../../../tests/fixtures/exampleFileContent.scss'),
'utf-8',
);
const mappedTokens: Map<string, Token> = new Map([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DimensionToken, StringToken, Token, TokenGroup, TokenType } from '@supernovaio/sdk-exporters';
import { generateCssFromTokens, tokenToCSSByType } from '../cssGenerator';
import { exampleMockedGroups, exampleMockedTokens } from '../../formatters/__fixtures__/mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../../tests/fixtures/mockedExampleTokens';

const mappedTokens: Map<string, Token> = new Map([]);
const tokenGroups: Array<TokenGroup> = exampleMockedGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
exampleMockedGroups,
exampleMockedInvariantTokens,
exampleMockedTokens,
} from '../../formatters/__fixtures__/mockedExampleTokens';
} from '../../../tests/fixtures/mockedExampleTokens';

const mappedTokens: Map<string, Token> = new Map([]);
const tokenGroups: Array<TokenGroup> = exampleMockedGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import fs from 'fs';
import path from 'path';
import { Supernova, Token, TokenGroup, TokenTheme } from '@supernovaio/sdk-exporters';
import { generateFiles, generateOutputFilesByThemes } from '../fileGenerator';
import { exampleMockedGroups, exampleMockedTokens } from '../../formatters/__fixtures__/mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../../tests/fixtures/mockedExampleTokens';
import { nonThemedFilesData } from '../../config/fileConfig';

const mockedExpectedResult = fs.readFileSync(
path.join(__dirname, '../../formatters/__fixtures__/exampleFileContent.scss'),
path.join(__dirname, '../../../tests/fixtures/exampleFileContent.scss'),
'utf-8',
);
const mappedTokens: Map<string, Token> = new Map([]);
Expand Down
52 changes: 11 additions & 41 deletions exporters/variables-scss/src/helpers/__tests__/colorHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
import { canHexBeShortened, normalizeColor, removeAlphaChannel, shortenHex } from '../colorHelper';

const dataProviderItems = [
{
originalColor: 'ffffffff',
expectedColor: '#fff',
},
{
originalColor: '123456',
expectedColor: '#123456',
},
{
originalColor: '123',
expectedColor: '#123',
},
{
originalColor: 'fff',
expectedColor: '#fff',
},
{
originalColor: 'ffffff',
expectedColor: '#fff',
},
{
originalColor: 'ffffff00',
expectedColor: '#fff0',
},
{
originalColor: 'fffffff0',
expectedColor: '#fffffff0',
},
{
originalColor: '96969',
expectedColor: '#96969',
},
{
originalColor: '835ea1',
expectedColor: '#835ea1',
},
{
originalColor: '00000040',
expectedColor: '#00000040',
},
['ffffffff', '#fff'],
['123456', '#123456'],
['123', '#123'],
['fff', '#fff'],
['ffffff', '#fff'],
['ffffff00', '#fff0'],
['fffffff0', '#fffffff0'],
['96969', '#96969'],
['835ea1', '#835ea1'],
['00000040', '#00000040'],
];

describe('colorHelper', () => {
describe.each(dataProviderItems)('normalizeColor', ({ originalColor, expectedColor }) => {
describe.each(dataProviderItems)('normalizeColor', (originalColor, expectedColor) => {
it('should normalize color', () => {
expect(normalizeColor(originalColor)).toBe(expectedColor);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Token, TokenGroup } from '@supernovaio/sdk-exporters';
import { addEmptyLineBetweenTokenGroups, formatTokenName, sortTokens, tokenVariableName } from '../tokenHelper';
import { exampleMockedGroups, exampleMockedTokens } from '../../formatters/__fixtures__/mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../../tests/fixtures/mockedExampleTokens';

const dataProvider = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$my-var: (
color: #000,
background: #fff,
border: 1px solid #000,
) !default;

0 comments on commit f988888

Please sign in to comment.