Skip to content

Commit

Permalink
Add extension based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Apr 20, 2023
1 parent 05ad55f commit 9b59b96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ export class MergedEnvironmentVariableCollection implements IMergedEnvironmentVa
entry = [];
this.descriptionMap.set(key, entry);
}
entry.push({
const extensionMutator = {
extensionIdentifier,
scope: mutator.scope,
description: mutator.description
});
};
if (!extensionMutator.scope) {
delete extensionMutator.scope; // Convenient for tests
}
entry.push(extensionMutator);

next = it.next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ suite('EnvironmentVariable - MergedEnvironmentVariableCollection', () => {
]);
});

test('Workspace scoped description entries are properly filtered', () => {
test('Workspace scoped description entries are properly filtered for each extension', () => {
const scope1 = { workspaceFolder: { uri: URI.file('workspace1'), name: 'workspace1', index: 0 } };
const scope2 = { workspaceFolder: { uri: URI.file('workspace2'), name: 'workspace2', index: 3 } };
const merged = new MergedEnvironmentVariableCollection(new Map([
Expand All @@ -153,12 +153,16 @@ suite('EnvironmentVariable - MergedEnvironmentVariableCollection', () => {
['A-key', { value: 'a1', type: EnvironmentVariableMutatorType.Prepend, scope: scope1, variable: 'A' }]
]),
descriptionMap: deserializeEnvironmentDescriptionMap([
['A-key', { description: 'A description', scope: scope1 }],
['A-key-scope1', { description: 'ext1 scope1 description', scope: scope1 }],
['A-key-scope2', { description: 'ext1 scope2 description', scope: scope2 }],
])
}],
['ext2', {
map: deserializeEnvironmentVariableCollection([
['A-key', { value: 'a2', type: EnvironmentVariableMutatorType.Append, variable: 'A' }]
]),
descriptionMap: deserializeEnvironmentDescriptionMap([
['A-key-scope1', { description: 'ext2 global description' }],
])
}],
['ext3', {
Expand All @@ -177,7 +181,8 @@ suite('EnvironmentVariable - MergedEnvironmentVariableCollection', () => {
]));
deepStrictEqual([...merged.getDescriptionMap(scope1).entries()], [
['A', [
{ extensionIdentifier: 'ext1', description: 'A description', scope: scope1 },
{ extensionIdentifier: 'ext1', description: 'ext1 scope1 description', scope: scope1 },
{ extensionIdentifier: 'ext2', description: 'ext2 global description' },
]]
]);
});
Expand Down

0 comments on commit 9b59b96

Please sign in to comment.