@@ -27,6 +27,12 @@ const scriptInvalidConstraint2 = resolveTestDataURL(
27
27
const scriptWithImportMap = resolveTestDataURL (
28
28
"with_import_map/plugin_with_import_map.ts" ,
29
29
) ;
30
+ const scriptWithDenoJson = resolveTestDataURL (
31
+ "with_deno_json/plugin_with_deno_json.ts" ,
32
+ ) ;
33
+ const scriptWithDenoJson2 = resolveTestDataURL (
34
+ "with_deno_json2/plugin_with_deno_json.ts" ,
35
+ ) ;
30
36
31
37
Deno . test ( "Plugin" , async ( t ) => {
32
38
const meta : Meta = {
@@ -563,4 +569,85 @@ Deno.test("Plugin", async (t) => {
563
569
} ) ;
564
570
} ) ;
565
571
} ) ;
572
+
573
+ await t . step ( "importMap property support" , async ( t ) => {
574
+ await t . step ( "loads plugin with deno.json" , async ( ) => {
575
+ const denops = createDenops ( ) ;
576
+ using _denops_call = stub ( denops , "call" ) ;
577
+ using _denops_cmd = stub ( denops , "cmd" ) ;
578
+
579
+ const plugin = new Plugin ( denops , "test-plugin" , scriptWithDenoJson ) ;
580
+
581
+ await plugin . waitLoaded ( ) ;
582
+
583
+ // Should emit events
584
+ assertSpyCalls ( _denops_call , 2 ) ;
585
+ assertSpyCall ( _denops_call , 0 , {
586
+ args : [
587
+ "denops#_internal#event#emit" ,
588
+ "DenopsSystemPluginPre:test-plugin" ,
589
+ ] ,
590
+ } ) ;
591
+ assertSpyCall ( _denops_call , 1 , {
592
+ args : [
593
+ "denops#_internal#event#emit" ,
594
+ "DenopsSystemPluginPost:test-plugin" ,
595
+ ] ,
596
+ } ) ;
597
+
598
+ // Should call the plugin's main function
599
+ assertSpyCalls ( _denops_cmd , 1 ) ;
600
+ assertSpyCall ( _denops_cmd , 0 , {
601
+ args : [ "echo 'Deno json plugin initialized'" ] ,
602
+ } ) ;
603
+ } ) ;
604
+
605
+ await t . step ( "plugin can use mapped imports" , async ( ) => {
606
+ const denops = createDenops ( ) ;
607
+ using _denops_call = stub ( denops , "call" ) ;
608
+ using _denops_cmd = stub ( denops , "cmd" ) ;
609
+
610
+ const plugin = new Plugin ( denops , "test-plugin" , scriptWithDenoJson ) ;
611
+ await plugin . waitLoaded ( ) ;
612
+
613
+ // Reset spy calls
614
+ _denops_cmd . calls . length = 0 ;
615
+
616
+ // Call the dispatcher function
617
+ const result = await plugin . call ( "test" ) ;
618
+
619
+ // Should execute the command with the message from the mapped import
620
+ assertSpyCalls ( _denops_cmd , 1 ) ;
621
+ assertSpyCall ( _denops_cmd , 0 , {
622
+ args : [ "echo 'Relative import map works for test-plugin!'" ] ,
623
+ } ) ;
624
+
625
+ // Should return the greeting from the mapped import
626
+ assertEquals ( result , "Hello from relative import map!" ) ;
627
+ } ) ;
628
+
629
+ await t . step ( "importMap is overridden by imports" , async ( ) => {
630
+ const denops = createDenops ( ) ;
631
+ using _denops_call = stub ( denops , "call" ) ;
632
+ using _denops_cmd = stub ( denops , "cmd" ) ;
633
+
634
+ const plugin = new Plugin ( denops , "test-plugin" , scriptWithDenoJson2 ) ;
635
+ await plugin . waitLoaded ( ) ;
636
+
637
+ // Reset spy calls
638
+ _denops_cmd . calls . length = 0 ;
639
+
640
+ // Call the dispatcher function
641
+ const result = await plugin . call ( "test" ) ;
642
+
643
+ // Should execute the command with the message from the mapped import
644
+ assertSpyCalls ( _denops_cmd , 1 ) ;
645
+ assertSpyCall ( _denops_cmd , 0 , {
646
+ args : [ "echo 'Import map works for test-plugin!'" ] ,
647
+ } ) ;
648
+
649
+ // Should return the greeting from the mapped import
650
+ assertEquals ( result , "Hello from mapped import!" ) ;
651
+ } ) ;
652
+ } ) ;
566
653
} ) ;
0 commit comments