(
config: typemoq.IMock<IConfigurationService>,
stateEnabled: boolean,
configCalled: boolean,
questionResponse: string
)
| 106 | |
| 107 | // Create a test banner with the given settings |
| 108 | function loadBanner( |
| 109 | config: typemoq.IMock<IConfigurationService>, |
| 110 | stateEnabled: boolean, |
| 111 | configCalled: boolean, |
| 112 | questionResponse: string |
| 113 | ): InteractiveShiftEnterBanner { |
| 114 | // Config persist state |
| 115 | const persistService: typemoq.IMock<IPersistentStateFactory> = typemoq.Mock.ofType<IPersistentStateFactory>(); |
| 116 | const enabledState: typemoq.IMock<IPersistentState<boolean>> = typemoq.Mock.ofType<IPersistentState<boolean>>(); |
| 117 | enabledState.setup((a) => a.value).returns(() => stateEnabled); |
| 118 | enabledState.setup((a) => a.updateValue(typemoq.It.isAny())).returns(() => Promise.resolve()); |
| 119 | persistService |
| 120 | .setup((a) => |
| 121 | a.createGlobalPersistentState( |
| 122 | typemoq.It.isValue(InteractiveShiftEnterStateKeys.ShowBanner), |
| 123 | typemoq.It.isValue(true) |
| 124 | ) |
| 125 | ) |
| 126 | .returns(() => { |
| 127 | return enabledState.object; |
| 128 | }); |
| 129 | persistService |
| 130 | .setup((a) => |
| 131 | a.createGlobalPersistentState( |
| 132 | typemoq.It.isValue(InteractiveShiftEnterStateKeys.ShowBanner), |
| 133 | typemoq.It.isValue(false) |
| 134 | ) |
| 135 | ) |
| 136 | .returns(() => { |
| 137 | return enabledState.object; |
| 138 | }); |
| 139 | |
| 140 | // Config settings |
| 141 | const dataScienceSettings = typemoq.Mock.ofType<IWatchableJupyterSettings>(); |
| 142 | dataScienceSettings.setup((d) => d.sendSelectionToInteractiveWindow).returns(() => false); |
| 143 | config.setup((c) => c.getSettings(typemoq.It.isAny())).returns(() => dataScienceSettings.object); |
| 144 | |
| 145 | // Config AppShell - mock showInformationMessage with exact expected arguments |
| 146 | when( |
| 147 | mockedVSCodeNamespaces.window.showInformationMessage( |
| 148 | 'Would you like shift-enter to send code to the new Interactive Window experience?', |
| 149 | 'Yes', |
| 150 | 'No' |
| 151 | ) |
| 152 | ).thenReturn(Promise.resolve(questionResponse) as any); |
| 153 | |
| 154 | // Config settings |
| 155 | config |
| 156 | .setup((c) => |
| 157 | c.updateSetting( |
| 158 | typemoq.It.isValue('interactiveWindow.textEditor.executeSelection'), |
| 159 | typemoq.It.isAny(), |
| 160 | typemoq.It.isAny(), |
| 161 | typemoq.It.isAny() |
| 162 | ) |
| 163 | ) |
| 164 | .returns(() => Promise.resolve()) |
| 165 | .verifiable(configCalled ? typemoq.Times.once() : typemoq.Times.never()); |
no test coverage detected