Skip to content

Commit

Permalink
fixup! Feat(variables-scss): Export to javascript #DS-1437
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Sep 26, 2024
1 parent 06c7119 commit 6f13b0d
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ const mockedExpectedResult = fs.readFileSync(
const mappedTokens: Map<string, Token> = new Map([]);
const tokenGroups: Array<TokenGroup> = exampleGroups;
const emptyFile = `/* This file was generated by Supernova, don't change manually */\n\n`;
const indexFile = fs.readFileSync(path.join(__dirname, '../__fixtures__/barrelFileMock.scss'), 'utf-8');
const indexColorFile = `@forward 'colors';\n`;
const indexJsFile = `export * from './borders';
const barrelFile = fs.readFileSync(path.join(__dirname, '../__fixtures__/barrelFileMock.scss'), 'utf-8');
const barrelColorFile = `@forward 'colors';\n`;
const barrelJsFile = `export * from './borders';
export * from './other';
export * from './radii';
export * from './spacing';
export * from './shadows';
export * from './gradients';
export * from './typography';
`;
const indexJsColorFile = `export * from './colors';\n`;
const barrelJsColorFile = `export * from './colors';\n`;

const mockedTsFile = `/* This file was generated by Supernova, don't change manually */
export const gridSpacingDesktop = '32px';\n
Expand Down Expand Up @@ -93,22 +93,22 @@ describe('fileGenerator', () => {
{ path: './js/global/', fileName: 'shadows.ts', content: emptyFile },
{ path: './js/global/', fileName: 'gradients.ts', content: emptyFile },
{ path: './js/global/', fileName: 'typography.ts', content: emptyFile },
// Global index files
{ path: './scss/global/', fileName: 'index.scss', content: indexFile },
{ path: './js/global/', fileName: 'index.ts', content: indexJsFile },
// Root index files
// Global barrel files
{ path: './scss/global/', fileName: 'index.scss', content: barrelFile },
{ path: './js/global/', fileName: 'index.ts', content: barrelJsFile },
// Root barrel files
{ path: './scss/', fileName: '@global.scss', content: `@forward 'global';\n` },
{ path: './js/', fileName: '@global.ts', content: `export * from './global';\n` },
// Themes files
{ path: './scss/themes/theme-light/', fileName: '_colors.scss', content: emptyFile },
{ path: './js/themes/theme-light/', fileName: 'colors.ts', content: emptyFile },
{ path: './scss/themes/theme-light/', fileName: 'index.scss', content: indexColorFile },
{ path: './js/themes/theme-light/', fileName: 'index.ts', content: indexJsColorFile },
{ path: './scss/themes/theme-light/', fileName: 'index.scss', content: barrelColorFile },
{ path: './js/themes/theme-light/', fileName: 'index.ts', content: barrelJsColorFile },
{ path: './scss/themes/theme-light-inverted/', fileName: '_colors.scss', content: emptyFile },
{ path: './js/themes/theme-light-inverted/', fileName: 'colors.ts', content: emptyFile },
{ path: './scss/themes/theme-light-inverted/', fileName: 'index.scss', content: indexColorFile },
{ path: './js/themes/theme-light-inverted/', fileName: 'index.ts', content: indexJsColorFile },
// Themes root index files
{ path: './scss/themes/theme-light-inverted/', fileName: 'index.scss', content: barrelColorFile },
{ path: './js/themes/theme-light-inverted/', fileName: 'index.ts', content: barrelJsColorFile },
// Themes root barrel files
{ path: './scss/', fileName: '@themes.scss', content: mockedRootThemeFile },
{ path: './js/', fileName: '@themes.ts', content: mockedRootThemeJsFile },
]);
Expand Down Expand Up @@ -139,32 +139,32 @@ describe('fileGenerator', () => {
const dataProvider = [
{
files: [{ fileName: 'borders', content: emptyFile }],
description: 'should generate index file with one file',
description: 'should generate barrel file with one file',
expectedBarrelFile: `@forward 'borders';\n`,
},
{
files: [
{ fileName: 'borders', content: emptyFile },
{ fileName: 'other', content: mockedExpectedResult },
],
description: 'should generate index file with multiple files',
description: 'should generate barrel file with multiple files',
expectedBarrelFile: `@forward 'borders';\n@forward 'other';\n`,
},
{
files: [
{ fileName: 'borders', content: emptyFile },
{ fileName: 'other', content: mockedExpectedResult },
],
description: 'should generate index file with one file with js output',
description: 'should generate barrel file with one file with js output',
hasJsOutput: true,
expectedBarrelFile: `export * from './borders';\nexport * from './other';\n`,
},
];

it.each(dataProvider)('$description', ({ files, expectedBarrelFile, hasJsOutput }) => {
const mockedIndexFile = generateBarrelFile(files, hasJsOutput);
const mockedBarrelFile = generateBarrelFile(files, hasJsOutput);

expect(mockedIndexFile).toBe(expectedBarrelFile);
expect(mockedBarrelFile).toBe(expectedBarrelFile);
});
});

Expand Down

0 comments on commit 6f13b0d

Please sign in to comment.