@@ -850,7 +850,7 @@ describe('SharePlugin', () => {
850
850
ProvideSharedPluginMock . mockClear ( ) ;
851
851
} ) ;
852
852
853
- it ( 'should transform all properties from SharedConfig to ConsumesConfig' , ( ) => {
853
+ it ( 'should transform all properties from SharedConfig to ConsumesConfig with exclude ' , ( ) => {
854
854
const sharedConfig = {
855
855
import : './path/to/module' ,
856
856
shareKey : 'customKey' ,
@@ -865,7 +865,6 @@ describe('SharePlugin', () => {
865
865
layer : 'layer' ,
866
866
request : 'custom-request' ,
867
867
exclude : { version : '^0.9.0' } ,
868
- include : { version : '^1.0.0' } ,
869
868
} ;
870
869
871
870
const plugin = new SharePlugin ( {
@@ -897,11 +896,59 @@ describe('SharePlugin', () => {
897
896
layer : sharedConfig . layer ,
898
897
request : sharedConfig . request ,
899
898
exclude : sharedConfig . exclude ,
899
+ } ) ;
900
+ } ) ;
901
+
902
+ it ( 'should transform all properties from SharedConfig to ConsumesConfig with include' , ( ) => {
903
+ const sharedConfig = {
904
+ import : './path/to/module' ,
905
+ shareKey : 'customKey' ,
906
+ shareScope : 'customScope' ,
907
+ requiredVersion : '^1.0.0' ,
908
+ strictVersion : true ,
909
+ singleton : true ,
910
+ packageName : 'my-package' ,
911
+ eager : true ,
912
+ version : '1.0.0' ,
913
+ issuerLayer : 'issuerLayer' ,
914
+ layer : 'layer' ,
915
+ request : 'custom-request' ,
916
+ include : { version : '^1.0.0' } ,
917
+ } ;
918
+
919
+ const plugin = new SharePlugin ( {
920
+ shared : {
921
+ react : sharedConfig ,
922
+ } ,
923
+ } ) ;
924
+
925
+ plugin . apply ( mockCompiler ) ;
926
+
927
+ // Check ConsumeSharedPlugin properties
928
+ expect ( ConsumeSharedPluginMock ) . toHaveBeenCalledTimes ( 1 ) ;
929
+ const consumeOptions = ConsumeSharedPluginMock . mock . calls [ 0 ] [ 0 ] ;
930
+ const reactConsume = consumeOptions . consumes . find (
931
+ ( consume ) => Object . keys ( consume ) [ 0 ] === 'react' ,
932
+ ) ;
933
+
934
+ // All expected properties should be passed through
935
+ expect ( reactConsume . react ) . toMatchObject ( {
936
+ import : sharedConfig . import ,
937
+ shareKey : sharedConfig . shareKey ,
938
+ shareScope : sharedConfig . shareScope ,
939
+ requiredVersion : sharedConfig . requiredVersion ,
940
+ strictVersion : sharedConfig . strictVersion ,
941
+ singleton : sharedConfig . singleton ,
942
+ packageName : sharedConfig . packageName ,
943
+ eager : sharedConfig . eager ,
944
+ issuerLayer : sharedConfig . issuerLayer ,
945
+ layer : sharedConfig . layer ,
946
+ request : sharedConfig . request ,
900
947
include : sharedConfig . include ,
901
948
} ) ;
902
949
} ) ;
903
950
904
- it ( 'should transform all properties from SharedConfig to ProvidesConfig' , ( ) => {
951
+ it ( 'should transform all properties from SharedConfig to ProvidesConfig with exclude ' , ( ) => {
905
952
const sharedConfig = {
906
953
import : './path/to/module' ,
907
954
shareKey : 'customKey' ,
@@ -914,7 +961,6 @@ describe('SharePlugin', () => {
914
961
layer : 'layer' ,
915
962
request : 'custom-request' ,
916
963
exclude : { version : '^0.9.0' } ,
917
- include : { version : '^1.0.0' } ,
918
964
} ;
919
965
920
966
const plugin = new SharePlugin ( {
@@ -944,6 +990,50 @@ describe('SharePlugin', () => {
944
990
layer : sharedConfig . layer ,
945
991
request : sharedConfig . request ,
946
992
exclude : sharedConfig . exclude ,
993
+ } ) ;
994
+ } ) ;
995
+
996
+ it ( 'should transform all properties from SharedConfig to ProvidesConfig with include' , ( ) => {
997
+ const sharedConfig = {
998
+ import : './path/to/module' ,
999
+ shareKey : 'customKey' ,
1000
+ shareScope : 'customScope' ,
1001
+ version : '1.0.0' ,
1002
+ eager : true ,
1003
+ requiredVersion : '^1.0.0' ,
1004
+ strictVersion : true ,
1005
+ singleton : true ,
1006
+ layer : 'layer' ,
1007
+ request : 'custom-request' ,
1008
+ include : { version : '^1.0.0' } ,
1009
+ } ;
1010
+
1011
+ const plugin = new SharePlugin ( {
1012
+ shared : {
1013
+ react : sharedConfig ,
1014
+ } ,
1015
+ } ) ;
1016
+
1017
+ plugin . apply ( mockCompiler ) ;
1018
+
1019
+ // Check ProvideSharedPlugin properties
1020
+ expect ( ProvideSharedPluginMock ) . toHaveBeenCalledTimes ( 1 ) ;
1021
+ const provideOptions = ProvideSharedPluginMock . mock . calls [ 0 ] [ 0 ] ;
1022
+ const reactProvide = provideOptions . provides . find (
1023
+ ( provide ) => Object . keys ( provide ) [ 0 ] === './path/to/module' ,
1024
+ ) ;
1025
+
1026
+ // All expected properties should be passed through
1027
+ expect ( reactProvide [ './path/to/module' ] ) . toMatchObject ( {
1028
+ shareKey : sharedConfig . shareKey ,
1029
+ shareScope : sharedConfig . shareScope ,
1030
+ version : sharedConfig . version ,
1031
+ eager : sharedConfig . eager ,
1032
+ requiredVersion : sharedConfig . requiredVersion ,
1033
+ strictVersion : sharedConfig . strictVersion ,
1034
+ singleton : sharedConfig . singleton ,
1035
+ layer : sharedConfig . layer ,
1036
+ request : sharedConfig . request ,
947
1037
include : sharedConfig . include ,
948
1038
} ) ;
949
1039
} ) ;
0 commit comments