Skip to content

Commit

Permalink
add component test for build options
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPesce committed Jan 19, 2024
1 parent 201313d commit e1c08e7
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
39 changes: 39 additions & 0 deletions electron/ui/src/tests/BuildOptions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { render, screen } from '@testing-library/react';
import BuildOptions from "../components/BuildOptions/BuildOptions"
import * as React from 'react'
import flowsheetData from './data/BuildOptionsData.json'

//mock props
const setFlowsheetData = () => {
console.log('set flowsheet data')
}
const setShowBuildOptions = () => {
console.log('set build options')
}
const runBuildFlowsheet = () => {
console.log('run build flowsheet')
}

test('test build options', () => {

render(
<BuildOptions
flowsheetData={flowsheetData}
tabValue={0}
isBuilt={true}
showBuildOptions={true}
setShowBuildOptions={setShowBuildOptions}
runBuildFlowsheet={runBuildFlowsheet}
setFlowsheetData={setFlowsheetData}
/>
)

//test for component elements
screen.getByRole('textbox', { name: /String Option/i});
screen.getByRole('textbox', { name: /Int Option/i});
screen.getByRole('textbox', { name: /Float Option/i});

screen.getByRole('button', { name: /Re-build Flowsheet/i});
screen.getByRole('button', { name: /List Option valid option a/i});
screen.getByRole('heading', { name: /Model Options/i});
})
60 changes: 60 additions & 0 deletions electron/ui/src/tests/data/BuildOptionsData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"inputData": {
"name": "Magprex",
"description": "Magprex flowsheet",
"model_objects": {},
"version": 2,
"requires_idaes_solver": false,
"dof": 0,
"sweep_results": {},
"build_options": {
"TestStrOptionValid": {
"name": "TestStrOptionValid",
"category": "String Options",
"display_name": "String Option",
"description": "String Option",
"display_values": [],
"values_allowed": "string",
"min_val": null,
"max_val": null,
"value": "test option"
},
"TestIntOptionValid": {
"name": "TestIntOptionValid",
"category": "Int Options",
"display_name": "Int Option",
"description": "Int Option",
"display_values": [],
"values_allowed": "int",
"min_val": 0,
"max_val": 16,
"value": 10
},
"TestFloatOptionValid": {
"name": "TestFloatOptionValid",
"category": "Float Options",
"display_name": "Float Option",
"description": "Float Option",
"display_values": [],
"values_allowed": "float",
"min_val": 0,
"max_val": 16,
"value": 10.1
},
"TestListOptionValid": {
"name": "TestListOptionValid",
"category": "List Options",
"display_name": "List Option",
"description": "List Option",
"display_values": [],
"values_allowed": [
"valid option a",
"valid option b"
],
"min_val": null,
"max_val": null,
"value": "valid option a"
}
}
}
}

0 comments on commit e1c08e7

Please sign in to comment.