( spyFn: jest.SpyInstance, mock: MockInitCmdPromptExpectation, debug = false )
| 143 | } |
| 144 | |
| 145 | export const initCommandPromptGetterMethodTester = async ( |
| 146 | spyFn: jest.SpyInstance, |
| 147 | mock: MockInitCmdPromptExpectation, |
| 148 | debug = false |
| 149 | ): Promise<void> => { |
| 150 | debug && logger.debug('******') |
| 151 | debug && logger.debug(`Test ${mock.methodToTest}`) |
| 152 | debug && logger.debug(`overwriteFlag: ${JSON.stringify(mock.overwriteFlag)}`) |
| 153 | debug && |
| 154 | logger.debug(`promptExpectation: ${JSON.stringify(mock.promptExpectation)}`) |
| 155 | mock.promptExpectation.forEach(expectation => |
| 156 | spyFn.mockResolvedValueOnce(expectation) |
| 157 | ) |
| 158 | const InitCommand = await getInitCommand([''], 'aws') |
| 159 | const cloudGraphConfig = InitCommand.getCGConfig('cloudGraph') |
| 160 | debug && |
| 161 | logger.debug( |
| 162 | `Config Dir -> ${JSON.stringify(InitCommand.config.configDir)}` |
| 163 | ) |
| 164 | debug && logger.debug(`Config -> ${JSON.stringify(cloudGraphConfig)}`) |
| 165 | const response = await InitCommand[mock.methodToTest](mock.overwriteFlag) |
| 166 | debug && logger.debug(`response: ${JSON.stringify(response)}`) |
| 167 | expect(response).toMatchObject(mock.expectedResult) |
| 168 | debug && |
| 169 | logger.debug(`expectedResult: ${JSON.stringify(mock.expectedResult)}`) |
| 170 | } |
| 171 | |
| 172 | export const initCommandNoOverwriteTester = async ( |
| 173 | mock: MockInitCmdPromptExpectation | MockInitCmdFlagsExpectation, |
no test coverage detected