@@ -9,7 +9,7 @@ import { runInTempDir } from "./helpers/run-in-tmp";
9
9
import { runWrangler } from "./helpers/run-wrangler" ;
10
10
import writeWranglerToml from "./helpers/write-wrangler-toml" ;
11
11
12
- describe ( "Dev component " , ( ) => {
12
+ describe ( "wrangler dev " , ( ) => {
13
13
mockAccountId ( ) ;
14
14
mockApiToken ( ) ;
15
15
runInTempDir ( ) ;
@@ -480,6 +480,72 @@ describe("Dev component", () => {
480
480
expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
481
481
} ) ;
482
482
} ) ;
483
+
484
+ describe ( "durable_objects" , ( ) => {
485
+ it ( "should warn if there is one or more remote Durable Object" , async ( ) => {
486
+ writeWranglerToml ( {
487
+ main : "index.js" ,
488
+ durable_objects : {
489
+ bindings : [
490
+ { name : "NAME_1" , class_name : "CLASS_1" } ,
491
+ {
492
+ name : "NAME_2" ,
493
+ class_name : "CLASS_2" ,
494
+ script_name : "SCRIPT_A" ,
495
+ } ,
496
+ { name : "NAME_3" , class_name : "CLASS_3" } ,
497
+ {
498
+ name : "NAME_4" ,
499
+ class_name : "CLASS_4" ,
500
+ script_name : "SCRIPT_B" ,
501
+ } ,
502
+ ] ,
503
+ } ,
504
+ } ) ;
505
+ fs . writeFileSync ( "index.js" , `export default {};` ) ;
506
+ await runWrangler ( "dev" ) ;
507
+ expect ( ( Dev as jest . Mock ) . mock . calls [ 0 ] [ 0 ] . ip ) . toEqual ( "localhost" ) ;
508
+ expect ( std . out ) . toMatchInlineSnapshot ( `""` ) ;
509
+ expect ( std . warn ) . toMatchInlineSnapshot ( `
510
+ "WARNING: You have Durable Object bindings, which are not defined locally in the worker being developed.
511
+ Be aware that changes to the data stored in these Durable Objects will be permanent and affect the live instances.
512
+ Remote Durable Objects that are affected:
513
+ - {\\"name\\":\\"NAME_2\\",\\"class_name\\":\\"CLASS_2\\",\\"script_name\\":\\"SCRIPT_A\\"}
514
+ - {\\"name\\":\\"NAME_4\\",\\"class_name\\":\\"CLASS_4\\",\\"script_name\\":\\"SCRIPT_B\\"}"
515
+ ` ) ;
516
+ expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
517
+ } ) ;
518
+
519
+ it ( "should use to `ip` from `wrangler.toml`, if available" , async ( ) => {
520
+ writeWranglerToml ( {
521
+ main : "index.js" ,
522
+ dev : {
523
+ ip : "0.0.0.0" ,
524
+ } ,
525
+ } ) ;
526
+ fs . writeFileSync ( "index.js" , `export default {};` ) ;
527
+ await runWrangler ( "dev" ) ;
528
+ expect ( ( Dev as jest . Mock ) . mock . calls [ 0 ] [ 0 ] . ip ) . toEqual ( "0.0.0.0" ) ;
529
+ expect ( std . out ) . toMatchInlineSnapshot ( `""` ) ;
530
+ expect ( std . warn ) . toMatchInlineSnapshot ( `""` ) ;
531
+ expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
532
+ } ) ;
533
+
534
+ it ( "should use --ip command line arg, if provided" , async ( ) => {
535
+ writeWranglerToml ( {
536
+ main : "index.js" ,
537
+ dev : {
538
+ ip : "1.1.1.1" ,
539
+ } ,
540
+ } ) ;
541
+ fs . writeFileSync ( "index.js" , `export default {};` ) ;
542
+ await runWrangler ( "dev --ip=0.0.0.0" ) ;
543
+ expect ( ( Dev as jest . Mock ) . mock . calls [ 0 ] [ 0 ] . ip ) . toEqual ( "0.0.0.0" ) ;
544
+ expect ( std . out ) . toMatchInlineSnapshot ( `""` ) ;
545
+ expect ( std . warn ) . toMatchInlineSnapshot ( `""` ) ;
546
+ expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
547
+ } ) ;
548
+ } ) ;
483
549
} ) ;
484
550
485
551
function mockGetZones ( domain : string , zones : { id : string } [ ] = [ ] ) {
0 commit comments