Skip to content

Commit

Permalink
fianlly figured it out
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed Sep 21, 2024
1 parent 4d11998 commit b164ac3
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/test/terminals/shellIntegration/pythonStartup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let environmentVariableCollection: TypeMoq.IMock<EnvironmentVariableCollection>;
let globalEnvironmentVariableCollection: TypeMoq.IMock<GlobalEnvironmentVariableCollection>;

setup(() => {
context = TypeMoq.Mock.ofType<IExtensionContext>();
// context.setup((c) => c).returns(() => context.object);
Expand All @@ -37,12 +38,20 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
.returns(() => environmentVariableCollection.object);
context.setup((c) => c.storageUri).returns(() => Uri.parse('a'));

globalEnvironmentVariableCollection
.setup((c) => c.replace(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
.returns(() => Promise.resolve());

environmentVariableCollection
.setup((c) => c.replace(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()))
.returns(() => Promise.resolve());

// Commenting out 41 to 45 will pas first couple test. "c.environmentVariableCollection is not a function" crashes everything.
context
.setup((c) =>
c.environmentVariableCollection.replace(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
)
.returns(() => Promise.resolve()); // TODO: what is wrong with this --> complaining it is NOT a Function
// context
// .setup((c) =>
// c.environmentVariableCollection.replace(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
// )
// .returns(() => Promise.resolve());
// Marker -----
getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration');
createDirectoryStub = sinon.stub(workspaceApis, 'createDirectory');
Expand Down Expand Up @@ -108,6 +117,9 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
await registerPythonStartup(context.object);

// Verify environment collection.replace has been called
sinon.assert.calledOnce(context.environmentVariableCollection.replace);
globalEnvironmentVariableCollection.verify(
(c) => c.replace('PYTHONSTARTUP', TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.once(),
);
});
});

0 comments on commit b164ac3

Please sign in to comment.