File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
extensions/ql-vscode/src/mocks Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ import { MockGitHubApiConfigListener } from '../config' ;
2+
13/**
24 * Enables mocking of the GitHub API server via HTTP interception, using msw.
35 */
46export class MockGitHubApiServer {
7+ private isListening : boolean ;
8+ private config : MockGitHubApiConfigListener ;
9+
10+ constructor ( ) {
11+ this . isListening = false ;
12+ this . config = new MockGitHubApiConfigListener ( ) ;
13+ this . setupConfigListener ( ) ;
14+ }
15+
516 public startServer ( ) : void {
17+ this . isListening = true ;
18+
619 // TODO: Enable HTTP interception.
720 }
821
922 public stopServer ( ) : void {
10- // Disable HTTP interception.
23+ this . isListening = false ;
24+
25+ // TODO: Disable HTTP interception.
1126 }
1227
1328 public loadScenario ( ) : void {
@@ -21,4 +36,14 @@ export class MockGitHubApiServer {
2136 public recordScenario ( ) : void {
2237 // TODO: Implement logic to record a new scenario to a directory.
2338 }
39+
40+ private setupConfigListener ( ) : void {
41+ this . config . onDidChangeConfiguration ( ( ) => {
42+ if ( this . config . mockServerEnabled && ! this . isListening ) {
43+ this . startServer ( ) ;
44+ } else if ( ! this . config . mockServerEnabled && this . isListening ) {
45+ this . stopServer ( ) ;
46+ }
47+ } ) ;
48+ }
2449}
You can’t perform that action at this time.
0 commit comments