@@ -1043,55 +1043,121 @@ describe('prepare', () => {
1043
1043
} ) ;
1044
1044
it ( 'Test#005 : should write out the orientation preference value' , ( ) => {
1045
1045
cfg . getPreference . and . callThrough ( ) ;
1046
+ writeFileSyncSpy . and . callThrough ( ) ;
1046
1047
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1047
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' ] ) ;
1048
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] [ 'UISupportedInterfaceOrientations~ipad' ] ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' ] ) ;
1049
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toEqual ( [ 'UIInterfaceOrientationPortrait' ] ) ;
1048
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1049
+ proj . parseSync ( ) ;
1050
+
1051
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1052
+ expect ( orientation ) . toEqual ( '"UIInterfaceOrientationPortrait"' ) ;
1053
+
1054
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1055
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"' ) ;
1056
+
1057
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1058
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"' ) ;
1050
1059
} ) ;
1051
1060
} ) ;
1052
1061
it ( 'Test#006 : should handle no orientation' , ( ) => {
1053
- cfg . getPreference . and . returnValue ( '' ) ;
1062
+ cfg . getPreference . and . returnValue ( null ) ;
1063
+ writeFileSyncSpy . and . callThrough ( ) ;
1054
1064
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1055
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toBeUndefined ( ) ;
1056
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] [ 'UISupportedInterfaceOrientations~ipad' ] ) . toBeUndefined ( ) ;
1057
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toBeUndefined ( ) ;
1065
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1066
+ proj . parseSync ( ) ;
1067
+
1068
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1069
+ expect ( orientation ) . toBeUndefined ( ) ;
1070
+
1071
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1072
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1073
+
1074
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1075
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1058
1076
} ) ;
1059
1077
} ) ;
1060
1078
it ( 'Test#007 : should handle default orientation' , ( ) => {
1061
1079
cfg . getPreference . and . returnValue ( 'default' ) ;
1080
+ writeFileSyncSpy . and . callThrough ( ) ;
1062
1081
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1063
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1064
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] [ 'UISupportedInterfaceOrientations~ipad' ] ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1065
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toBeUndefined ( ) ;
1082
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1083
+ proj . parseSync ( ) ;
1084
+
1085
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1086
+ expect ( orientation ) . toBeUndefined ( ) ;
1087
+
1088
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1089
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1090
+
1091
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1092
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1066
1093
} ) ;
1067
1094
} ) ;
1068
1095
it ( 'Test#008 : should handle portrait orientation' , ( ) => {
1069
1096
cfg . getPreference . and . returnValue ( 'portrait' ) ;
1097
+ writeFileSyncSpy . and . callThrough ( ) ;
1070
1098
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1071
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' ] ) ;
1072
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toEqual ( [ 'UIInterfaceOrientationPortrait' ] ) ;
1099
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1100
+ proj . parseSync ( ) ;
1101
+
1102
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1103
+ expect ( orientation ) . toEqual ( '"UIInterfaceOrientationPortrait"' ) ;
1104
+
1105
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1106
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"' ) ;
1107
+
1108
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1109
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"' ) ;
1073
1110
} ) ;
1074
1111
} ) ;
1075
1112
it ( 'Test#009 : should handle landscape orientation' , ( ) => {
1076
1113
cfg . getPreference . and . returnValue ( 'landscape' ) ;
1114
+ writeFileSyncSpy . and . callThrough ( ) ;
1077
1115
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1078
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1079
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toEqual ( [ 'UIInterfaceOrientationLandscapeLeft' ] ) ;
1116
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1117
+ proj . parseSync ( ) ;
1118
+
1119
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1120
+ expect ( orientation ) . toEqual ( '"UIInterfaceOrientationLandscapeLeft"' ) ;
1121
+
1122
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1123
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1124
+
1125
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1126
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1080
1127
} ) ;
1081
1128
} ) ;
1082
1129
it ( 'Test#010 : should handle all orientation on ios' , ( ) => {
1083
1130
cfg . getPreference . and . returnValue ( 'all' ) ;
1131
+ writeFileSyncSpy . and . callThrough ( ) ;
1084
1132
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1085
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1086
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toEqual ( [ 'UIInterfaceOrientationPortrait' ] ) ;
1133
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1134
+ proj . parseSync ( ) ;
1135
+
1136
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1137
+ expect ( orientation ) . toEqual ( '"UIInterfaceOrientationPortrait"' ) ;
1138
+
1139
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1140
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1141
+
1142
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1143
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1087
1144
} ) ;
1088
1145
} ) ;
1089
1146
it ( 'Test#011 : should handle custom orientation' , ( ) => {
1090
1147
cfg . getPreference . and . returnValue ( 'some-custom-orientation' ) ;
1148
+ writeFileSyncSpy . and . callThrough ( ) ;
1091
1149
return updateProject ( cfg , p . locations ) . then ( ( ) => {
1092
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UISupportedInterfaceOrientations ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1093
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] [ 'UISupportedInterfaceOrientations~ipad' ] ) . toEqual ( [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' ] ) ;
1094
- expect ( plist . build . calls . mostRecent ( ) . args [ 0 ] . UIInterfaceOrientation ) . toBeUndefined ( ) ;
1150
+ const proj = new XcodeProject ( p . locations . pbxproj ) ;
1151
+ proj . parseSync ( ) ;
1152
+
1153
+ const orientation = proj . getBuildProperty ( 'INFOPLIST_KEY_UIInterfaceOrientation' , undefined , 'App' ) ;
1154
+ expect ( orientation ) . toBeUndefined ( ) ;
1155
+
1156
+ const phone_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone' , undefined , 'App' ) ;
1157
+ expect ( phone_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1158
+
1159
+ const pad_supported = proj . getBuildProperty ( 'INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad' , undefined , 'App' ) ;
1160
+ expect ( pad_supported ) . toEqual ( '"UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"' ) ;
1095
1161
} ) ;
1096
1162
} ) ;
1097
1163
0 commit comments