-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
…354/task-add-turbos
- Loading branch information
Showing
27 changed files
with
304 additions
and
222 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
97 changes: 97 additions & 0 deletions
97
packages/core/src/App/Containers/Layout/__tests__/app-contents.spec.js
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,97 @@ | ||
import React from 'react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { mockStore, StoreProvider } from '@deriv/stores'; | ||
import { ThemedScrollbars } from '@deriv/components'; | ||
import AppContents from '../app-contents'; | ||
|
||
let child_ref; | ||
|
||
const MockComp = props => { | ||
child_ref = React.useRef(); | ||
return ( | ||
<div {...props} ref={child_ref}> | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
jest.mock('@deriv/shared', () => ({ | ||
...jest.requireActual('@deriv/shared'), | ||
isMobile: jest.fn().mockReturnValue(true), | ||
WS: { | ||
wait: jest.fn().mockResolvedValue(true), | ||
}, | ||
})); | ||
|
||
jest.mock('@deriv/components', () => ({ | ||
...jest.requireActual('@deriv/components'), | ||
ThemedScrollbars: props => <MockComp {...props}>{props.children}</MockComp>, | ||
})); | ||
|
||
describe('<AppContents/>', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
const mock = { | ||
common: { | ||
platform: 'dtrader', | ||
}, | ||
gtm: { | ||
pushDataLayer: jest.fn(), | ||
}, | ||
}; | ||
|
||
const store = mockStore(mock); | ||
|
||
const renderComponent = (store_config = store) => { | ||
const new_store = { | ||
...store_config, | ||
}; | ||
return render( | ||
<BrowserRouter> | ||
<StoreProvider store={new_store}> | ||
<AppContents /> | ||
</StoreProvider> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
it('should render the Cookie banner with Accept reject button', () => { | ||
const new_store = { | ||
...store, | ||
client: { | ||
...store.client, | ||
is_eu_country: true, | ||
}, | ||
}; | ||
|
||
renderComponent(new_store); | ||
|
||
waitFor(async () => { | ||
expect(await screen.findByText('Don’t accept')).toBeInTheDocument(); | ||
expect(await screen.findByText('Accept')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should not render the cookie banner when it is not a eu country', () => { | ||
renderComponent(); | ||
|
||
waitFor(() => { | ||
expect(screen.queryByText('Don’t accept')).not.toBeInTheDocument(); | ||
expect(screen.queryByText('Accept')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('should move scroll to top', async () => { | ||
renderComponent(); | ||
|
||
await waitFor(() => { | ||
expect(child_ref.current.scrollTop).toBe(0); | ||
}); | ||
}); | ||
}); |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.