From 69cf900c0ba6561ae0c73ff1b88fa89718dcabda Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 13 Jan 2017 21:11:12 -0800 Subject: [PATCH] Add snapshot test for MainWindow --- js/__mocks__/styleMock.js | 0 js/__tests__/MainWindow.js | 46 +++ js/__tests__/__snapshots__/MainWindow.js.snap | 369 ++++++++++++++++++ package.json | 7 + 4 files changed, 422 insertions(+) create mode 100644 js/__mocks__/styleMock.js create mode 100644 js/__tests__/MainWindow.js create mode 100644 js/__tests__/__snapshots__/MainWindow.js.snap diff --git a/js/__mocks__/styleMock.js b/js/__mocks__/styleMock.js new file mode 100644 index 00000000..e69de29b diff --git a/js/__tests__/MainWindow.js b/js/__tests__/MainWindow.js new file mode 100644 index 00000000..8371934b --- /dev/null +++ b/js/__tests__/MainWindow.js @@ -0,0 +1,46 @@ +const Winamp = ({ + media: { + addEventListener: jest.fn(), + _analyser: null + } +}); + +const canvasMockify = require('canvas-mock'); + +function createNodeMock(element) { + if (element.type === 'canvas') { + const Canvas = window.document.createElement('canvas'); + canvasMockify(Canvas); // mock canvas functions required by Phaser.js are added + return Canvas; + } + return null; +} + +window.requestAnimationFrame = () => {}; + +import React from 'react'; +import {Provider} from 'react-redux'; +import renderer from 'react-test-renderer'; +import getStore from '../store'; + +import MainWindow from '../components/MainWindow'; + +describe('MainWindow', () => { + let store; + beforeEach(() => { + store = getStore(Winamp); + }); + + it('renders to snapshot', () => { + const options = {createNodeMock}; + const tree = renderer.create( + + + , + options).toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/js/__tests__/__snapshots__/MainWindow.js.snap b/js/__tests__/__snapshots__/MainWindow.js.snap new file mode 100644 index 00000000..6a02c84f --- /dev/null +++ b/js/__tests__/__snapshots__/MainWindow.js.snap @@ -0,0 +1,369 @@ +exports[`MainWindow renders to snapshot 1`] = ` +
+
+ Loading... +
+
+
+
    +
  • + + Winamp2-js... + +
  • +
  • +
    +
  • +
  • + Play File... +
  • +
  • +
      +
    • + Load Skin... +
    • +
    • +
      +
    • +
    • + +
    • +
    • + Mac OSX v1.5 (Aqua) +
    • +
    • + TopazAmp +
    • +
    • + Vizor +
    • +
    • + XMMS Turquoise +
    • +
    • + Zaxon Remake +
    • +
    + Skins +
  • +
  • +
    +
  • +
  • + Exit +
  • +
+
+
+
+ +
+
+ 0 +
+
+ 0 +
+
+ 0 +
+
+ 0 +
+
+