@@ -814,7 +814,7 @@ describe('SharePlugin', () => {
814
814
ProvideSharedPluginMock . mockClear ( ) ;
815
815
} ) ;
816
816
817
- it ( 'should transform all properties from SharedConfig to ConsumesConfig' , ( ) => {
817
+ it ( 'should transform all properties from SharedConfig to ConsumesConfig with exclude ' , ( ) => {
818
818
const sharedConfig = {
819
819
import : './path/to/module' ,
820
820
shareKey : 'customKey' ,
@@ -829,7 +829,6 @@ describe('SharePlugin', () => {
829
829
layer : 'layer' ,
830
830
request : 'custom-request' ,
831
831
exclude : { version : '^0.9.0' } ,
832
- include : { version : '^1.0.0' } ,
833
832
} ;
834
833
835
834
const plugin = new SharePlugin ( {
@@ -861,11 +860,59 @@ describe('SharePlugin', () => {
861
860
layer : sharedConfig . layer ,
862
861
request : sharedConfig . request ,
863
862
exclude : sharedConfig . exclude ,
863
+ } ) ;
864
+ } ) ;
865
+
866
+ it ( 'should transform all properties from SharedConfig to ConsumesConfig with include' , ( ) => {
867
+ const sharedConfig = {
868
+ import : './path/to/module' ,
869
+ shareKey : 'customKey' ,
870
+ shareScope : 'customScope' ,
871
+ requiredVersion : '^1.0.0' ,
872
+ strictVersion : true ,
873
+ singleton : true ,
874
+ packageName : 'my-package' ,
875
+ eager : true ,
876
+ version : '1.0.0' ,
877
+ issuerLayer : 'issuerLayer' ,
878
+ layer : 'layer' ,
879
+ request : 'custom-request' ,
880
+ include : { version : '^1.0.0' } ,
881
+ } ;
882
+
883
+ const plugin = new SharePlugin ( {
884
+ shared : {
885
+ react : sharedConfig ,
886
+ } ,
887
+ } ) ;
888
+
889
+ plugin . apply ( mockCompiler ) ;
890
+
891
+ // Check ConsumeSharedPlugin properties
892
+ expect ( ConsumeSharedPluginMock ) . toHaveBeenCalledTimes ( 1 ) ;
893
+ const consumeOptions = ConsumeSharedPluginMock . mock . calls [ 0 ] [ 0 ] ;
894
+ const reactConsume = consumeOptions . consumes . find (
895
+ ( consume ) => Object . keys ( consume ) [ 0 ] === 'react' ,
896
+ ) ;
897
+
898
+ // All expected properties should be passed through
899
+ expect ( reactConsume . react ) . toMatchObject ( {
900
+ import : sharedConfig . import ,
901
+ shareKey : sharedConfig . shareKey ,
902
+ shareScope : sharedConfig . shareScope ,
903
+ requiredVersion : sharedConfig . requiredVersion ,
904
+ strictVersion : sharedConfig . strictVersion ,
905
+ singleton : sharedConfig . singleton ,
906
+ packageName : sharedConfig . packageName ,
907
+ eager : sharedConfig . eager ,
908
+ issuerLayer : sharedConfig . issuerLayer ,
909
+ layer : sharedConfig . layer ,
910
+ request : sharedConfig . request ,
864
911
include : sharedConfig . include ,
865
912
} ) ;
866
913
} ) ;
867
914
868
- it ( 'should transform all properties from SharedConfig to ProvidesConfig' , ( ) => {
915
+ it ( 'should transform all properties from SharedConfig to ProvidesConfig with exclude ' , ( ) => {
869
916
const sharedConfig = {
870
917
import : './path/to/module' ,
871
918
shareKey : 'customKey' ,
@@ -878,7 +925,6 @@ describe('SharePlugin', () => {
878
925
layer : 'layer' ,
879
926
request : 'custom-request' ,
880
927
exclude : { version : '^0.9.0' } ,
881
- include : { version : '^1.0.0' } ,
882
928
} ;
883
929
884
930
const plugin = new SharePlugin ( {
@@ -908,6 +954,50 @@ describe('SharePlugin', () => {
908
954
layer : sharedConfig . layer ,
909
955
request : sharedConfig . request ,
910
956
exclude : sharedConfig . exclude ,
957
+ } ) ;
958
+ } ) ;
959
+
960
+ it ( 'should transform all properties from SharedConfig to ProvidesConfig with include' , ( ) => {
961
+ const sharedConfig = {
962
+ import : './path/to/module' ,
963
+ shareKey : 'customKey' ,
964
+ shareScope : 'customScope' ,
965
+ version : '1.0.0' ,
966
+ eager : true ,
967
+ requiredVersion : '^1.0.0' ,
968
+ strictVersion : true ,
969
+ singleton : true ,
970
+ layer : 'layer' ,
971
+ request : 'custom-request' ,
972
+ include : { version : '^1.0.0' } ,
973
+ } ;
974
+
975
+ const plugin = new SharePlugin ( {
976
+ shared : {
977
+ react : sharedConfig ,
978
+ } ,
979
+ } ) ;
980
+
981
+ plugin . apply ( mockCompiler ) ;
982
+
983
+ // Check ProvideSharedPlugin properties
984
+ expect ( ProvideSharedPluginMock ) . toHaveBeenCalledTimes ( 1 ) ;
985
+ const provideOptions = ProvideSharedPluginMock . mock . calls [ 0 ] [ 0 ] ;
986
+ const reactProvide = provideOptions . provides . find (
987
+ ( provide ) => Object . keys ( provide ) [ 0 ] === './path/to/module' ,
988
+ ) ;
989
+
990
+ // All expected properties should be passed through
991
+ expect ( reactProvide [ './path/to/module' ] ) . toMatchObject ( {
992
+ shareKey : sharedConfig . shareKey ,
993
+ shareScope : sharedConfig . shareScope ,
994
+ version : sharedConfig . version ,
995
+ eager : sharedConfig . eager ,
996
+ requiredVersion : sharedConfig . requiredVersion ,
997
+ strictVersion : sharedConfig . strictVersion ,
998
+ singleton : sharedConfig . singleton ,
999
+ layer : sharedConfig . layer ,
1000
+ request : sharedConfig . request ,
911
1001
include : sharedConfig . include ,
912
1002
} ) ;
913
1003
} ) ;
0 commit comments