| 41 | } |
| 42 | |
| 43 | class MockDeployEffects extends MockAuthEffects implements DeployEffects { |
| 44 | public logger = new MockLogger(); |
| 45 | public input = new Readable(); |
| 46 | public output: NodeJS.WritableStream; |
| 47 | public observableApiKey: string | null = null; |
| 48 | public projectTitle = "My Project"; |
| 49 | public projectSlug = "my-project"; |
| 50 | public isTty: boolean; |
| 51 | public outputColumns: number; |
| 52 | public clack = new TestClackEffects(); |
| 53 | |
| 54 | private deployConfigs: Record<string, DeployConfig>; |
| 55 | private defaultDeployConfig: DeployConfig | null; |
| 56 | private ioResponses: {prompt: RegExp; response: string}[] = []; |
| 57 | private debug: boolean; |
| 58 | private configEffects: MockConfigEffects; |
| 59 | private authEffects: MockAuthEffects; |
| 60 | private fixedInputStatTime: Date | undefined; |
| 61 | private fixedOutputStatTime: Date | undefined; |
| 62 | private buildManifest: BuildManifest | undefined; |
| 63 | |
| 64 | constructor({ |
| 65 | apiKey = validApiKey, |
| 66 | deployConfig = null, |
| 67 | isTty = true, |
| 68 | outputColumns = 80, |
| 69 | debug = false, |
| 70 | fixedInputStatTime, |
| 71 | fixedOutputStatTime, |
| 72 | buildManifest |
| 73 | }: MockDeployEffectsOptions = {}) { |
| 74 | super(); |
| 75 | this.authEffects = new MockAuthEffects(); |
| 76 | this.configEffects = new MockConfigEffects(); |
| 77 | |
| 78 | this.observableApiKey = apiKey; |
| 79 | this.deployConfigs = {}; |
| 80 | this.defaultDeployConfig = deployConfig; |
| 81 | this.isTty = isTty; |
| 82 | this.outputColumns = outputColumns; |
| 83 | this.debug = debug; |
| 84 | this.fixedInputStatTime = fixedInputStatTime; |
| 85 | this.fixedOutputStatTime = fixedOutputStatTime; |
| 86 | this.buildManifest = buildManifest; |
| 87 | |
| 88 | this.output = new Writable({ |
| 89 | write: (data, _enc, callback) => { |
| 90 | const dataString = data.toString(); |
| 91 | let matched = false; |
| 92 | for (const [index, {prompt, response}] of this.ioResponses.entries()) { |
| 93 | if (dataString.match(prompt)) { |
| 94 | // Having to null/reinit input seems wrong. |
| 95 | // TODO: find the correct way to submit to readline but keep the same |
| 96 | // input stream across multiple readline interactions. |
| 97 | this.input.push(`${response}\n`); |
| 98 | this.input.push(null); |
| 99 | this.input = new Readable(); |
| 100 | this.ioResponses.splice(index, 1); |
nothing calls this directly
no outgoing calls
no test coverage detected