-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from sharmalab/tests
Add Basic Test Framework and Tests
- Loading branch information
Showing
13 changed files
with
8,217 additions
and
4,459 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
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,3 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env', '@babel/preset-react'], | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
moduleFileExtensions: ['js', 'jsx'], | ||
transform: { | ||
'^.+\\.jsx?$': 'babel-jest', | ||
}, | ||
moduleNameMapper: { | ||
'\\.css$': 'identity-obj-proxy', | ||
}, | ||
transformIgnorePatterns: [ | ||
'/node_modules/(?!react-dnd)/', // Ignore node_modules except for react-dnd | ||
], | ||
setupFilesAfterEnv: ['@testing-library/jest-dom', './tests/setupTests.js'], | ||
}; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,30 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
|
||
import App from '../source/Application'; | ||
|
||
import testConfig from '../config/wines.json'; | ||
import testData from '../config/wines_data.json'; | ||
|
||
|
||
|
||
describe('Eaglescope basic tests', () => { | ||
test('renders title from config', async () => { | ||
const container = render( | ||
<App overrideConfig={testConfig} overrideData={testData}/> | ||
); | ||
await waitFor(() => { | ||
const titleElement = screen.getByText('Eaglescope Demo | Wines'); | ||
expect(titleElement).toBeInTheDocument(); | ||
}); | ||
}); | ||
test('renders vis elems', async () => { | ||
const container = render( | ||
<App overrideConfig={testConfig} overrideData={testData}/> | ||
); | ||
await waitFor(() => { | ||
const elements = document.getElementsByClassName('vis-grid-item'); | ||
expect(elements.length).toBeGreaterThan(6); | ||
}); | ||
}); | ||
}); |
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,12 @@ | ||
const fetch = require('cross-fetch'); | ||
|
||
global.fetch = fetch; | ||
|
||
|
||
window.matchMedia = jest.fn().mockImplementation(query => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), // Deprecated, but still used in some cases | ||
removeListener: jest.fn(), // Deprecated, but still used in some cases | ||
})); |