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