Skip to content

Commit

Permalink
fix: test dont run through because AudioContext
Browse files Browse the repository at this point in the history
  • Loading branch information
cedscho committed May 19, 2022
1 parent 9a66682 commit e0d7072
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 21 deletions.
32 changes: 19 additions & 13 deletions Frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Frontend/src/benchi-chatbot/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const config = {
state: {
questionNr: 0,
userPreferences: {experience: '', risk: '', active: false, effort: '', duration: ''},
textToSpeech: new TextToSpeech()
},
customComponents: {
// Replaces the default header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import toJson from 'enzyme-to-json';

configure({adapter: new Adapter()});

jest.mock('../../../../benchi-chatbot/TextToSpeech', () => ({
ctx: {}
}));

it('AnalysisScreen renders without crashing', () => {
const setSearchResult = jest.fn();
const setPortfolioData = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

Enzyme.configure({adapter: new Adapter()})

jest.mock('../../../../benchi-chatbot/TextToSpeech', () => ({
ctx: {}
}));

it('AssetDetailsScreen renders without crashing', () => {
const portfolioData = {
'Portfolio': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import DashboardScreen from '../DashboardScreen';
import toJson from 'enzyme-to-json';
import Enzyme, {shallow} from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import {BrowserRouter} from 'react-router-dom';

Enzyme.configure({adapter: new Adapter()})

jest.mock('../../../../benchi-chatbot/TextToSpeech', () => ({
ctx: {}
}));

it('DashboardScreen renders without crashing', () => {
const portfolioData = {
Expand All @@ -29,8 +33,9 @@ it('DashboardScreen renders without crashing', () => {
const getAllAssets = jest.fn();
const setStatusMessage = jest.fn();
const setMessageType = jest.fn();
const addPortfolio = jest.fn();

const wrapper = shallow(
const wrapper = shallow(<BrowserRouter>
<DashboardScreen
searchResult={[]}
setSearchResult={setSearchResult}
Expand All @@ -43,7 +48,8 @@ it('DashboardScreen renders without crashing', () => {
setPortfolioData={setPortfolioData}
setStatusMessage={setStatusMessage}
setMessageType={setMessageType}
/>);
/>
</BrowserRouter>);

expect(toJson(wrapper)).toMatchSnapshot();
})
Original file line number Diff line number Diff line change
@@ -1,19 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DashboardScreen renders without crashing 1`] = `
<Fragment>
<ScreensTemplate
<Router
location={
Object {
"hash": "",
"key": "default",
"pathname": "/",
"search": "",
"state": null,
}
}
navigationType="POP"
navigator={
Object {
"action": "POP",
"back": [Function],
"block": [Function],
"createHref": [Function],
"forward": [Function],
"go": [Function],
"listen": [Function],
"location": Object {
"hash": "",
"key": "default",
"pathname": "/",
"search": "",
"state": null,
},
"push": [Function],
"replace": [Function],
}
}
>
<DashboardScreen
activePortfolio="Portfolio"
assetsListArray={
Array [
Array [],
]
}
bodyComponent={[Function]}
getAllAssets={[MockFunction]}
portfolioData={
Object {
"Portfolio": Object {
"activities": Array [],
"cash": Array [],
"crypto": Array [],
"gains": 0,
"name": "Portfolio",
"performance": 0,
"realisedGains": 0,
"shares": Array [],
"updated": "1970-01-01",
"value": 0,
},
}
}
searchResult={Array []}
selectedNavLinkIndex={0}
setActivePortfolio={[MockFunction]}
setMessageType={[MockFunction]}
setPortfolioData={[MockFunction]}
setSearchResult={[MockFunction]}
setStatusMessage={[MockFunction]}
watchListsArray={Array []}
/>
</Fragment>
</Router>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

Enzyme.configure({adapter: new Adapter()})

jest.mock('../../../../benchi-chatbot/TextToSpeech', () => ({
ctx: {}
}));

it('SettingsScreen renders without crashing', () => {
const emptyPortfolioData = {
'Portfolio': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jest.mock('react-router-dom', () => ({
useNavigate: () => mockedNavigator
}));

jest.mock('../../../../benchi-chatbot/TextToSpeech', () => ({
ctx: {}
}));

describe('Tests regarding WatchList screen', () => {
const addToWatchList = jest.fn();
const setWatchListsArray = jest.fn();
Expand Down

0 comments on commit e0d7072

Please sign in to comment.