| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  | import Versioning from './versioning'; | 
					
						
							| 
									
										
										
										
											2020-12-29 05:36:31 +00:00
										 |  |  | import UnityVersioning from './unity-versioning'; | 
					
						
							| 
									
										
										
										
											2021-11-24 12:51:52 +00:00
										 |  |  | import AndroidVersioning from './android-versioning'; | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  | import BuildParameters from './build-parameters'; | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  | import Input from './input'; | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  | import Platform from './platform'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  | const determineVersion = jest.spyOn(Versioning, 'determineVersion').mockImplementation(async () => '1.3.37'); | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-29 05:36:31 +00:00
										 |  |  | const determineUnityVersion = jest | 
					
						
							|  |  |  |   .spyOn(UnityVersioning, 'determineUnityVersion') | 
					
						
							|  |  |  |   .mockImplementation(() => '2019.2.11f1'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 12:51:52 +00:00
										 |  |  | const determineSdkManagerParameters = jest | 
					
						
							|  |  |  |   .spyOn(AndroidVersioning, 'determineSdkManagerParameters') | 
					
						
							|  |  |  |   .mockImplementation(() => 'platforms;android-30'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  | afterEach(() => { | 
					
						
							|  |  |  |   jest.clearAllMocks(); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  | describe('BuildParameters', () => { | 
					
						
							|  |  |  |   describe('create', () => { | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('does not throw', async () => { | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.not.toThrow(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('determines the version only once', async () => { | 
					
						
							|  |  |  |       await BuildParameters.create(); | 
					
						
							|  |  |  |       expect(determineVersion).toHaveBeenCalledTimes(1); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-29 05:36:31 +00:00
										 |  |  |     it('determines the unity version only once', async () => { | 
					
						
							|  |  |  |       await BuildParameters.create(); | 
					
						
							|  |  |  |       expect(determineUnityVersion).toHaveBeenCalledTimes(1); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 22:02:05 +00:00
										 |  |  |     it('returns the android version code with provided input', async () => { | 
					
						
							|  |  |  |       const mockValue = '42'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidVersionCode', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidVersionCode: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('returns the android version code from version by default', async () => { | 
					
						
							|  |  |  |       const mockValue = ''; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidVersionCode', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ androidVersionCode: 1003037 })); | 
					
						
							| 
									
										
										
										
											2020-06-24 22:02:05 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 12:51:52 +00:00
										 |  |  |     it('determines the android sdk manager parameters only once', async () => { | 
					
						
							|  |  |  |       await BuildParameters.create(); | 
					
						
							|  |  |  |       expect(determineSdkManagerParameters).toHaveBeenCalledTimes(1); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the platform', async () => { | 
					
						
							|  |  |  |       const mockValue = 'somePlatform'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ platform: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the project path', async () => { | 
					
						
							|  |  |  |       const mockValue = 'path/to/project'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'projectPath', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ projectPath: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the build name', async () => { | 
					
						
							|  |  |  |       const mockValue = 'someBuildName'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildName', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ buildName: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the build path', async () => { | 
					
						
							|  |  |  |       const mockPath = 'somePath'; | 
					
						
							|  |  |  |       const mockPlatform = 'somePlatform'; | 
					
						
							|  |  |  |       const expectedBuildPath = `${mockPath}/${mockPlatform}`; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildsPath', 'get').mockReturnValue(mockPath); | 
					
						
							|  |  |  |       jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(mockPlatform); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ buildPath: expectedBuildPath }), | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the build file', async () => { | 
					
						
							|  |  |  |       const mockValue = 'someBuildName'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildName', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ buildFile: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     test.each([Platform.types.StandaloneWindows, Platform.types.StandaloneWindows64])( | 
					
						
							|  |  |  |       'appends exe for %s', | 
					
						
							|  |  |  |       async (targetPlatform) => { | 
					
						
							|  |  |  |         jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform); | 
					
						
							|  |  |  |         jest.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform); | 
					
						
							|  |  |  |         await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |           expect.objectContaining({ buildFile: `${targetPlatform}.exe` }), | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |       }, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     test.each([Platform.types.Android])('appends apk for %s', async (targetPlatform) => { | 
					
						
							|  |  |  |       jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform); | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform); | 
					
						
							| 
									
										
										
										
											2020-07-06 01:41:21 +00:00
										 |  |  |       jest.spyOn(Input, 'androidAppBundle', 'get').mockReturnValue(false); | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ buildFile: `${targetPlatform}.apk` }), | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 01:41:21 +00:00
										 |  |  |     test.each([Platform.types.Android])('appends aab for %s', async (targetPlatform) => { | 
					
						
							|  |  |  |       jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform); | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform); | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidAppBundle', 'get').mockReturnValue(true); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ buildFile: `${targetPlatform}.aab` }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the build method', async () => { | 
					
						
							|  |  |  |       const mockValue = 'Namespace.ClassName.BuildMethod'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'buildMethod', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ buildMethod: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 01:41:21 +00:00
										 |  |  |     it('returns the android keystore name', async () => { | 
					
						
							|  |  |  |       const mockValue = 'keystore.keystore'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidKeystoreName', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidKeystoreName: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('returns the android keystore base64-encoded content', async () => { | 
					
						
							|  |  |  |       const mockValue = 'secret'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidKeystoreBase64', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidKeystoreBase64: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('returns the android keystore pass', async () => { | 
					
						
							|  |  |  |       const mockValue = 'secret'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidKeystorePass', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidKeystorePass: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('returns the android keyalias name', async () => { | 
					
						
							|  |  |  |       const mockValue = 'secret'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidKeyaliasName', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidKeyaliasName: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('returns the android keyalias pass', async () => { | 
					
						
							|  |  |  |       const mockValue = 'secret'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidKeyaliasPass', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidKeyaliasPass: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 12:51:52 +00:00
										 |  |  |     it('returns the android target sdk version', async () => { | 
					
						
							|  |  |  |       const mockValue = 'AndroidApiLevelAuto'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'androidTargetSdkVersion', 'get').mockReturnValue(mockValue); | 
					
						
							|  |  |  |       await expect(BuildParameters.create()).resolves.toEqual( | 
					
						
							|  |  |  |         expect.objectContaining({ androidTargetSdkVersion: mockValue }), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-21 15:44:56 +00:00
										 |  |  |     it('returns the custom parameters', async () => { | 
					
						
							|  |  |  |       const mockValue = '-profile SomeProfile -someBoolean -someValue exampleValue'; | 
					
						
							|  |  |  |       jest.spyOn(Input, 'customParameters', 'get').mockReturnValue(mockValue); | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |       await expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ customParameters: mockValue })); | 
					
						
							| 
									
										
										
										
											2020-01-27 22:03:29 +00:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); |