@@ -189,53 +189,6 @@ describe("hot middleware (unit)", () => {
189189 stream . close ( ) ;
190190 } ) ;
191191
192- it ( "publishes JSON payloads to attached clients" , ( ) => {
193- const stream = createEventStream ( 5000 , noopLogger ) ;
194- const writes = [ ] ;
195- const fakeRes = {
196- writableEnded : false ,
197- write : ( chunk ) => writes . push ( chunk ) ,
198- writeHead : ( ) => { } ,
199- end : ( ) => { } ,
200- } ;
201- const fakeReq = {
202- httpVersion : "1.1" ,
203- socket : { setKeepAlive : ( ) => { } } ,
204- on : ( ) => { } ,
205- } ;
206-
207- stream . handler ( fakeReq , fakeRes ) ;
208- stream . publish ( { action : "built" , hash : "abc" } ) ;
209-
210- expect ( writes . some ( ( w ) => w . includes ( '"action":"built"' ) ) ) . toBe ( true ) ;
211- expect ( writes . some ( ( w ) => w . includes ( '"hash":"abc"' ) ) ) . toBe ( true ) ;
212-
213- stream . close ( ) ;
214- } ) ;
215-
216- it ( "close ends connected clients" , ( ) => {
217- const stream = createEventStream ( 5000 , noopLogger ) ;
218- let ended = false ;
219- const fakeRes = {
220- writableEnded : false ,
221- write : ( ) => { } ,
222- writeHead : ( ) => { } ,
223- end : ( ) => {
224- ended = true ;
225- } ,
226- } ;
227- const fakeReq = {
228- httpVersion : "1.1" ,
229- socket : { setKeepAlive : ( ) => { } } ,
230- on : ( ) => { } ,
231- } ;
232-
233- stream . handler ( fakeReq , fakeRes ) ;
234- stream . close ( ) ;
235-
236- expect ( ended ) . toBe ( true ) ;
237- } ) ;
238-
239192 it ( "sets Connection: keep-alive for HTTP/1 clients" , ( ) => {
240193 const stream = createEventStream ( 5000 , noopLogger ) ;
241194 const { headers } = attachClient ( stream , { httpVersion : "1.1" } ) ;
@@ -250,25 +203,6 @@ describe("hot middleware (unit)", () => {
250203 stream . close ( ) ;
251204 } ) ;
252205
253- it ( "broadcasts events to every attached client" , ( ) => {
254- const stream = createEventStream ( 5000 , noopLogger ) ;
255- const clients = [
256- attachClient ( stream ) ,
257- attachClient ( stream ) ,
258- attachClient ( stream ) ,
259- ] ;
260-
261- for ( const c of clients ) c . writes . length = 0 ;
262-
263- stream . publish ( { action : "built" , hash : "xyz" } ) ;
264-
265- for ( const c of clients ) {
266- expect ( c . writes . some ( ( w ) => w . includes ( '"hash":"xyz"' ) ) ) . toBe ( true ) ;
267- }
268-
269- stream . close ( ) ;
270- } ) ;
271-
272206 it ( "logs client connect and disconnect with the active count" , ( ) => {
273207 const messages = [ ] ;
274208 const stream = createEventStream ( 5000 , {
@@ -317,55 +251,6 @@ describe("createHot", () => {
317251 hot . close ( ) ;
318252 } ) ;
319253
320- it ( "exposes publish() so callers can broadcast custom payloads" , ( ) => {
321- const compiler = makeFakeCompiler ( ) ;
322- const hot = createHot ( compiler , { } ) ;
323- const { writes } = attachClient ( { handler : hot . handle } ) ;
324-
325- hot . publish ( { action : "custom-thing" , payload : 42 } ) ;
326-
327- expect (
328- writes . some (
329- ( w ) =>
330- w . includes ( '"action":"custom-thing"' ) && w . includes ( '"payload":42' ) ,
331- ) ,
332- ) . toBe ( true ) ;
333-
334- hot . close ( ) ;
335- } ) ;
336-
337- it ( "includes the changed file in the building payload" , ( ) => {
338- const compiler = makeFakeCompiler ( ) ;
339- const hot = createHot ( compiler , { } ) ;
340- const { writes } = attachClient ( { handler : hot . handle } ) ;
341-
342- compiler . emitInvalid ( "/src/index.js" ) ;
343-
344- expect (
345- writes . some (
346- ( w ) =>
347- w . includes ( '"action":"building"' ) &&
348- w . includes ( '"file":"/src/index.js"' ) ,
349- ) ,
350- ) . toBe ( true ) ;
351-
352- hot . close ( ) ;
353- } ) ;
354-
355- it ( "omits the file field when the invalid hook reports none" , ( ) => {
356- const compiler = makeFakeCompiler ( ) ;
357- const hot = createHot ( compiler , { } ) ;
358- const { writes } = attachClient ( { handler : hot . handle } ) ;
359-
360- compiler . emitInvalid ( ) ;
361-
362- const building = writes . find ( ( w ) => w . includes ( '"action":"building"' ) ) ;
363- expect ( building ) . toBeDefined ( ) ;
364- expect ( building ) . not . toContain ( '"file"' ) ;
365-
366- hot . close ( ) ;
367- } ) ;
368-
369254 it ( "ends a response whose headers were already sent instead of registering it" , async ( ) => {
370255 const compiler = makeFakeCompiler ( ) ;
371256 const hot = createHot ( compiler , { } ) ;
@@ -399,61 +284,6 @@ describe("createHot", () => {
399284 } ) ;
400285 } ) ;
401286
402- it ( "includes the compilation name in the building payload" , ( ) => {
403- const compiler = makeFakeCompiler ( ) ;
404- compiler . name = "main" ;
405- const hot = createHot ( compiler , { } ) ;
406- const { writes } = attachClient ( { handler : hot . handle } ) ;
407-
408- compiler . emitInvalid ( ) ;
409-
410- // The client pairs `building` with the `built`/`sync` that follows by
411- // name — without it the building indicator can never be hidden.
412- const building = writes . find ( ( w ) => w . includes ( '"action":"building"' ) ) ;
413- expect ( building ) . toContain ( '"name":"main"' ) ;
414-
415- hot . close ( ) ;
416- } ) ;
417-
418- it ( "names the building payload after the compiler that invalidated in a multi-compiler" , ( ) => {
419- const app = makeFakeCompiler ( ) ;
420- app . name = "app" ;
421- const widget = makeFakeCompiler ( ) ;
422- widget . name = "widget" ;
423- const multi = makeFakeCompiler ( ) ;
424- multi . compilers = [ app , widget ] ;
425- const hot = createHot ( multi , { } ) ;
426- const { writes } = attachClient ( { handler : hot . handle } ) ;
427-
428- widget . emitInvalid ( "/src/widget.js" ) ;
429-
430- const building = writes . filter ( ( w ) => w . includes ( '"action":"building"' ) ) ;
431- expect ( building ) . toHaveLength ( 1 ) ;
432- expect ( building [ 0 ] ) . toContain ( '"name":"widget"' ) ;
433- expect ( building [ 0 ] ) . toContain ( '"file":"/src/widget.js"' ) ;
434-
435- hot . close ( ) ;
436- } ) ;
437-
438- it ( "publishes sync instead of built when a bundle's hash did not change" , ( ) => {
439- const compiler = makeFakeCompiler ( ) ;
440- const hot = createHot ( compiler , { } ) ;
441- const { writes } = attachClient ( { handler : hot . handle } ) ;
442-
443- compiler . emitDone ( makeFakeStats ( { hash : "same" } ) ) ;
444- writes . length = 0 ;
445-
446- // A rebuild that produced the same hash (e.g. another bundle of a
447- // multi-compiler changed) must not be announced as `built`.
448- compiler . emitInvalid ( ) ;
449- compiler . emitDone ( makeFakeStats ( { hash : "same" } ) ) ;
450-
451- expect ( writes . some ( ( w ) => w . includes ( '"action":"sync"' ) ) ) . toBe ( true ) ;
452- expect ( writes . some ( ( w ) => w . includes ( '"action":"built"' ) ) ) . toBe ( false ) ;
453-
454- hot . close ( ) ;
455- } ) ;
456-
457287 it ( "pairs bundles sharing a name by occurrence so unchanged ones publish sync" , ( ) => {
458288 const compiler = makeFakeCompiler ( ) ;
459289 const hot = createHot ( compiler , { } ) ;
@@ -481,26 +311,6 @@ describe("createHot", () => {
481311 hot . close ( ) ;
482312 } ) ;
483313
484- it ( "publishes built when the bundle's hash changed" , ( ) => {
485- const compiler = makeFakeCompiler ( ) ;
486- const hot = createHot ( compiler , { } ) ;
487- const { writes } = attachClient ( { handler : hot . handle } ) ;
488-
489- compiler . emitDone ( makeFakeStats ( { hash : "one" } ) ) ;
490- writes . length = 0 ;
491-
492- compiler . emitInvalid ( ) ;
493- compiler . emitDone ( makeFakeStats ( { hash : "two" } ) ) ;
494-
495- expect (
496- writes . some (
497- ( w ) => w . includes ( '"action":"built"' ) && w . includes ( '"hash":"two"' ) ,
498- ) ,
499- ) . toBe ( true ) ;
500-
501- hot . close ( ) ;
502- } ) ;
503-
504314 it ( "publishes built only for the changed bundles of a multi-compiler" , ( ) => {
505315 const compiler = makeFakeCompiler ( ) ;
506316 const hot = createHot ( compiler , { } ) ;
0 commit comments