|
1 | 1 | import { afterAll, beforeEach, describe, expect, test } from 'bun:test' |
2 | 2 | import { resetTextStyleCache } from '../../utils' |
3 | | -import { Codegen, resetGlobalBuildTreeCache } from '../Codegen' |
| 3 | +import { |
| 4 | + Codegen, |
| 5 | + getGlobalAssetNodes, |
| 6 | + resetGlobalAssetNodes, |
| 7 | + resetGlobalBuildTreeCache, |
| 8 | +} from '../Codegen' |
4 | 9 | import { resetGetPropsCache } from '../props' |
5 | 10 | import { resetSelectorPropsCache } from '../props/selector' |
6 | 11 | import { ResponsiveCodegen } from '../responsive/ResponsiveCodegen' |
@@ -47,19 +52,36 @@ import { ResponsiveCodegen } from '../responsive/ResponsiveCodegen' |
47 | 52 |
|
48 | 53 | beforeEach(() => { |
49 | 54 | resetGlobalBuildTreeCache() |
| 55 | + resetGlobalAssetNodes() |
50 | 56 | resetGetPropsCache() |
51 | 57 | resetSelectorPropsCache() |
52 | 58 | resetTextStyleCache() |
53 | 59 | }) |
54 | 60 |
|
55 | 61 | afterAll(() => { |
56 | 62 | resetGlobalBuildTreeCache() |
| 63 | + resetGlobalAssetNodes() |
57 | 64 | resetGetPropsCache() |
58 | 65 | resetSelectorPropsCache() |
59 | 66 | resetTextStyleCache() |
60 | 67 | ;(globalThis as { figma?: unknown }).figma = undefined |
61 | 68 | }) |
62 | 69 |
|
| 70 | +describe('globalAssetNodes', () => { |
| 71 | + test('resetGlobalAssetNodes clears and getGlobalAssetNodes returns empty map', () => { |
| 72 | + resetGlobalAssetNodes() |
| 73 | + const assets = getGlobalAssetNodes() |
| 74 | + expect(assets.size).toBe(0) |
| 75 | + }) |
| 76 | + |
| 77 | + test('getGlobalAssetNodes returns readonly map', () => { |
| 78 | + const assets = getGlobalAssetNodes() |
| 79 | + expect(typeof assets.get).toBe('function') |
| 80 | + expect(typeof assets.has).toBe('function') |
| 81 | + expect(typeof assets.size).toBe('number') |
| 82 | + }) |
| 83 | +}) |
| 84 | + |
63 | 85 | function createComponentNode( |
64 | 86 | name: string, |
65 | 87 | variantProperties: Record<string, string>, |
|
0 commit comments