Fix tests for `hooks`
This commit is contained in:
parent
e9d82745ce
commit
83e837955c
|
@ -10,6 +10,10 @@
|
|||
"**/*.spec.tsx",
|
||||
"**/*.spec.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@nrwl/react/babel",
|
||||
{
|
||||
"runtime": "automatic",
|
||||
"useBuiltIns": "usage"
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": []
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
module.exports = function(api) {
|
||||
api.cache(true);
|
||||
const presets = [
|
||||
'@nrwl/next/babel',
|
||||
'module:metro-react-native-babel-preset'
|
||||
];
|
||||
const plugins = [
|
||||
["@babel/plugin-proposal-private-property-in-object", { "loose": false }]
|
||||
];
|
||||
|
||||
return {
|
||||
presets,
|
||||
plugins
|
||||
};
|
||||
};
|
|
@ -1,19 +1,19 @@
|
|||
import { Api } from './api'
|
||||
import { FetcherOptions } from './fetcher'
|
||||
import { Fetch } from './types'
|
||||
import {
|
||||
RNCookieManager,
|
||||
ToughCookieJar,
|
||||
wrapReactNativeCookieManager,
|
||||
wrapToughCookie,
|
||||
} from './cookies'
|
||||
import { FetcherOptions } from './fetcher'
|
||||
import { Fetch } from './types'
|
||||
|
||||
export { Api, FetcherOptions }
|
||||
export * from './types'
|
||||
export { LoginStatusChecker } from './loginStatus'
|
||||
export * from './types'
|
||||
export { Api, FetcherOptions }
|
||||
|
||||
const init = (
|
||||
fetch: Fetch,
|
||||
fetchImpl: Fetch,
|
||||
cookieManagerImpl: RNCookieManager | ToughCookieJar,
|
||||
options?: FetcherOptions
|
||||
): Api => {
|
||||
|
@ -21,7 +21,7 @@ const init = (
|
|||
const cookieManager = ((cookieManagerImpl as RNCookieManager).get)
|
||||
? wrapReactNativeCookieManager(cookieManagerImpl as RNCookieManager)
|
||||
: wrapToughCookie(cookieManagerImpl as ToughCookieJar)
|
||||
return new Api(fetch, cookieManager, options)
|
||||
return new Api(fetchImpl, cookieManager, options)
|
||||
}
|
||||
|
||||
export default init
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
"**/*.spec.tsx",
|
||||
"**/*.spec.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
"**/*.spec.tsx",
|
||||
"**/*.spec.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"presets": [
|
||||
[
|
||||
"@nrwl/react/babel",
|
||||
{
|
||||
"runtime": "automatic",
|
||||
"useBuiltIns": "usage"
|
||||
}
|
||||
]
|
||||
],
|
||||
"plugins": []
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
module.exports = function(api) {
|
||||
api.cache(true);
|
||||
const presets = [
|
||||
[
|
||||
'@nrwl/next/babel',
|
||||
{
|
||||
modules: 'auto',
|
||||
targets: {
|
||||
browsers: ['defaults']
|
||||
},
|
||||
}
|
||||
],
|
||||
"@nrwl/react/babel",
|
||||
];
|
||||
const plugins = [
|
||||
'@babel/plugin-transform-runtime',
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
["@babel/plugin-proposal-private-property-in-object", { "loose": false }],
|
||||
"@babel/plugin-transform-runtime",
|
||||
{
|
||||
"regenerator": true,
|
||||
"corejs": 3
|
||||
}
|
||||
];
|
||||
|
||||
return {
|
||||
presets,
|
||||
plugins
|
||||
};
|
||||
};
|
|
@ -6,7 +6,4 @@ module.exports = {
|
|||
},
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
||||
coverageDirectory: '../../coverage/libs/hooks',
|
||||
testEnvironment: 'jsdom',
|
||||
clearMocks: true,
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js']
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
import 'regenerator-runtime/runtime'
|
|
@ -19,5 +19,8 @@
|
|||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ const { default: init } = jest.requireActual(
|
|||
'@skolplattformen/api-skolplattformen'
|
||||
)
|
||||
|
||||
const wait = (ms) => new Promise((res) => setTimeout(res, ms))
|
||||
const wait = (ms: number) => new Promise((res) => setTimeout(res, ms))
|
||||
|
||||
describe('hooks with fake data', () => {
|
||||
let api
|
||||
let storage
|
||||
const wrapper = ({ children }) => (
|
||||
let api: any
|
||||
let storage: any
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
<ApiProvider api={api} storage={storage}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
|
@ -92,7 +92,7 @@ describe('hooks with fake data', () => {
|
|||
})
|
||||
})
|
||||
describe('data belonging to one child', () => {
|
||||
let child
|
||||
let child: any
|
||||
beforeEach(async () => {
|
||||
;[child] = await api.getChildren()
|
||||
})
|
||||
|
@ -178,7 +178,7 @@ describe('hooks with fake data', () => {
|
|||
})
|
||||
it('handles reloads', async () => {
|
||||
await act(async () => {
|
||||
store.dispatch({ type: 'CLEAR' })
|
||||
store.dispatch({ type: 'CLEAR' } as any) // fixes test for invalid type
|
||||
|
||||
const [child] = await api.getChildren()
|
||||
|
|
@ -10,6 +10,10 @@
|
|||
"**/*.spec.tsx",
|
||||
"**/*.spec.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
"@types/detox": "17.14.2",
|
||||
"@types/he": "^1.1.1",
|
||||
"@types/i18n-js": "^3.8.2",
|
||||
"@types/jest": "26.0.24",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/luxon": "^1.26.4",
|
||||
"@types/node": "14.14.33",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
|
|
|
@ -20,6 +20,5 @@
|
|||
"@skolplattformen/curriculum": ["libs/curriculum/src/index.ts"],
|
||||
"@skolplattformen/hooks": ["libs/hooks/src/index.ts"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "tmp"]
|
||||
}
|
||||
}
|
||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -2535,7 +2535,7 @@
|
|||
dependencies:
|
||||
"@types/istanbul-lib-report" "*"
|
||||
|
||||
"@types/jest@*", "@types/jest@26.0.24":
|
||||
"@types/jest@*":
|
||||
version "26.0.24"
|
||||
resolved "https://registry.npmjs.org/@types/jest/-/jest-26.0.24.tgz"
|
||||
integrity sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w==
|
||||
|
@ -2543,6 +2543,14 @@
|
|||
jest-diff "^26.0.0"
|
||||
pretty-format "^26.0.0"
|
||||
|
||||
"@types/jest@^27.0.2":
|
||||
version "27.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.2.tgz#ac383c4d4aaddd29bbf2b916d8d105c304a5fcd7"
|
||||
integrity sha512-4dRxkS/AFX0c5XW6IPMNOydLn2tEhNhJV7DnYK+0bjoJZ+QTmfucBlihX7aoEsh/ocYtkLC73UbnBXBXIxsULA==
|
||||
dependencies:
|
||||
jest-diff "^27.0.0"
|
||||
pretty-format "^27.0.0"
|
||||
|
||||
"@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7", "@types/json-schema@^7.0.8":
|
||||
version "7.0.9"
|
||||
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz"
|
||||
|
@ -8189,7 +8197,7 @@ jest-diff@^26.0.0:
|
|||
jest-get-type "^26.3.0"
|
||||
pretty-format "^26.6.2"
|
||||
|
||||
jest-diff@^27.2.5:
|
||||
jest-diff@^27.0.0, jest-diff@^27.2.5:
|
||||
version "27.2.5"
|
||||
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.2.5.tgz#908f7a6aca5653824516ad30e0a9fd9767e53623"
|
||||
integrity sha512-7gfwwyYkeslOOVQY4tVq5TaQa92mWfC9COsVYMNVYyJTOYAqbIkoD3twi5A+h+tAPtAelRxkqY6/xu+jwTr0dA==
|
||||
|
@ -11368,7 +11376,7 @@ pretty-format@^26.0.0, pretty-format@^26.0.1, pretty-format@^26.5.2, pretty-form
|
|||
ansi-styles "^4.0.0"
|
||||
react-is "^17.0.1"
|
||||
|
||||
pretty-format@^27.2.2, pretty-format@^27.2.5:
|
||||
pretty-format@^27.0.0, pretty-format@^27.2.2, pretty-format@^27.2.5:
|
||||
version "27.2.5"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.5.tgz#7cfe2a8e8f01a5b5b29296a0b70f4140df0830c5"
|
||||
integrity sha512-+nYn2z9GgicO9JiqmY25Xtq8SYfZ/5VCpEU3pppHHNAhd1y+ZXxmNPd1evmNcAd6Hz4iBV2kf0UpGth5A/VJ7g==
|
||||
|
|
Loading…
Reference in New Issue