-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mock webcontainer api and xterm for unit test
- Loading branch information
1 parent
31e5f9f
commit 43920a1
Showing
7 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class WebContainerApiMock { | ||
public static boot = jest.fn(() => Promise.resolve({ | ||
on: jest.fn(() => jest.fn()) | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class XtermTerminalMock { | ||
public loadAddon = jest.fn(() => Promise.resolve()); | ||
public open = jest.fn(); | ||
public clear = jest.fn(); | ||
public kill = jest.fn(); | ||
public getWriter = jest.fn(); | ||
public dispose = jest.fn(); | ||
public onWriteParsed = () => ({ | ||
dispose: jest.fn() | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
import 'jest-preset-angular/setup-jest'; | ||
import { | ||
WebContainerApiMock, | ||
} from './mocks/webcontainer-api.mock'; | ||
import { | ||
XtermTerminalMock, | ||
} from './mocks/x-term.mock'; | ||
|
||
jest.mock('@webcontainer/api', | ||
() => ({ | ||
WebContainer: WebContainerApiMock | ||
}), { | ||
virtual: true | ||
}); | ||
|
||
jest.mock('@xterm/xterm', | ||
() => ({ Terminal: XtermTerminalMock }), { | ||
virtual: true | ||
}); |