Skip to content

Commit

Permalink
added tests for each component
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPesce committed Jul 6, 2022
1 parent 9defaf9 commit 56e9cef
Show file tree
Hide file tree
Showing 8 changed files with 732 additions and 3 deletions.
5 changes: 2 additions & 3 deletions electron/ui/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import { BrowserRouter } from "react-router-dom";

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
render(<BrowserRouter> <App /> </BrowserRouter>);
});
12 changes: 12 additions & 0 deletions electron/ui/src/tests/Graph.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render, screen } from '@testing-library/react';
import Graph from "Components/Graph/Graph"

//mock props

test('test input accordion', () => {

render( <Graph></Graph> )

//test for component elements
screen.getByRole('img', { name: /flowsheet/i});
})
13 changes: 13 additions & 0 deletions electron/ui/src/tests/Header.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { render, screen } from '@testing-library/react';
import Header from "Components/Boilerplate/Header/Header"

//mock props

test('test input accordion', () => {

render( <Header></Header> )

//test for component elements
screen.getByRole('link', { name: /NAWI logo/i});
screen.getByRole('img', { name: /NAWI logo/i});
})
50 changes: 50 additions & 0 deletions electron/ui/src/tests/InputAccordion.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { render, screen } from '@testing-library/react';
import InputAccordion from "Components/InputAccordion/InputAccordion"

//mock props
const key = ""

const mockSections = {
"": {
"display_name": "",
"variables": {
"flow_vol": {
"value": {
"index": [
[
0
]
],
"value": [
0.0003286
],
"bounds": [
[
null,
null
]
]
},
"display_name": "flow_vol",
"description": "Volumetric flowrate in feed",
"display_units": "m<sup>3</sup>/s",
"indices": [],
"scale_factor": 0,
"to_units": "",
"readonly": false,
"category": ""
},
}
}
}

test('test input accordion', () => {

render( <InputAccordion dataKey={key} data={mockSections[key]}></InputAccordion> )

//test for component elements
screen.getByRole('button', { name: ""});
screen.getByRole('region', { name: ""});
screen.getByRole('textbox', { name: /flow_vol/i});

})
41 changes: 41 additions & 0 deletions electron/ui/src/tests/InputWrapper.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { render, screen } from '@testing-library/react';
import InputWrapper from "Components/InputWrapper/InputWrapper"

//mock props
const key = "flow_vol"
const fieldData = {
"value": {
"index": [
[
0
]
],
"value": [
0.0003286
],
"bounds": [
[
null,
null
]
]
},
"display_name": "flow_vol",
"description": "Volumetric flowrate in feed",
"display_units": "m<sup>3</sup>/s",
"indices": [],
"scale_factor": 0,
"to_units": "",
"readonly": false,
"category": ""
}

test('test input wrapper', () => {

render( <InputWrapper key={key} fieldData={fieldData}></InputWrapper> )

//test for component elements
screen.getByRole('textbox', { name: /flow_vol/i});


})
31 changes: 31 additions & 0 deletions electron/ui/src/tests/NewFlowsheetDialog.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { render, screen } from '@testing-library/react';
import NewFlowsheetDialog from "Components/NewFlowsheetDialog/NewFlowsheetDialog"


//mock props
const open = true
const mockClose = () => {
console.log("close");
};

test('test new flowsheet dialog', () => {
render( <NewFlowsheetDialog open={open} onClose={mockClose}></NewFlowsheetDialog> )

//test that all textboxes are present
screen.getByRole('textbox', { name: /flowsheet name/i});
screen.getByRole('textbox', { name: /has bypass/i});
screen.getByRole('textbox', { name: /has desal feed/i});
screen.getByRole('textbox', { name: /is twostage/i});
screen.getByRole('textbox', { name: /has erd/i});
screen.getByRole('textbox', { name: /nf type/i});
screen.getByRole('textbox', { name: /nf base/i});
screen.getByRole('textbox', { name: /ro type/i});
screen.getByRole('textbox', { name: /ro base/i});
screen.getByRole('textbox', { name: /ro level/i});

//test that cancel and create buttons are present
screen.getByRole('button', { name: /cancel/i})
screen.getByRole('button', { name: /create/i})

//screen.debug();
})
12 changes: 12 additions & 0 deletions electron/ui/src/tests/Page.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render, screen } from '@testing-library/react';
import Page from "Components/Page/Page"

//mock props

test('test input accordion', () => {

render( <Page></Page> )

//test for component elements
screen.getByRole('img', { name: /flowsheet/i});
})
Loading

0 comments on commit 56e9cef

Please sign in to comment.