Skip to content

Commit

Permalink
Remove demo from electrode-demo-index (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
didi0613 authored and jchip committed Jan 22, 2018
1 parent 9faaa70 commit 7c133be
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
8 changes: 2 additions & 6 deletions samples/electrode-demo-index/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"scripts": {
"test:dev": "clap test-frontend",
"test": "clap check-cov && clap cov-frontend",
"demo": "clap server-dev",
"hot": "clap server-hot",
"build": "npm run generate && clap build-lib",
"generate": "npm run generate-metadata && npm run generate-documentation",
"generate-metadata": "electrode-docgen --package ./package.json --src ./src --metadata components.json",
Expand All @@ -38,12 +36,10 @@
],
"license": "Apache-2.0",
"dependencies": {
"component-playground": "^3.0.0",
"electrode-archetype-react-component": "../../packages/electrode-archetype-react-component",
"object-assign": "^4.1.0"
},
"devDependencies": {
"electrode-archetype-react-component": "../../packages/electrode-archetype-react-component",
"electrode-archetype-react-component-dev": "../../packages/electrode-archetype-react-component-dev",
"webpack": "^3"
"electrode-archetype-react-component-dev": "../../packages/electrode-archetype-react-component-dev"
}
}
50 changes: 38 additions & 12 deletions samples/electrode-demo-index/test/client/components/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,52 @@
* Client tests
*/
import React from "react";
import { shallow } from "enzyme";
import { mount } from "enzyme";

import ElectrodeDemoIndex from "src/index";

describe("index", () => {
let container;
let component;

beforeEach(() => {
container = document.createElement("div");
});

afterEach(() => {
component.unmount();
});

it("should render into the document", () => {
const component = shallow(React.createElement(ElectrodeDemoIndex));
component = mount(<ElectrodeDemoIndex />, container);
expect(component).to.not.be.null;
});

it("should throw a warning when calling _setDemoContext", () => {
class Demo extends ElectrodeDemoIndex {
componentDidMount() {
this._setDemoContext({libraryScope: {}, components: []});
}
}
it("should render component-documentation", () => {
component = mount(<ElectrodeDemoIndex scope={{}} />, container);
expect(component.html()).to.equal(
"<div class=\"component-documentation\"></div>"
);
});

// TODO: fix this dummy test to check for console warning
// https://gecgithub01.walmart.com/electrode/demo-index/issues/10
const component = shallow(React.createElement(Demo));
expect(component).to.not.be.null;
it("should render component-documentation with components", () => {
component = mount(
<ElectrodeDemoIndex
components={[
{
title: "electrode-demo-index",
examples: {
map: () => {}
}
}
]}
/>,
container
);
expect(component.html()).to.equal(
"<div class=\"component-documentation\"><div>" +
"<h3 id=\"electrode-demo-index\">" +
"electrode-demo-index</h3></div></div>"
);
});
});

0 comments on commit 7c133be

Please sign in to comment.