Skip to content

Commit a9765f5

Browse files
committed
fix: fetch copybook for dialect from the dialect configured settings
fetch copybook for dialect from the dialect configured settings and not from the cobol configuration Signed-off-by: Aman Prashant <[email protected]>
1 parent 17d12b1 commit a9765f5

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

clients/cobol-lsp-vscode-extension/src/__tests__/services/SettingsTest.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,32 @@ describe("SettingsService returns correct tab settings", () => {
197197
expect(tabSettings.rules.length).toBe(2);
198198
});
199199
});
200+
201+
describe("SettingsService returns correct Copybook Configuration Values", () => {
202+
const mockConfigurationFetch = (settings, configuredValue) => jest.fn().mockReturnValue({
203+
get: (args: String) => {
204+
if (settings === args) {
205+
return configuredValue;
206+
}
207+
},
208+
});
209+
210+
test("returns empty array when dialect configuration is not provided", () => {
211+
vscode.workspace.getConfiguration = mockConfigurationFetch("dialect.paths-uss", undefined);
212+
expect(SettingsService.getUssPath("doc-uri", "dialect")).toHaveLength(0);
213+
});
214+
215+
test("returns configured array when dialect configuration is provided", () => {
216+
vscode.workspace.getConfiguration = mockConfigurationFetch("dialect.paths-uss", ["configured-dialect-settings"]);
217+
const configuredValue = SettingsService.getUssPath("doc-uri", "dialect");
218+
expect(configuredValue).toHaveLength(1);
219+
expect(configuredValue[0]).toBe("configured-dialect-settings");
220+
});
221+
222+
test("returns configured array for COBOL configuration", () => {
223+
vscode.workspace.getConfiguration = mockConfigurationFetch("paths-uss", ["configured-cobol-settings"]);
224+
const configuredValue = SettingsService.getUssPath("doc-uri", SettingsService.DEFAULT_DIALECT);
225+
expect(configuredValue).toHaveLength(1);
226+
expect(configuredValue[0]).toBe("configured-cobol-settings");
227+
});
228+
});

clients/cobol-lsp-vscode-extension/src/services/Settings.ts

-2
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,11 @@ export class SettingsService {
359359
const pathList: string[] = vscode.workspace
360360
.getConfiguration(SETTINGS_CPY_SECTION)
361361
.get(`${dialectType.toLowerCase()}.${section}`);
362-
if (pathList && pathList.length > 0) {
363362
return SettingsService.evaluateVariable(
364363
pathList,
365364
"fileBasenameNoExtension",
366365
programFile,
367366
);
368-
}
369367
}
370368
const pathList: string[] = vscode.workspace
371369
.getConfiguration(SETTINGS_CPY_SECTION)

0 commit comments

Comments
 (0)