|
1 | | -test('displays browser view of when URL is correctly inputted', () => {}); |
| 1 | +import React from 'react'; |
| 2 | +import { GlobalContext } from '../../../context/globalReducer'; |
| 3 | +import BrowserView from '../../RightPanel/BrowserView/BrowserView'; |
| 4 | +import EditorView from '../../RightPanel/EditorView/EditorView'; |
| 5 | +import RightPanel from '../../RightPanel/RightPanel'; |
2 | 6 |
|
3 | | -test(`omitting 'www' from URL still displays browser view`, () => {}); |
| 7 | +import { render, fireEvent } from '@testing-library/react'; |
| 8 | +import { build, fake } from 'test-data-bot'; |
| 9 | +import '@testing-library/jest-dom/extend-expect'; |
4 | 10 |
|
5 | | -test('localhost URL displays on the browser view', () => {}); |
| 11 | +import Enzyme from 'enzyme'; |
| 12 | +import { shallow, mount } from 'enzyme'; |
| 13 | +import ReactDOM from 'react-dom'; |
| 14 | +import { act } from 'react-dom/test-utils'; |
| 15 | + |
| 16 | +import { configure } from 'enzyme'; |
| 17 | +import Adapter from 'enzyme-adapter-react-16'; |
| 18 | +import { exportAllDeclaration } from '@babel/types'; |
| 19 | + |
| 20 | +Enzume.configure({ adapter: new Adapter() }); |
| 21 | + |
| 22 | +let globalM = { |
| 23 | + url: null, |
| 24 | + isProjectLoaded: false, |
| 25 | + fileTree: null, |
| 26 | + componentName: '', |
| 27 | + isFileDirectoryOpen: true, |
| 28 | + rightPanelDisplay: 'browserView', |
| 29 | + displayedFileCode: '', |
| 30 | + isFolderOpen: {}, |
| 31 | + isFileHighlighted: '', |
| 32 | + projectFilePath: '', |
| 33 | + filePathMap: {}, |
| 34 | +}; |
| 35 | + |
| 36 | +let dispatchToGlobal = jest.fn(); |
| 37 | + |
| 38 | +let wrapper = mount( |
| 39 | + <GlobalContext.Provider value={[globalM, dispatchToGlobal]}> |
| 40 | + <ProjectLoader /> |
| 41 | + <Navbar> |
| 42 | + <FileDirectory /> |
| 43 | + </Navbar> |
| 44 | + <RightPanel> |
| 45 | + <BrowserView /> |
| 46 | + <EditorView /> |
| 47 | + </RightPanel> |
| 48 | + </GlobalContext.Provider> |
| 49 | +); |
| 50 | + |
| 51 | +test('displays browser view of when URL is correctly inputted', () => { |
| 52 | + globalM.url !== null; |
| 53 | + const browserViewComponent = wrapper.find(<BrowserView />); |
| 54 | + expect(browserViewComponent).toMatchSnapshot(); |
| 55 | +}); |
| 56 | + |
| 57 | +test(`omitting 'www' from URL still displays browser view`, () => { |
| 58 | + const addHttps = wrapper.find(addHttps()); |
| 59 | + addHttps(!url.startsWith('www')); |
| 60 | + const browserViewComponent = wrapper.find(<BrowserView />); |
| 61 | + expect(browserViewComponent).toMatchSnapshot(); |
| 62 | +}); |
6 | 63 |
|
7 | 64 | test('displays file directory of project that is loaded', () => {}); |
8 | 65 |
|
|
0 commit comments