Skip to content

Commit 2e77a64

Browse files
authored
Remove urlsToWatch diagnostic check. Closes #31 (#75)
Closes #31
1 parent cf919ff commit 2e77a64

File tree

2 files changed

+0
-97
lines changed

2 files changed

+0
-97
lines changed

src/diagnostics.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,6 @@ export const updateDiagnostics = (
3232
}
3333
}
3434

35-
// check if urlsToWatch is empty
36-
const urlsToWatchNode = getASTNode(
37-
documentNode.children,
38-
'Identifier',
39-
'urlsToWatch'
40-
);
41-
if (
42-
urlsToWatchNode &&
43-
(urlsToWatchNode.value as parse.ArrayNode).children.length === 0
44-
) {
45-
diagnostics.push(
46-
new vscode.Diagnostic(
47-
getRangeFromASTNode(urlsToWatchNode),
48-
'Add at least one url to watch.',
49-
vscode.DiagnosticSeverity.Error
50-
)
51-
);
52-
}
53-
5435
// check validity of plugins
5536
const pluginsNode = getASTNode(
5637
documentNode.children,

src/test/extension.test.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -42,84 +42,6 @@ suite('extension', () => {
4242
});
4343
});
4444

45-
suite('urlsToWatch', () => {
46-
47-
suiteSetup(async () => {
48-
const context = await vscode.extensions.getExtension('garrytrinder.dev-proxy-toolkit')?.activate() as vscode.ExtensionContext;
49-
await context.globalState.update('devProxyInstall', testDevProxyInstall);
50-
});
51-
52-
teardown(async () => {
53-
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
54-
const context = await vscode.extensions.getExtension('garrytrinder.dev-proxy-toolkit')?.activate() as vscode.ExtensionContext;
55-
await context.globalState.update('devProxyInstall', testDevProxyInstall);
56-
});
57-
58-
test('should show error when opening document with no urlsToWatch found', async () => {
59-
const fileName = 'config-urls-to-watch-required.json';
60-
const filePath = path.resolve(__dirname, 'examples', fileName);
61-
const document = await vscode.workspace.openTextDocument(filePath);
62-
const diagnostics = vscode.languages.getDiagnostics(document.uri);
63-
64-
const expected = {
65-
message: 'Add at least one url to watch.',
66-
severity: vscode.DiagnosticSeverity.Error,
67-
};
68-
const actual = {
69-
message: diagnostics[0]?.message,
70-
severity: diagnostics[0]?.severity,
71-
};
72-
assert.deepStrictEqual(actual, expected);
73-
});
74-
75-
test('should show error when document changes and has no urlsToWatch found', async () => {
76-
const fileName = 'config-urls-to-watch-required.json';
77-
const filePath = path.resolve(__dirname, 'examples', fileName);
78-
const fileContents = fs.readFileSync(filePath, 'utf8');
79-
const document = await vscode.workspace.openTextDocument({
80-
language: 'json',
81-
content: fileContents,
82-
});
83-
await sleep(1000);
84-
const diagnostics = vscode.languages.getDiagnostics(document.uri);
85-
86-
const expected = {
87-
message: 'Add at least one url to watch.',
88-
severity: vscode.DiagnosticSeverity.Error,
89-
};
90-
const actual = {
91-
message: diagnostics[0]?.message,
92-
severity: diagnostics[0]?.severity,
93-
};
94-
assert.deepStrictEqual(actual, expected);
95-
});
96-
97-
test('should have no error after adding a urlToWatch', async () => {
98-
const fileName = 'config-urls-to-watch-required.json';
99-
const filePath = path.resolve(__dirname, 'examples', fileName);
100-
const document = await vscode.workspace.openTextDocument(filePath);
101-
await sleep(1000);
102-
const documentNode = parse(document.getText()) as parse.ObjectNode;
103-
const urlsToWatchNode = getASTNode(
104-
documentNode.children,
105-
'Identifier',
106-
'urlsToWatch'
107-
);
108-
const position = getStartPositionFromASTNode(
109-
urlsToWatchNode?.value as parse.ArrayNode
110-
);
111-
const edit = new vscode.WorkspaceEdit();
112-
edit.insert(document.uri, position, '"https://example.com"');
113-
await vscode.workspace.applyEdit(edit);
114-
const diagnostics = vscode.languages.getDiagnostics(document.uri);
115-
116-
const expected = 0;
117-
const actual = diagnostics.length;
118-
assert.strictEqual(actual, expected);
119-
});
120-
121-
});
122-
12345
suite('isConfigFile', () => {
12446

12547
setup(async () => {

0 commit comments

Comments
 (0)