Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test components #42

Merged
merged 6 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions skyline-vscode/react-ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import MemThroughputContainer from './sections/MemThroughputContainer';
function acquireApi() {
// if (typeof this.acquireApi.api == 'undefined') {
if (typeof acquireApi.api === 'undefined') {
console.log("Calling acquire function");
if (typeof acquireVsCodeApi === "function") {
let f = window['acquireVsCodeApi'];
let a = f();
Expand Down Expand Up @@ -72,9 +71,11 @@ function App() {
const connect = function() {
resetApp();
let vscode = App.vscodeApi;
vscode.postMessage({
command: "connect"
});
if(vscode){
vscode.postMessage({
command: "connect"
});
}
}

const processAnalysisState = function (state) {
Expand Down
19 changes: 9 additions & 10 deletions skyline-vscode/react-ui/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {act, create} from 'react-test-renderer';
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import App from './App';

describe('App', () => {
it ('should render successfully', () => {
let root;
act(() => {
root = create(<App />);
});
expect(root).toBeTruthy();
});
});
// For testing there is no default socket connection. It will show the error screen
test("Render App correctly, must show a connection error and button to reset it", async() => {
render(<App />);

expect(screen.getByText(/connection error/i)).toBeTruthy();
await userEvent.click(screen.getByText('Reconnect'));
})
Loading