Skip to content

Commit

Permalink
#4: Set up and maintain tests for the web app
Browse files Browse the repository at this point in the history
 - removed hidden errors for Snippet-rendering
  • Loading branch information
dartandrevinsky committed Apr 23, 2021
1 parent 7051e0f commit a4d847a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ console.log('Jest Config Loaded: maa-client/src/jest.config.js');
console.log('JEST_JUNIT_OUTPUT_DIR=', process.env.JEST_JUNIT_OUTPUT_DIR);

module.exports = {
setupFiles: [
'<rootDir>/window.setup.js'
],
moduleNameMapper:{
"\\.(css|less|sass|scss)$": "<rootDir>/__mocks__/styleMock.js",
"\\.(gif|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js"
Expand Down
23 changes: 23 additions & 0 deletions src/ui/elements/Snippet/Snippet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ import { history, store } from '../../../app/store';
import { ConnectedRouter } from 'connected-react-router';
import { Snippet } from './index';

// from: https://github.com/popperjs/popper-core/issues/478
// How to use Popper.js in Jest / JSDOM?
jest.mock(
'popper.js',
() =>
class Popper {
static placements = [
'auto', 'auto-end', 'auto-start',
'bottom', 'bottom-end', 'bottom-start',
'left', 'left-end', 'left-start',
'right', 'right-end', 'right-start',
'top', 'top-end', 'top-start'
];

constructor() {
return {
destroy: () => {},
scheduleUpdate: () => {}
};
}
}
);

describe(`src/ui/elements/Snippet/index.js`, () => {
describe(`Snippet component`, () => {

Expand Down
5 changes: 5 additions & 0 deletions src/window.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log('src/window.setup.js');

window.scrollTo = jest.fn();
window.prompt = jest.fn();
window.alert = jest.fn();

0 comments on commit a4d847a

Please sign in to comment.