@@ -103,6 +103,8 @@ describe('devupUIPlugin', () => {
103103 const plugin = new DevupUIWebpackPlugin ( {
104104 devupPath : 'custom-devup.json' ,
105105 } )
106+
107+ vi . mocked ( getCss ) . mockReturnValue ( 'css' )
106108 const compiler = {
107109 options : {
108110 module : {
@@ -114,6 +116,9 @@ describe('devupUIPlugin', () => {
114116 afterCompile : {
115117 tap : vi . fn ( ) ,
116118 } ,
119+ done : {
120+ tap : vi . fn ( ) ,
121+ } ,
117122 watchRun : {
118123 tapAsync : vi . fn ( ) ,
119124 } ,
@@ -131,6 +136,23 @@ describe('devupUIPlugin', () => {
131136 } ,
132137 } )
133138 expect ( add ) . toHaveBeenCalledWith ( resolve ( 'custom-devup.json' ) )
139+ expect ( compiler . hooks . done . tap ) . toHaveBeenCalled ( )
140+
141+ vi . mocked ( compiler . hooks . done . tap ) . mock . calls [ 0 ] [ 1 ] ( {
142+ hasErrors : ( ) => true ,
143+ } )
144+ expect ( writeFileSync ) . not . toHaveBeenCalled ( )
145+
146+ vi . mocked ( compiler . hooks . done . tap ) . mock . calls [ 0 ] [ 1 ] ( {
147+ hasErrors : ( ) => false ,
148+ } )
149+ expect ( writeFileSync ) . toHaveBeenCalledWith (
150+ resolve ( '.df' , 'devup-ui.css' ) ,
151+ 'css' ,
152+ {
153+ encoding : 'utf-8' ,
154+ } ,
155+ )
134156 } )
135157
136158 it ( 'should skip writing css file' , ( ) => {
@@ -155,6 +177,9 @@ describe('devupUIPlugin', () => {
155177 afterCompile : {
156178 tap : vi . fn ( ) ,
157179 } ,
180+ done : {
181+ tap : vi . fn ( ) ,
182+ } ,
158183 watchRun : {
159184 tapAsync : vi . fn ( ) ,
160185 } ,
@@ -191,6 +216,9 @@ describe('devupUIPlugin', () => {
191216 afterCompile : {
192217 tap : vi . fn ( ) ,
193218 } ,
219+ done : {
220+ tap : vi . fn ( ) ,
221+ } ,
194222 watchRun : {
195223 tapAsync : vi . fn ( ) ,
196224 } ,
@@ -208,6 +236,7 @@ describe('devupUIPlugin', () => {
208236 encoding : 'utf-8' ,
209237 } ,
210238 )
239+ expect ( compiler . hooks . done . tap ) . not . toHaveBeenCalled ( )
211240 } )
212241 it ( 'should register devup watch' , ( ) => {
213242 const plugin = new DevupUIWebpackPlugin ( {
@@ -224,6 +253,9 @@ describe('devupUIPlugin', () => {
224253 afterCompile : {
225254 tap : vi . fn ( ) ,
226255 } ,
256+ done : {
257+ tap : vi . fn ( ) ,
258+ } ,
227259 watchRun : {
228260 tapAsync : vi . fn ( ) ,
229261 } ,
@@ -310,6 +342,9 @@ describe('devupUIPlugin', () => {
310342 afterCompile : {
311343 tap : vi . fn ( ) ,
312344 } ,
345+ done : {
346+ tap : vi . fn ( ) ,
347+ } ,
313348 watchRun : {
314349 tapAsync : vi . fn ( ) ,
315350 } ,
0 commit comments