Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement typescript #421

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module.exports = {
}],
'jsdoc/require-description': 'error',
'jsdoc/require-param': 'error',
'jsdoc/require-returns-check': 'error'
'jsdoc/require-returns-check': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error'
// '@typescript-eslint/explicit-function-return-type': 'warn',
// '@typescript-eslint/no-explicit-any': 'error'
},
Expand Down
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"args": [
"test",
"--runInBand",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}"
],
"cwd": "/Users/jonathandayton/agrilyst/mobx-async-store",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"runtimeExecutable": "yarn"
}
]
}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ describe('it changes the zone name', () => {
expect(wrapper.text()).toMatch('Zone 1')
wrapper.find('button').simulate('click')
expect(wrapper.text()).toMatch('Zone 2')
expect(fetch.mock.calls).toHaveLength(2)
const [fetchZone, patchZone] = fetch.mock.calls
expect(fetchMock.mock.calls).toHaveLength(2)
const [fetchZone, patchZone] = fetchMock.mock.calls
expect(fetchZone[0].method).toEqual('GET')
expect(fetchZone[0].body).toMatch('Zone 1')
expect(fetchZone[0].method).toEqual('PATCH')
Expand All @@ -326,8 +326,8 @@ describe('fetchZone', () => {
it('loads the zone', async (done) => {
const zone = await fetchZone('1')
expect(zone.name).toMatch('Zone 1')
expect(fetch.mock.calls).toHaveLength(1)
expect(fetch.mock.calls[0].method).toEqual('GET')
expect(fetchMock.mock.calls).toHaveLength(1)
expect(fetchMock.mock.calls[0].method).toEqual('GET')
})
})

Expand Down Expand Up @@ -356,12 +356,12 @@ Example - failure on specific call
mockServer.start({ responseOverrides })

window.alert = jest.fn()
expect(fetch.mock.calls).toHaveLength(1)
expect(fetchMock.mock.calls).toHaveLength(1)

const submitBtn = wrapper.find('button[data-testid="manual-task-submit-button"]')
await submitBtn.simulate('click')

expect(fetch.mock.calls).toHaveLength(2)
expect(fetchMock.mock.calls).toHaveLength(2)
setImmediate(() => {
expect(window.alert).toHaveBeenCalledWith('There is an error!')
done()
Expand All @@ -378,13 +378,13 @@ Example - failure on all calls
const mockServer = new MockServer()
mockServer.start({ status: 500 })

expect(fetch.mock.calls).toHaveLength(1)
expect(fetchMock.mock.calls).toHaveLength(1)
const submitBtn = wrapper.find('button[data-testid="manual-task-submit-button"]')

try {
await submitBtn.simulate('click')
} catch (error) {
expect(fetch.mock.calls).toHaveLength(2)
expect(fetchMock.mock.calls).toHaveLength(2)
}
})

Expand Down Expand Up @@ -441,8 +441,8 @@ describe('it displays the zone name', () => {

it('displays the zone name', () => {
expect(wrapper.text()).toMatch('Fun Zone 1')
expect(fetch.mock.calls).toHaveLength(1)
expect(fetch.mock.calls[0].method).toEqual('GET')
expect(fetchMock.mock.calls).toHaveLength(1)
expect(fetchMock.mock.calls[0].method).toEqual('GET')
})
})

Expand Down
98 changes: 98 additions & 0 deletions dist/types/FactoryFarm.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/types/FactoryFarm.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions dist/types/MockServer.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/types/MockServer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading