Skip to content

Commit

Permalink
fixup! Feat(exporters): Variables exporter export new token structure…
Browse files Browse the repository at this point in the history
… #DS-1435
  • Loading branch information
curdaj committed Aug 30, 2024
1 parent 8145ec4 commit ab534d4
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions exporters/variables-scss/generated/exporter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,11 @@ ${r}) !default;
/\n{3,}/g,
`
`,
)),
(y = y.replace(
/\n{2,}$/,
`
`,
)),
y
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;
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;
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import fs from 'fs';
import path from 'path';
import { formatCSS } from '../cssFormatter';

const mockedCSS = `$my-var: (
color: #000,
background: #fff,
border: 1px solid #000
) !default;`;
const mockedUnformattedCSS = fs.readFileSync(
path.join(__dirname, '../../__fixtures__/unformattedExample.scss'),
'utf-8',
);

const mockedFormattedCSS = `$my-var: (
color: #000,
background: #fff,
border: 1px solid #000
) !default;\n`;
const mockedFormattedCSS = fs.readFileSync(path.join(__dirname, '../../__fixtures__/formattedExample.scss'), 'utf-8');

describe('formatCSS', () => {
it('should correctly format CSS string', () => {
expect(formatCSS(mockedCSS)).toBe(mockedFormattedCSS);
expect(formatCSS(mockedUnformattedCSS)).toBe(mockedFormattedCSS);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ export const formatCSS = (css: string): string => {
// Remove extra blank lines
formattedCSS = formattedCSS.replace(/\n{3,}/g, '\n\n');

// Replace two or more new lines at the end of the file with a single new line
formattedCSS = formattedCSS.replace(/\n{2,}$/, '\n');

return formattedCSS;
};
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 './mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../__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
@@ -1,6 +1,6 @@
import { Token, TokenGroup } from '@supernovaio/sdk-exporters';
import { generateCssObjectFromTokens, generateObjectContent } from '../cssObjectGenerator';
import { exampleMockedGroups, exampleMockedTokens } from './mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../__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
@@ -1,6 +1,6 @@
import { Token, TokenGroup } from '@supernovaio/sdk-exporters';
import { tokenVariableName } from '../tokenHelper';
import { exampleMockedGroups, exampleMockedTokens } from '../../generators/__tests__/mockedExampleTokens';
import { exampleMockedGroups, exampleMockedTokens } from '../../__fixtures__/mockedExampleTokens';

describe('tokenHelper', () => {
it('should return the expected variable name for exampleToken', () => {
Expand Down

0 comments on commit ab534d4

Please sign in to comment.