@@ -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-
12345suite ( 'isConfigFile' , ( ) => {
12446
12547 setup ( async ( ) => {
0 commit comments