Skip to content

Commit

Permalink
Merge pull request #4 from magic-script/feature/refactor_unit_tests
Browse files Browse the repository at this point in the history
Change unit tests to get components from magic-script-components library
  • Loading branch information
panwrona authored Sep 13, 2019
2 parents 89b9795 + 5bbb7d1 commit 1f646dd
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 29 deletions.
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ module.exports = {
},
testEnvironment: "node",
testMatch: ["**/__tests__/*.js"],
testPathIgnorePatterns: ["/node_modules/", ".eslintrc.js"]
testPathIgnorePatterns: ["/node_modules/", ".eslintrc.js"],
transformIgnorePatterns: [
"/node_modules/(?!magic-script-components).+(js|jsx)$"
]
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
},
"peerDependencies": {
"@babel/core": "^7.6.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"rollup-plugin-babel": "^4.3.3"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"magic-script-components": "2.0.0",
"react-test-renderer": "^16.9.0"
}
}
4 changes: 2 additions & 2 deletions src/__tests__/Audio.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Audio } from "magic-script-components";

describe("Audio component", () => {
test("Matches the snapshot", () => {
const props = {fileName: "test_file.avi"};
const audio = create(React.createElement("audio", props));
const audio = create(<Audio fileName="test_file.avi" />);
expect(audio.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/Button.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Button } from "magic-script-components";

describe("Button component", () => {
test("Matches the snapshot", () => {
const props = {text: "Test Button", width: 0.25, height: 0.1}
const button = create(React.createElement("button", props));
const button = create(<Button text="Test Button" width={0.25} height={0.1} />);
expect(button.toJSON()).toMatchSnapshot();
});
});
3 changes: 2 additions & 1 deletion src/__tests__/CircleConfirmation.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { CircleConfirmation } from "magic-script-components";

describe("CircleConfirmation component", () => {
test("Matches the snapshot", () => {
const circleConfirmation = create(React.createElement("circleConfirmation"));
const circleConfirmation = create(<CircleConfirmation />);
expect(circleConfirmation.toJSON()).toMatchSnapshot();
});
});
3 changes: 2 additions & 1 deletion src/__tests__/ColorPicker.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { ColorPicker } from "magic-script-components";

describe("ColorPicker component", () => {
test("Matches the snapshot", () => {
const colorPicker = create(React.createElement("colorPicker"));
const colorPicker = create(<ColorPicker />);
expect(colorPicker.toJSON()).toMatchSnapshot();
});
});
6 changes: 3 additions & 3 deletions src/__tests__/DatePicker.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { DatePicker } from "magic-script-components";

describe("DatePicker component", () => {
test("Matches the snapshot", () => {
const props = {label: "Test DatePicker"}
const datepicker = create(React.createElement("datePicker", props));
expect(datepicker.toJSON()).toMatchSnapshot();
const datePicker = create(<DatePicker label="Test DatePicker" />);
expect(datePicker.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/Image.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Image } from "magic-script-components";

describe("Image component", () => {
test("Matches the snapshot", () => {
const props = {filePath: "test_file.png", width: 0.2, height: 0.2}
const image = create(React.createElement("image", props));
const image = create(<Image filePath="test_file.png" width={0.2} height={0.2} />);
expect(image.toJSON()).toMatchSnapshot();
});
});
3 changes: 2 additions & 1 deletion src/__tests__/ListView.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { ListView } from "magic-script-components";

describe("ListView component", () => {
test("Matches the snapshot", () => {
const listView = create(React.createElement("listView"));
const listView = create(<ListView />);
expect(listView.toJSON()).toMatchSnapshot();
});
});
3 changes: 2 additions & 1 deletion src/__tests__/ListViewItem.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { ListViewItem } from "magic-script-components";

describe("ListViewItem component", () => {
test("Matches the snapshot", () => {
const listViewItem = create(React.createElement("listViewItem"));
const listViewItem = create(<ListViewItem />);
expect(listViewItem.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/Model.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Model } from "magic-script-components";

describe("Model component", () => {
test("Matches the snapshot", () => {
const props = {modelPath:"", materialPath:"", texturePath:"", textureName:""}
const model = create(React.createElement("model", props));
const model = create(<Model modelPath="" materialPath="" texturePath="" textureName="" />);
expect(model.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/PageView.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { PageView } from "magic-script-components";

describe("PageView component", () => {
test("Matches the snapshot", () => {
const props = {width: 0.2, height: 0.2}
const pageView = create(React.createElement("pageView", props));
const pageView = create(<PageView width={0.2} height={0.2} />);
expect(pageView.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/ScrollBar.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { ScrollBar } from "magic-script-components";

describe("ScrollBar component", () => {
test("Matches the snapshot", () => {
const props = {width: 0.1}
const scrollbar = create(React.createElement("scrollBar", props));
const scrollbar = create(<ScrollBar width={0.1} />);
expect(scrollbar.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/Text.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Text } from "magic-script-components";

describe("Text component", () => {
test("Matches the snapshot", () => {
const props = {text: "Test Text"}
const text = create(React.createElement("text", props));
const text = create(<Text text="Test Text" />);
expect(text.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/TextEdit.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { TextEdit } from "magic-script-components";

describe("TextEdit component", () => {
test("Matches the snapshot", () => {
const props = {text: "Test Text Edit", width: 0.25, height: 0.1}
const text = create(React.createElement("textEdit", props));
const text = create(<TextEdit text="Test Text Edit" width={0.25} height={0.1} />);
expect(text.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/TimePicker.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { TimePicker } from "magic-script-components";

describe("TimePicker component", () => {
test("Matches the snapshot", () => {
const props = {label: "Test TimePicker"}
const timePicker = create(React.createElement("timePicker", props));
const timePicker = create(<TimePicker label="Test TimePicker" />);
expect(timePicker.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions src/__tests__/Video.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
import React from "react";
import { create } from "react-test-renderer";
import { Video } from "magic-script-components";

describe("Video component", () => {
test("Matches the snapshot", () => {
const props = {videoPath: "test_file.mp4"}
const video = create(React.createElement("video", props));
const video = create(<Video videoPath="test_file.mp4" />);
expect(video.toJSON()).toMatchSnapshot();
});
});

0 comments on commit 1f646dd

Please sign in to comment.