Skip to content

Commit

Permalink
Update tsc and fix spec type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rjz committed Apr 12, 2017
1 parent 4859392 commit 1427363
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
25 changes: 16 additions & 9 deletions package.json
Expand Up @@ -20,30 +20,37 @@
"author": "RJ Zaworski <rj@rjzaworski.com> (http://rjzaworski.com)",
"license": "ISC",
"dependencies": {
"react": "15.4.1",
"react-redux": "4.4.6",
"react": "15.4.2",
"react-redux": "5.0.3",
"redux": "3.6.0",
"redux-thunk": "^2.2.0"
"redux-thunk": "2.2.0"
},
"devDependencies": {
"@types/react": "0.14.55",
"@types/react-dom": "0.14.20",
"@types/jest": "19.2.2",
"@types/minimist": "1.2.0",
"@types/node": "7.0.12",
"@types/react": "15.0.21",
"@types/react-dom": "0.14.23",
"@types/react-redux": "4.4.38",
"@types/redux": "3.6.0",
"@types/semver": "5.3.31",
"@types/sinon": "2.1.2",
"babel-core": "6.14.0",
"babel-loader": "6.2.5",
"babel-polyfill": "6.20.0",
"babel-preset-es2015": "6.14.0",
"coveralls": "2.11.15",
"http-server": "0.9.0",
"jest": "17.0.3",
"jest-cli": "17.0.3",
"jest": "19.0.2",
"jest-cli": "19.0.2",
"react-addons-test-utils": "15.4.1",
"react-dom": "15.4.1",
"sinon": "1.17.4",
"source-map-loader": "0.1.5",
"ts-jest": "17.0.3",
"ts-jest": "19.0.7",
"ts-loader": "0.8.2",
"tslint": "3.14.0",
"typescript": "2.0.6",
"typescript": "2.3.0",
"typings": "2.1.0",
"webpack": "1.13.1",
"webpack-fail-plugin": "1.0.5",
Expand Down
6 changes: 4 additions & 2 deletions src/actions/__tests__/index_spec.ts
@@ -1,9 +1,11 @@
jest.mock('../../api')

import { createStore } from 'redux'
import { api } from '../../api'
import * as apiExports from '../../api'
import * as actions from '../index'

const api: jest.Mocked<apiExports.Api> = apiExports.api as any

describe('actions', () => {
const store = () => {
const reducer = jest.fn()
Expand Down Expand Up @@ -34,7 +36,7 @@ describe('actions', () => {
})

it('sends an API request', () => {
actions.saveCount({ value: '14' })(jest.fn())
actions.saveCount({ value: 14 })(jest.fn())
expect(api.save.mock.calls.length).toEqual(1)
})

Expand Down
2 changes: 1 addition & 1 deletion src/actions/index.ts
Expand Up @@ -69,4 +69,4 @@ function apiActionGroupFactory<Q, S>(x: ApiActionGroup<Q, S>, go: apiFunc<Q, S>)
}

export const saveCount = apiActionGroupFactory(_saveCount, api.save)
export const loadCount = apiActionGroupFactory(_loadCount, api.load)
export const loadCount = () => apiActionGroupFactory(_loadCount, api.load)(null)
7 changes: 6 additions & 1 deletion src/api.ts
Expand Up @@ -18,7 +18,12 @@ const flakify = <T>(f: () => T): Promise<T> =>
}, 200 + Math.random() * 2000)
)

export const api = {
export type Api = {
save(x: { value: number }): Promise<null>,
load(): (Promise<{ value: number }>),
}

export const api: Api = {
save: (counter: { value: number }): Promise<null> => flakify(() => {
localStorage.setItem('__counterValue', counter.value.toString())
return null
Expand Down
22 changes: 21 additions & 1 deletion src/components/__tests__/__snapshots__/counter_spec.tsx.snap
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/Counter renders 1`] = `
<CounterComponent
counter={
Expand All @@ -20,5 +22,23 @@ exports[`components/Counter renders 1`] = `
"subscribe": [Function],
Symbol(observable): [Function],
}
} />
}
storeSubscription={
Subscription {
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(observable): [Function],
},
"unsubscribe": null,
}
}
/>
`;
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -3,6 +3,7 @@
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"lib": ["es6"],
"module": "commonjs",
"target": "es6",
"jsx": "react"
Expand Down

0 comments on commit 1427363

Please sign in to comment.