-
- Electron Fiddle allows you to build little experiments and mini-apps with Electron. Each Fiddle has at least three of these files: A main script, a renderer script, a preload script, and an HTML file.
-
-
- If you
-
- require()
-
- a module, Fiddle will install it automatically. It will also automatically provide you with autocomplete information for the
-
- electron
-
- module.
-
- ,
- "name": "fiddle-editors",
- "selector": "div.mosaic-root",
- "title": "π Fiddle Editors",
- },
- {
- "content":
-
- Electron Fiddle knows about all released Electron versions, downloading your versions automatically in the background.
-
-
- Open the preferences to see all available versions and delete those previously downloaded.
-
- ,
- "name": "select-versions",
- "selector": "#version-chooser",
- "title": "π Choose an Electron Version",
- },
- {
- "content":
- Hit this button to give your Fiddle a try and start it.
-
,
- "name": "button-run",
- "selector": "#button-run",
- "title": "π Run Your Fiddle",
- },
- {
- "content":
-
- Like what you've built? You can save your Fiddle as a public GitHub Gist, allowing other users to load it by pasting the URL into the address bar. If they don't have Electron Fiddle, they can see and download your code directly from GitHub.
-
-
- You can also package your Fiddle as a standalone binary or as an installer from the "Tasks" menu.
-
- ,
- "name": "button-action",
- "selector": "#button-action",
- "title": "πΊ Share Your Fiddle",
- },
- {
- "content":
- We've finished our tour of Electron Fiddle, but if this is your first time using Electron, we could introduce you to its basics. Interested?
-
,
- "getButtons": [Function],
- "name": "first-time-electron",
- "selector": "div.mosaic-root",
- "title": "π Getting Started With Electron?",
- },
- {
- "content":
-
- Every Electron app starts with a main script, very similar to how a Node.js application is started. The main script runs in the "main process". To display a user interface, the main process creates renderer processes βΒ usually in the form of windows, which Electron calls Β
-
- BrowserWindow
-
- .
-
-
- To get started, pretend that the main process is just like a Node.js process. All APIs and features found in Electron are accessible through the
-
- electron
-
- module, which can be required like any other Node.js module.
-
-
- The default fiddle creates a new
-
- BrowserWindow
-
- and loads an HTML file.
-
- ,
- "name": "main-editor",
- "selector": "div.mosaic-window.main\\.js",
- "title": "π Main Script",
- },
- {
- "content":
- In the default fiddle, this HTML file is loaded in the Β
-
- BrowserWindow
-
- . Any HTML, CSS, or JavaScript that works in a browser will work here, too. In addition, Electron allows you to execute Node.js code. Take a close look at the Β
-
- <script />
-
- tag and notice how we can call
-
-
- require()
-
- like we would in Node.js.
-
,
- "name": "html-editor",
- "selector": "div.mosaic-window.index\\.html",
- "title": "π HTML",
- },
- {
- "content":
-
- This is the script we just required from the HTML file. In here, you can do anything that works in Node.js
-
- and
-
- anything that works in a browser.
-
-
- By the way: If you want to use an
-
- npm
-
- module here, just Β
-
- require
-
- it. Electron Fiddle will automatically detect that you requested a module and install it as soon as you run your fiddle.
-
- ,
- "name": "renderer-editor",
- "selector": "div.mosaic-window.renderer\\.js",
- "title": "π Renderer Script",
- },
- }
- }
-/>
-`;
diff --git a/tests/renderer/components/tour-spec.tsx b/tests/renderer/components/tour-spec.tsx
deleted file mode 100644
index d2c619ca78..0000000000
--- a/tests/renderer/components/tour-spec.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import * as React from 'react';
-
-import { mount, shallow } from 'enzyme';
-import { mocked } from 'jest-mock';
-
-import { Tour } from '../../../src/renderer/components/tour';
-import { overrideRendererPlatform } from '../../utils';
-
-describe('VersionChooser component', () => {
- const oldQuerySelector = document.querySelector;
- const mockTour = new Set([
- {
- name: 'mock-step-1',
- selector: 'div.mock-1',
- title: 'Step 1',
- content: mock-step-1,
- },
- {
- name: 'mock-step-2',
- selector: 'div.mock-2',
- title: 'Step 2',
- content: mock-step-2,
- },
- ]);
-
- beforeEach(() => {
- overrideRendererPlatform('darwin');
-
- document.querySelector = jest.fn(() => ({
- getBoundingClientRect: jest.fn(() => ({
- top: 20,
- left: 25,
- height: 120,
- width: 130,
- })),
- }));
- });
-
- afterEach(() => {
- document.querySelector = oldQuerySelector;
- });
-
- it('renders', () => {
- const mockStop = jest.fn();
- const wrapper = shallow();
-
- expect(wrapper).toMatchSnapshot();
- });
-
- it('renders supplied buttons', () => {
- mockTour.forEach((item) => {
- (item as any).getButtons = () => [];
- });
-
- const mockStop = jest.fn();
- const wrapper = shallow();
-
- expect(wrapper.find('button').text()).toBe('Hello');
- });
-
- it('renders "Finish Tour" at the end', () => {
- const singleItemTour = new Set([
- {
- name: 'mock-step-1',
- selector: 'div.mock-1',
- title: 'Step 1',
- content: mock-step-1,
- },
- ]);
-
- const mockStop = jest.fn();
- const wrapper = mount();
-
- expect(wrapper.find('button').text()).toBe('tick-circleFinish Tour');
- });
-
- it('handles a missing target', () => {
- mocked(document.querySelector).mockReturnValueOnce(null);
-
- const mockStop = jest.fn();
- const wrapper = shallow();
-
- expect(wrapper.find('svg').length).toBe(1);
- });
-
- it('stops on stop()', () => {
- const mockStop = jest.fn();
- const wrapper = shallow();
- const instance: any = wrapper.instance();
-
- instance.stop();
-
- expect(mockStop).toHaveBeenCalled();
- });
-
- it('advances on advance()', () => {
- const mockStop = jest.fn();
- const wrapper = shallow();
- const instance: any = wrapper.instance();
-
- instance.advance();
- expect((wrapper.state('step') as any).name).toBe('mock-step-2');
-
- instance.advance();
- expect(wrapper.state('step')).toBe(null);
- });
-
- it('handles a resize', () => {
- jest.useFakeTimers();
-
- const mockStop = jest.fn();
- const wrapper = shallow();
- const instance: any = wrapper.instance();
-
- instance.forceUpdate = jest.fn();
- instance.onResize();
-
- expect(instance.resizeHandle).toBeTruthy();
- jest.runAllTimers();
-
- expect(instance.forceUpdate).toHaveBeenCalled();
- });
-
- it('removes the resize listener', () => {
- const oldRemove = window.removeEventListener;
- window.removeEventListener = jest.fn();
-
- const mockStop = jest.fn();
- const wrapper = shallow();
- const instance: any = wrapper.instance() as any;
-
- instance.componentWillUnmount();
- expect(window.removeEventListener).toHaveBeenCalled();
-
- window.removeEventListener = oldRemove;
- });
-});
diff --git a/tests/renderer/components/tour-welcome-spec.tsx b/tests/renderer/components/tour-welcome-spec.tsx
deleted file mode 100644
index e11b9cbf21..0000000000
--- a/tests/renderer/components/tour-welcome-spec.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import * as React from 'react';
-
-import { shallow } from 'enzyme';
-
-import {
- WelcomeTour,
- getWelcomeTour,
-} from '../../../src/renderer/components/tour-welcome';
-import { AppState } from '../../../src/renderer/state';
-
-describe('Header component', () => {
- let store: AppState;
-
- beforeEach(() => {
- ({ state: store } = window.app);
- store.isTourShowing = true;
- });
-
- it('renders', () => {
- const wrapper = shallow();
- expect(wrapper).toMatchSnapshot();
- });
-
- it('renders null if the tour is not showing', () => {
- store.isTourShowing = false;
-
- const wrapper = shallow();
- expect(wrapper.html()).toBe(null);
- });
-
- it('renders the tour once started', () => {
- const wrapper = shallow();
- const instance: any = wrapper.instance();
-
- instance.startTour();
-
- expect(wrapper.state('isTourStarted')).toBe(true);
- expect(wrapper).toMatchSnapshot();
- });
-
- it('stops the tour on stopTour()', () => {
- const wrapper = shallow();
- const instance: any = wrapper.instance();
-
- instance.stopTour();
-
- expect(wrapper.state('isTourStarted')).toBe(false);
- expect(store.disableTour).toHaveBeenCalled();
- });
-
- describe('getWelcomeTour()', () => {
- it('offers custom buttons for the Electron step', () => {
- const tourSteps = [...getWelcomeTour()];
- const electronStep = tourSteps.find(
- ({ name }) => name === 'first-time-electron',
- );
- const mockParam = { stop: jest.fn(), advance: jest.fn() };
- const buttons = electronStep!.getButtons!(mockParam);
-
- shallow(buttons[0]).simulate('click');
- expect(mockParam.stop).toHaveBeenCalled();
-
- shallow(buttons[1]).simulate('click');
- expect(mockParam.advance).toHaveBeenCalled();
- });
- });
-});