Skip to content

Commit

Permalink
fix tests after remove bootstrap versions < 5
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf committed Oct 17, 2024
1 parent 4bf9011 commit bd773a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ export default class BootstrapExtractor {
const variables = await this.readSassFile('_variables.scss');

const variablesDarkFile = '_variables-dark.scss';
const variablesDark = this.version === 5 && existsSync(this.getFilePath(variablesDarkFile))
? await this.readSassFile(variablesDarkFile)
: ''; // TODO: can be removed safely in bootstrap@6

let variablesDark = '';

if(existsSync(this.getFilePath(variablesDarkFile))) {
variablesDark = await this.readSassFile(variablesDarkFile)
}

const result = `${functions}
${variables.replace('@import "variables-dark";', '')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,21 @@ ${collectorServiceCode}`);
});

test('extract (bootstrap 5)', async () => {
const input = '$var1: test1;$var2: test2 !default;$custom-var: test3;$var4: var(--bs-blue);';
const input = '$var1: test1;$var2: test2 !default;$custom-var: test3;$var4: var(--bs-blue);$var5: -.25rem;';
const extractor = new BootstrapExtractor(input, 5);
extractor.meta = {
'dx-var1': '$var1',
'dx-var2': '$var2',
'dx-var3': '$var3',
'dx-var4': '$var4',
'dx-var5': '$var5',
};

expect(await extractor.extract()).toEqual([
{ key: '$dx-var1', value: 'test1' },
{ key: '$dx-var2', value: 'test2' },
{ key: '$dx-var4', value: '#0d6efd' },
{ key: '$dx-var5', value: '-4px' },
]);
});
});

0 comments on commit bd773a6

Please sign in to comment.