Skip to content

Commit

Permalink
continue: add tests for sass
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattchewone committed Jan 28, 2025
1 parent 70f83fa commit c474078
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/tests/__snapshots__/background-processors.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Background Processors should process background solid correctly - sass: solid styles 1`] = `
"// Generated SCSS Variables
$brand-primary: #00464a;
$teal-800-50: #00464a80;
$teal-medium: #04646a;
$teal-dark: #00464a;
$brand-secondary: #04646a;
// Generated SCSS Mixins
@mixin background-solid-variable
background: $brand-primary;
@mixin background-solid-alpha-variable
background: $teal-800-50;
@mixin background-solid-custom
background: #00464a;
@mixin background-solid-alpha-custom
background: #00464a80;
"
`;

exports[`Background Processors should process background solid correctly: solid styles 1`] = `
{
"alpha": "background: #00464a80;",
Expand Down
37 changes: 36 additions & 1 deletion src/tests/background-processors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { collectTokens } from '../services';
import { transformToCss } from '../transformers';
import { transformToCss, transformToScss } from '../transformers';
import testData from './fixtures/figma-test-data.json';
import { createTestVariableResolver } from '../utils/test.utils';

Expand Down Expand Up @@ -54,6 +54,41 @@ describe('Background Processors', () => {
expect(styles.alpha).toBe('background: #00464a80;');
});

it('should process background solid correctly - sass', async () => {
const pageNode = {
...testData,
type: 'PAGE',
name: 'background',
parent: null,
width: 100,
height: 100
};

const children = testData.children.map((child: BaseNode) => ({
...child,
parent: pageNode,
width: 100,
height: 100
}));
pageNode.children = children;

// Create variable resolver with complete test data
const getVariableByIdAsync = await createTestVariableResolver(testData);

// Mock Figma API
global.figma = {
currentPage: pageNode,
variables: {
getVariableByIdAsync
}
};

const tokens = await collectTokens();
const scss = transformToScss(tokens);

expect(scss).toMatchSnapshot('solid styles');
});

it.skip('should process background gradient correctly', async () => {
// Create proper node hierarchy in test data
const pageNode = {
Expand Down

0 comments on commit c474078

Please sign in to comment.