Skip to content

Commit

Permalink
Update all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
artemave committed Jan 7, 2020
1 parent 584ced5 commit bd167ae
Show file tree
Hide file tree
Showing 8 changed files with 1,538 additions and 2,204 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["@babel/preset-react"]
"presets": ["@babel/preset-react"],
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
13
23 changes: 15 additions & 8 deletions browser/app.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
const React = require('react')
import React from 'react'
import PropTypes from 'prop-types'

export default class App extends React.Component {
static get propTypes() {
return {
apiUrl: PropTypes.string,
}
}

module.exports = class App extends React.Component {
constructor(props) {
super(props);
this.state = {user: ''};
super(props)
this.state = {user: ''}

this.handleNameChange = this.handleNameChange.bind(this);
this.fetchTodos = this.fetchTodos.bind(this);
this.handleNameChange = this.handleNameChange.bind(this)
this.fetchTodos = this.fetchTodos.bind(this)
}

handleNameChange(event) {
this.setState({user: event.target.value});
this.setState({user: event.target.value})
}

async fetchTodos(event) {
Expand All @@ -33,7 +40,7 @@ module.exports = class App extends React.Component {
return this.state.todos
?
<>
<h1>{this.state.user}'s TODOs</h1>
<h1>{this.state.user}&apos;s TODOs</h1>
<ul>
{this.state.todos.map((todo, n) => <li key={n}>{todo.title}</li>)}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion browser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import React from 'react'
import ReactDOM from 'react-dom'
import App from './app'

ReactDOM.render(<App apiUrl={window.location.href}/>, document.body)
ReactDOM.render(<App apiUrl={window.location.href}/>, document.querySelector('main'))
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@
"start": "./scripts/start.sh",
"postinstall": "electron-rebuild",
"dev": "nf start",
"test": "electron-mocha -r @babel/register --color --renderer ./test/*Spec.js",
"test": "electron-mocha -r @babel/register --no-timeout --color --renderer ./test/*Spec.js",
"lint": "eslint $(git ls-files | grep -E '\\.js$')",
"build": "webpack",
"heroku-postbuild": "npm run build",
"watch-assets": "yarn build --watch"
},
"dependencies": {
"@babel/core": "latest",
"@babel/preset-react": "^7.0.0",
"@babel/preset-react": "latest",
"babel-loader": "latest",
"electron-rebuild": "^1.8.4",
"eslint-plugin-react": "^7.13.0",
"electron-rebuild": "latest",
"eslint-plugin-react": "latest",
"express": "latest",
"morgan": "latest",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"sqlite3": "^4.0.8",
"react": "latest",
"react-dom": "latest",
"sqlite3": "latest",
"webpack": "latest",
"webpack-cli": "latest",
"webpack-manifest-plugin": "latest"
},
"devDependencies": {
"@babel/register": "^7.4.4",
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
"@babel/register": "latest",
"browser-monkey": "latest",
"chai": "latest",
"chokidar": "latest",
"electron": "^4",
"electron-mocha": "^7",
"electron": "latest",
"electron-mocha": "latest",
"eslint": "latest",
"foreman": "latest",
"mocha": "latest",
Expand Down
3 changes: 1 addition & 2 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const http = require('http')
const express = require('express')
const morgan = require('morgan')
const loadManifest = require('./loadManifest')
const sqlite3 = require('sqlite3')
const LiveReload = require('./liveReload')
Expand All @@ -18,6 +17,7 @@ function renderIndexHtml () {
<title>TODOs</title>
</head>
<body>
<main></main>
${scripts.map(url => `<script type="text/javascript" src="/dist/${url}"></script>`).join('\n')}
</body>
</html>
Expand All @@ -26,7 +26,6 @@ function renderIndexHtml () {

module.exports = function () {
const app = express()
app.use(morgan('dev'))

app.get('/api/todos/:user', (req, res) => {
const db = new sqlite3.Database(process.env.DB || process.cwd() + '/app.db')
Expand Down
18 changes: 9 additions & 9 deletions test/todosSpec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const {existsSync, unlinkSync} = require('fs')
const ReactDOM = require('react-dom')
const React = require('react')
const createMonkey = require('browser-monkey/create')
const createTestDiv = require('browser-monkey/lib/createTestDiv')
const {Database} = require('sqlite3')
const App = require('../browser/app')
const createServer = require('../server/app')
import {existsSync, unlinkSync} from 'fs'
import ReactDOM from 'react-dom'
import React from 'react'
import createMonkey from 'browser-monkey/create'
import createTestDiv from 'browser-monkey/lib/createTestDiv'
import {Database} from 'sqlite3'
import createServer from '../server/app'
import App from '../browser/app'

let dbPath = process.env.DB = process.cwd() + '/test/test.db'

Expand Down Expand Up @@ -58,7 +58,7 @@ describe('todos app', () => {
})

context('user does not exist', () => {
it('shows a message', async () => {
it('shows a "not found" message', async () => {
await page.find('input[name=user]').typeIn('Bob')
await page.click('Fetch TODOs')
await page.shouldHave({text: "Could not find Bob's TODOs"})
Expand Down
Loading

0 comments on commit bd167ae

Please sign in to comment.