mirror of
https://github.com/chinchang/web-maker.git
synced 2025-08-02 19:37:29 +02:00
fix: fix testsuite and create a sample test for the footer
This commit is contained in:
11
.babelrc
Normal file
11
.babelrc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
"react",
|
||||||
|
"env"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
["transform-react-jsx", {
|
||||||
|
"pragma": "h"
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
6108
package-lock.json
generated
6108
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
38
package.json
38
package.json
@@ -4,7 +4,8 @@
|
|||||||
"description": "A blazing fast & offline web playground",
|
"description": "A blazing fast & offline web playground",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev",
|
"start": "if-env NODE_ENV=production && npm run -s serve || npm run -s dev",
|
||||||
"build": "preact build --template src/index.html --no-prerender --service-worker false",
|
"build":
|
||||||
|
"preact build --template src/index.html --no-prerender --service-worker false",
|
||||||
"serve": "preact build && preact serve",
|
"serve": "preact build && preact serve",
|
||||||
"dev": "preact watch --template src/index.html --https --no-prerender",
|
"dev": "preact watch --template src/index.html --https --no-prerender",
|
||||||
"lint": "eslint src",
|
"lint": "eslint src",
|
||||||
@@ -22,10 +23,7 @@
|
|||||||
"src/detached-window.js"
|
"src/detached-window.js"
|
||||||
],
|
],
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,jsx,json,css,md}": [
|
"*.{js,jsx,json,css,md}": ["prettier --write", "git add"]
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^7.2.3",
|
"babel-eslint": "^7.2.3",
|
||||||
@@ -54,6 +52,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emmetio/codemirror-plugin": "^0.5.4",
|
"@emmetio/codemirror-plugin": "^0.5.4",
|
||||||
|
"babel-preset-env": "^1.7.0",
|
||||||
|
"babel-preset-react": "^6.24.1",
|
||||||
"code-blast-codemirror": "chinchang/code-blast-codemirror#web-maker",
|
"code-blast-codemirror": "chinchang/code-blast-codemirror#web-maker",
|
||||||
"codemirror": "^5.37.0",
|
"codemirror": "^5.37.0",
|
||||||
"copy-webpack-plugin": "^4.5.1",
|
"copy-webpack-plugin": "^4.5.1",
|
||||||
@@ -67,19 +67,13 @@
|
|||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"verbose": true,
|
"verbose": true,
|
||||||
"setupFiles": [
|
"setupFiles": ["<rootDir>/src/tests/__mocks__/browserMocks.js"],
|
||||||
"<rootDir>/src/tests/__mocks__/browserMocks.js"
|
|
||||||
],
|
|
||||||
"testURL": "http://localhost:8080",
|
"testURL": "http://localhost:8080",
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": ["js", "jsx"],
|
||||||
"js",
|
"moduleDirectories": ["node_modules"],
|
||||||
"jsx"
|
|
||||||
],
|
|
||||||
"moduleDirectories": [
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/tests/__mocks__/fileMock.js",
|
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
|
||||||
|
"<rootDir>/src/tests/__mocks__/fileMock.js",
|
||||||
"\\.(css|less|scss)$": "identity-obj-proxy",
|
"\\.(css|less|scss)$": "identity-obj-proxy",
|
||||||
"^./style$": "identity-obj-proxy",
|
"^./style$": "identity-obj-proxy",
|
||||||
"^preact$": "<rootDir>/node_modules/preact/dist/preact.min.js",
|
"^preact$": "<rootDir>/node_modules/preact/dist/preact.min.js",
|
||||||
@@ -89,20 +83,12 @@
|
|||||||
"^react-addons-css-transition-group$": "preact-css-transition-group"
|
"^react-addons-css-transition-group$": "preact-css-transition-group"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": ["last 3 Chrome versions", "last 3 Firefox versions"],
|
||||||
"last 3 Chrome versions",
|
|
||||||
"last 3 Firefox versions"
|
|
||||||
],
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/chinchang/web-maker.git"
|
"url": "git+https://github.com/chinchang/web-maker.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": ["frontend", "playground", "web", "editor"],
|
||||||
"frontend",
|
|
||||||
"playground",
|
|
||||||
"web",
|
|
||||||
"editor"
|
|
||||||
],
|
|
||||||
"author": "Kushagra Gour",
|
"author": "Kushagra Gour",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
12
src/tests/footer.test.js
Normal file
12
src/tests/footer.test.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { h, Component } from 'preact';
|
||||||
|
import Footer from '../components/Footer';
|
||||||
|
import { Link } from 'preact-router/match';
|
||||||
|
// See: https://github.com/mzgoddard/preact-render-spy
|
||||||
|
import { shallow, deep } from 'preact-render-spy';
|
||||||
|
|
||||||
|
describe('Initial Test of the Footer', () => {
|
||||||
|
test('Footer renders 1 link with an ID of notificationsBtn', () => {
|
||||||
|
const context = shallow(<Footer />);
|
||||||
|
expect(context.find('#notificationsBtn').exists()).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@@ -1,14 +0,0 @@
|
|||||||
import { h, Component } from 'preact';
|
|
||||||
import Header from '../components/header';
|
|
||||||
import { Link } from 'preact-router/match';
|
|
||||||
// See: https://github.com/mzgoddard/preact-render-spy
|
|
||||||
import { shallow, deep } from 'preact-render-spy';
|
|
||||||
|
|
||||||
describe('Initial Test of the Header', () => {
|
|
||||||
|
|
||||||
test('Header renders 3 nav items', () => {
|
|
||||||
const context = shallow(<Header />);
|
|
||||||
expect(context.find('h1').text()).toBe('Preact App');
|
|
||||||
expect(context.find(<Link />).length).toBe(3);
|
|
||||||
});
|
|
||||||
});
|
|
Reference in New Issue
Block a user