@@ -79,6 +79,72 @@ describe('import-devup (standalone file)', () => {
7979 expect ( loadFontAsync ) . toHaveBeenCalled ( )
8080 } )
8181
82+ test ( 'removes only variables from the Devup color collection' , async ( ) => {
83+ const uploadXlsx = mock ( ( ) =>
84+ Promise . resolve ( {
85+ theme : {
86+ colors : { Light : { primary : '#111111' } } ,
87+ } ,
88+ } ) ,
89+ )
90+ spyOn ( uploadXlsxModule , 'uploadDevupXlsx' ) . mockImplementation ( uploadXlsx )
91+
92+ const removeDevupVariable = mock ( ( ) => { } )
93+ const removeOtherVariable = mock ( ( ) => { } )
94+ const devupVariable = {
95+ id : 'devup-primary' ,
96+ name : 'legacy' ,
97+ setValueForMode : mock ( ( ) => { } ) ,
98+ remove : removeDevupVariable ,
99+ } as unknown as Variable
100+ const otherCollectionVariable = {
101+ id : 'other-primary' ,
102+ name : 'legacy' ,
103+ setValueForMode : mock ( ( ) => { } ) ,
104+ remove : removeOtherVariable ,
105+ } as unknown as Variable
106+ const createdVariable = {
107+ id : 'created-primary' ,
108+ name : 'primary' ,
109+ setValueForMode : mock ( ( ) => { } ) ,
110+ remove : mock ( ( ) => { } ) ,
111+ } as unknown as Variable
112+ const createVariable = mock ( ( ) => createdVariable )
113+ const collection = {
114+ variableIds : [ 'devup-primary' ] ,
115+ modes : [ { modeId : 'light-id' , name : 'Light' } ] ,
116+ addMode : mock ( ( ) => 'light-id' ) ,
117+ removeMode : mock ( ( ) => { } ) ,
118+ } as unknown as VariableCollection
119+
120+ ; ( globalThis as { figma ?: unknown } ) . figma = {
121+ util : { rgba : ( v : unknown ) => v } ,
122+ variables : {
123+ getLocalVariableCollectionsAsync : async ( ) => [ collection ] ,
124+ getLocalVariablesAsync : async ( ) => [
125+ devupVariable ,
126+ otherCollectionVariable ,
127+ ] ,
128+ createVariableCollection : ( ) => collection ,
129+ createVariable,
130+ } ,
131+ getLocalTextStylesAsync : async ( ) => [ ] ,
132+ createTextStyle : mock (
133+ ( ) =>
134+ ( {
135+ name : '' ,
136+ } ) as unknown as TextStyle ,
137+ ) ,
138+ loadFontAsync : mock ( ( ) => Promise . resolve ( ) ) ,
139+ } as unknown as typeof figma
140+
141+ await importDevup ( 'excel' )
142+
143+ expect ( removeDevupVariable ) . toHaveBeenCalledTimes ( 1 )
144+ expect ( removeOtherVariable ) . not . toHaveBeenCalled ( )
145+ expect ( createVariable ) . toHaveBeenCalledWith ( 'primary' , collection , 'COLOR' )
146+ } )
147+
82148 test ( 'imports array typography and skips nulls' , async ( ) => {
83149 const uploadXlsx = mock ( ( ) =>
84150 Promise . resolve ( {
0 commit comments