fix: lint and prettier fixes
This commit is contained in:
parent
97b438069a
commit
169b5365e9
|
@ -2,6 +2,5 @@
|
|||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false
|
||||
"bracketSpacing": true
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
|
||||
"extends": [
|
||||
"@react-native-community",
|
||||
"plugin:react-native-a11y/all",
|
||||
"plugin:@nrwl/nx/react",
|
||||
"../../.eslintrc.json"
|
||||
],
|
||||
"ignorePatterns": ["!**/*", "public", ".cache", "node_modules"],
|
||||
"overrides": [
|
||||
{
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false
|
||||
"bracketSameLine": false
|
||||
}
|
||||
|
|
|
@ -21,10 +21,7 @@ const reporter = __DEV__
|
|||
log: (message) => console.log(message),
|
||||
error: (error, label) => console.error(label, error),
|
||||
}
|
||||
: {
|
||||
log: () => {},
|
||||
error: () => {},
|
||||
}
|
||||
: undefined
|
||||
|
||||
if (__DEV__) {
|
||||
const DevMenu = require('react-native-dev-menu')
|
||||
|
|
|
@ -31,7 +31,9 @@ const setup = (customProps = {}) => {
|
|||
beforeAll(() => {
|
||||
// Hide errors from act
|
||||
// https://github.com/callstack/react-native-testing-library/issues/379
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {})
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {
|
||||
// noop
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
|
@ -44,7 +44,9 @@ const setup = (customProps = {}) => {
|
|||
beforeAll(() => {
|
||||
// Hide errors from state illegal state transition
|
||||
// Probably due to mock
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {})
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {
|
||||
// noop
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(jest.clearAllMocks)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { fireEvent } from '@testing-library/react-native'
|
||||
import React from 'react'
|
||||
import RNCalendarEvents from 'react-native-calendar-events'
|
||||
import Toast from 'react-native-simple-toast'
|
||||
import { render } from '../../utils/testHelpers'
|
||||
import { SaveToCalendar } from '../saveToCalendar.component'
|
||||
import Toast from 'react-native-simple-toast'
|
||||
|
||||
jest.mock('react-native-simple-toast', () => ({
|
||||
SHORT: 'short',
|
||||
|
@ -53,7 +53,9 @@ const setup = (customProps = {}) => {
|
|||
beforeAll(() => {
|
||||
// Hide errors from state illegal state transition
|
||||
// Probably due to mock
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {})
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {
|
||||
// noop
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(jest.clearAllMocks)
|
||||
|
|
|
@ -38,7 +38,9 @@ type ChildListItemNavigationProp = StackNavigationProp<
|
|||
|
||||
export const ChildListItem = ({ child, color }: ChildListItemProps) => {
|
||||
// Forces rerender when child.id changes
|
||||
React.useEffect(() => {}, [child.id])
|
||||
React.useEffect(() => {
|
||||
// noop
|
||||
}, [child.id])
|
||||
|
||||
const navigation = useNavigation<ChildListItemNavigationProp>()
|
||||
const { t } = useTranslation()
|
||||
|
|
|
@ -19,7 +19,7 @@ export const Notification = ({ item }: NotificationProps) => {
|
|||
const date = item.dateModified || item.dateCreated
|
||||
const displayDate = date ? moment(date).fromNow() : null
|
||||
|
||||
const sharedCookiesEnabled: boolean = Boolean(
|
||||
const sharedCookiesEnabled = Boolean(
|
||||
item.url && item.url.startsWith('https://start.unikum.net/')
|
||||
)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export const SaveToCalendar = ({ event }: SaveToCalendarProps) => {
|
|||
const toast = (text: string) =>
|
||||
Toast.showWithGravity(text, Toast.SHORT, Toast.BOTTOM)
|
||||
|
||||
function removeEmptyValues<T extends object>(obj: T) {
|
||||
function removeEmptyValues<T extends Record<string, unknown>>(obj: T) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).filter(([_, v]) => v != null)
|
||||
) as { [K in keyof T]: any }
|
||||
|
|
|
@ -12,7 +12,9 @@ export default function useAsyncStorage<T>(
|
|||
if (!storageKey) return
|
||||
await AsyncStorage.setItem(storageKey, JSON.stringify(value))
|
||||
setStorageItem(value)
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -20,7 +22,9 @@ export default function useAsyncStorage<T>(
|
|||
try {
|
||||
const data = await AsyncStorage.getItem(storageKey)
|
||||
if (typeof data === 'string') setStorageItem(JSON.parse(data))
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
getStoredValue()
|
||||
|
|
|
@ -10,4 +10,4 @@ module.exports = {
|
|||
'react-native/jest/assetFileTransformer.js'
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ const rtlList: { [key: string]: boolean } = {
|
|||
}
|
||||
|
||||
export const isRTL = (langCode: string) => {
|
||||
if (!rtlList.hasOwnProperty(langCode)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(rtlList, langCode)) {
|
||||
return false
|
||||
}
|
||||
return rtlList[langCode]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import '@testing-library/jest-native/extend-expect';
|
||||
import moment from 'moment';
|
||||
import 'moment/locale/sv';
|
||||
import 'react-native-gesture-handler/jestSetup';
|
||||
import '@testing-library/jest-native/extend-expect'
|
||||
import moment from 'moment'
|
||||
import 'moment/locale/sv'
|
||||
import 'react-native-gesture-handler/jestSetup'
|
||||
|
||||
moment.locale('sv')
|
||||
|
||||
|
@ -9,12 +9,14 @@ moment.locale('sv')
|
|||
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
|
||||
|
||||
jest.mock('react-native-reanimated', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Reanimated = require('react-native-reanimated/mock')
|
||||
|
||||
// The mock for `call` immediately calls the callback which is incorrect
|
||||
// So we override it with a no-op
|
||||
Reanimated.default.call = () => {}
|
||||
Reanimated.default.call = () => {
|
||||
// noop
|
||||
}
|
||||
|
||||
return Reanimated
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { translate, translations } from '../translation'
|
|||
|
||||
describe('translation in swedish', () => {
|
||||
beforeAll(() => {
|
||||
i18n.translations = { ['sv']: translations.sv }
|
||||
i18n.translations = { sv: translations.sv }
|
||||
i18n.locale = 'sv'
|
||||
})
|
||||
it('should be able to translate the word settings', () => {
|
||||
|
@ -13,7 +13,7 @@ describe('translation in swedish', () => {
|
|||
|
||||
describe('translation in english', () => {
|
||||
beforeAll(() => {
|
||||
i18n.translations = { ['en']: translations.en }
|
||||
i18n.translations = { en: translations.en }
|
||||
i18n.locale = 'en'
|
||||
})
|
||||
it('should be able to translate the word settings', () => {
|
||||
|
|
|
@ -7,6 +7,7 @@ import { useChild } from '../components/childContext.component'
|
|||
import { Typography } from '../styles'
|
||||
|
||||
// https://github.com/facebook/react-native/issues/14796#issuecomment-389743259
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
global.Buffer = global.Buffer || require('buffer').Buffer
|
||||
|
||||
const NUM_CHARS_AROUND_SEARCH_MATCH = 20
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false
|
||||
"bracketSameLine": false
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false
|
||||
"bracketSameLine": false
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ const HttpProxyAgent = require('https-proxy-agent')
|
|||
const agentWrapper = require('./agentFetchWrapper')
|
||||
const init = require('./dist').default
|
||||
|
||||
|
||||
const [, , personalNumber] = process.argv
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
const cookieJar = new CookieJar()
|
||||
|
@ -68,7 +67,11 @@ async function run() {
|
|||
*/
|
||||
try {
|
||||
console.log('schedule')
|
||||
const schedule = await api.getSchedule(children[1], DateTime.local(), DateTime.local().plus({ week: 1 }))
|
||||
const schedule = await api.getSchedule(
|
||||
children[1],
|
||||
DateTime.local(),
|
||||
DateTime.local().plus({ week: 1 })
|
||||
)
|
||||
console.log(schedule)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
@ -84,7 +87,12 @@ async function run() {
|
|||
|
||||
try {
|
||||
console.log('timetable')
|
||||
const timetable = await api.getTimetable(skola24children[0], 15, 2021, "sv")
|
||||
const timetable = await api.getTimetable(
|
||||
skola24children[0],
|
||||
15,
|
||||
2021,
|
||||
'sv'
|
||||
)
|
||||
console.log(inspect(timetable, false, 1000, true))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
@ -216,7 +224,9 @@ const record = async (info, data) => {
|
|||
}
|
||||
|
||||
// Hack to keep it running while wating for await
|
||||
const timer = setTimeout(() => {}, 999999)
|
||||
const timer = setTimeout(() => {
|
||||
// noop
|
||||
}, 999999)
|
||||
|
||||
run()
|
||||
.then(() => {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
/* eslint-disable max-len */
|
||||
/* eslint-disable no-plusplus */
|
||||
export class URLSearchParams {
|
||||
|
||||
private dict: { [key: string]: string[] } = {}
|
||||
|
||||
constructor(search: string | string[] | any | URLSearchParams = '') {
|
||||
|
@ -80,11 +79,15 @@ export class URLSearchParams {
|
|||
if (Array.isArray(item) && item.length === 2) {
|
||||
this.appendTo(dict, item[0], item[1])
|
||||
} else {
|
||||
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initalizer must only contain pair elements")
|
||||
throw new TypeError(
|
||||
"Failed to construct 'URLSearchParams': Sequence initalizer must only contain pair elements"
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Object.entries(search).forEach(([key, value]) => this.appendTo(dict, key, value))
|
||||
Object.entries(search).forEach(([key, value]) =>
|
||||
this.appendTo(dict, key, value)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// remove 1st ?
|
||||
|
@ -97,7 +100,11 @@ export class URLSearchParams {
|
|||
const value = pairs[j]
|
||||
const index = value.indexOf('=')
|
||||
if (index > -1) {
|
||||
this.appendTo(dict, this.decode(value.slice(0, index)), this.decode(value.slice(index+1)))
|
||||
this.appendTo(
|
||||
dict,
|
||||
this.decode(value.slice(0, index)),
|
||||
this.decode(value.slice(index + 1))
|
||||
)
|
||||
} else if (value) {
|
||||
this.appendTo(dict, this.decode(value), '')
|
||||
}
|
||||
|
@ -107,11 +114,16 @@ export class URLSearchParams {
|
|||
return dict
|
||||
}
|
||||
|
||||
appendTo(dict: any, name: string, value: string | Function | any): void {
|
||||
appendTo(dict: any, name: string, value: string | (() => void) | any): void {
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const val = typeof value === 'string' ? value: (
|
||||
value !== null && value !== undefined && typeof value.toString === 'function' ? value.toString() : JSON.stringify(value)
|
||||
)
|
||||
const val =
|
||||
typeof value === 'string'
|
||||
? value
|
||||
: value !== null &&
|
||||
value !== undefined &&
|
||||
typeof value.toString === 'function'
|
||||
? value.toString()
|
||||
: JSON.stringify(value)
|
||||
|
||||
if (name in dict) {
|
||||
dict[name].push(value)
|
||||
|
@ -123,7 +135,7 @@ export class URLSearchParams {
|
|||
decode(str: string): string {
|
||||
return str
|
||||
.replace(/[ +]/g, '%20')
|
||||
.replace(/(%[a-f0-9]{2})+/ig, (match) => decodeURIComponent(match))
|
||||
.replace(/(%[a-f0-9]{2})+/gi, (match) => decodeURIComponent(match))
|
||||
}
|
||||
|
||||
encode(str: string[]): string {
|
||||
|
@ -134,9 +146,12 @@ export class URLSearchParams {
|
|||
')': '%29',
|
||||
'~': '%7E',
|
||||
'%20': '+',
|
||||
'%00': '\x00'
|
||||
'%00': '\x00',
|
||||
}
|
||||
return encodeURIComponent(str.join(',')).replace(
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return encodeURIComponent(str.join(',')).replace(/[!'\(\)~]|%20|%00/g, (match) => replace[match] || '')
|
||||
/[!'\(\)~]|%20|%00/g,
|
||||
(match) => replace[match] || ''
|
||||
)
|
||||
}
|
||||
}
|
|
@ -57,9 +57,9 @@ export class Api extends EventEmitter {
|
|||
|
||||
private cookieManager: CookieManager
|
||||
|
||||
public isLoggedIn: boolean = false
|
||||
public isLoggedIn = false
|
||||
|
||||
public isFake: boolean = false
|
||||
public isFake = false
|
||||
|
||||
private authorizedSystems: SSOSystems = {}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import wrap, { CallInfo, Fetcher, Recorder } from './fetcher'
|
||||
import { Fetch, Headers, Response } from './types'
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Blob = require('node-blob')
|
||||
Blob.prototype.arrayBuffer = async function () {
|
||||
return this.buffer.buffer
|
||||
|
|
|
@ -28,7 +28,7 @@ class Checker extends EventEmitter {
|
|||
|
||||
private url: string
|
||||
|
||||
private cancelled: boolean = false
|
||||
private cancelled = false
|
||||
|
||||
constructor(fetcher: Fetcher, ticket: AuthTicket) {
|
||||
super()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const camel = require('camelcase-keys')
|
||||
import camel from 'camelcase-keys'
|
||||
|
||||
export interface EtjanstResponse {
|
||||
Success: boolean
|
||||
|
|
|
@ -62,11 +62,12 @@ const record = async (info, data) => {
|
|||
case 'text':
|
||||
content.text = data
|
||||
break
|
||||
case 'blob':
|
||||
case 'blob': {
|
||||
const buffer = await data.arrayBuffer()
|
||||
content.blob = Buffer.from(buffer).toString('base64')
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (info.error) {
|
||||
const { message, stack } = info.error
|
||||
content.error = {
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"semi": false,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false
|
||||
"bracketSameLine": false
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{
|
||||
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
|
||||
"extends": [
|
||||
"@react-native-community",
|
||||
"plugin:react-native-a11y/all",
|
||||
"plugin:@nrwl/nx/react",
|
||||
"../../.eslintrc.json"
|
||||
],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
|
|
|
@ -14,9 +14,14 @@ export default (init = {}, delay = 0) => {
|
|||
cache[key] = val
|
||||
}
|
||||
const clear = () => {
|
||||
Object.keys(cache).forEach((key) => { cache[key] = undefined })
|
||||
Object.keys(cache).forEach((key) => {
|
||||
cache[key] = undefined
|
||||
})
|
||||
}
|
||||
return {
|
||||
getItem, setItem, cache, clear,
|
||||
getItem,
|
||||
setItem,
|
||||
cache,
|
||||
clear,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {
|
||||
EntityAction, EntityName, ExtraActionProps,
|
||||
} from './types'
|
||||
import { EntityAction, EntityName, ExtraActionProps } from './types'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const loadAction = <T>(entity: EntityName, extra: ExtraActionProps<T>): EntityAction<T> => ({
|
||||
export const loadAction = <T>(
|
||||
entity: EntityName,
|
||||
extra: ExtraActionProps<T>
|
||||
): EntityAction<T> => ({
|
||||
entity,
|
||||
extra,
|
||||
type: 'GET_FROM_API',
|
||||
|
|
|
@ -26,8 +26,16 @@ describe('childlists', () => {
|
|||
]
|
||||
|
||||
const children = [
|
||||
{ name: 'Uwe Übrink (elev)', firstName: 'Uwe', lastName: 'Vredstein Übrink' },
|
||||
{ name: 'Cassius Übrink (elev)', firstName: 'Cassius', lastName: 'Vredstein Übrink' },
|
||||
{
|
||||
name: 'Uwe Übrink (elev)',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
},
|
||||
{
|
||||
name: 'Cassius Übrink (elev)',
|
||||
firstName: 'Cassius',
|
||||
lastName: 'Vredstein Übrink',
|
||||
},
|
||||
]
|
||||
expect(merge(etjanstChildren, skola24Children)).toEqual(children)
|
||||
})
|
||||
|
@ -41,7 +49,11 @@ describe('childlists', () => {
|
|||
]
|
||||
|
||||
const children = [
|
||||
{ name: 'Uwe Übrink (elev)', firstName: 'Uwe', lastName: 'Vredstein Übrink' },
|
||||
{
|
||||
name: 'Uwe Übrink (elev)',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
},
|
||||
{ name: 'Cassius Übrink (elev)' },
|
||||
]
|
||||
expect(merge(etjanstChildren, skola24Children)).toEqual(children)
|
||||
|
@ -57,7 +69,11 @@ describe('childlists', () => {
|
|||
]
|
||||
|
||||
const children = [
|
||||
{ name: 'Uwe Übrink (elev)', firstName: 'Uwe', lastName: 'Vredstein Übrink' },
|
||||
{
|
||||
name: 'Uwe Übrink (elev)',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
},
|
||||
{ name: 'Cassius Übrink (elev)' },
|
||||
]
|
||||
expect(merge(etjanstChildren, skola24Children)).toEqual(children)
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
Skola24Child,
|
||||
} from '@skolplattformen/api-skolplattformen'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const merge = (
|
||||
etjanstChildren: EtjanstChild[],
|
||||
skola24Children: Skola24Child[]
|
||||
|
|
|
@ -23,7 +23,9 @@ describe('useApi()', () => {
|
|||
expect(result.current.isLoggedIn).toBe(false)
|
||||
})
|
||||
it('updates isLoggedIn', async () => {
|
||||
const { result, waitForValueToChange } = renderHook(() => useApi(), { wrapper })
|
||||
const { result, waitForValueToChange } = renderHook(() => useApi(), {
|
||||
wrapper,
|
||||
})
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.emitter.emit('login')
|
||||
|
@ -33,7 +35,9 @@ describe('useApi()', () => {
|
|||
expect(result.current.isLoggedIn).toBe(true)
|
||||
})
|
||||
it('updates isFake', async () => {
|
||||
const { result, waitForValueToChange } = renderHook(() => useApi(), { wrapper })
|
||||
const { result, waitForValueToChange } = renderHook(() => useApi(), {
|
||||
wrapper,
|
||||
})
|
||||
await act(async () => {
|
||||
api.isFake = true
|
||||
api.emitter.emit('login')
|
||||
|
|
|
@ -30,8 +30,12 @@ describe('hooks with fake data', () => {
|
|||
)
|
||||
beforeEach(async () => {
|
||||
api = init(
|
||||
() => {},
|
||||
() => {}
|
||||
() => {
|
||||
// noop
|
||||
},
|
||||
() => {
|
||||
//noop
|
||||
}
|
||||
)
|
||||
await api.login('121212121212')
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import {
|
||||
Api,
|
||||
CalendarItem,
|
||||
|
|
|
@ -14,11 +14,7 @@ describe('logout - cleanup', () => {
|
|||
let storage
|
||||
let response
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -26,14 +22,18 @@ describe('logout - cleanup', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getChildren.mockImplementation(() => (
|
||||
api.getChildren.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_etjanst_children': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
})
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
|
@ -46,7 +46,10 @@ describe('logout - cleanup', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate: wait1 } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate: wait1 } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await wait1()
|
||||
await wait1()
|
||||
|
@ -63,7 +66,10 @@ describe('logout - cleanup', () => {
|
|||
api.isLoggedIn = true
|
||||
api.emitter.emit('login')
|
||||
|
||||
const { result: result2, waitForNextUpdate: wait2 } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result: result2, waitForNextUpdate: wait2 } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await wait2()
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
import { Middleware } from 'redux'
|
||||
import { EntityAction, EntityStoreRootState, ExtraActionProps } from './types'
|
||||
|
||||
type IMiddleware = Middleware<{}, EntityStoreRootState>
|
||||
export const apiMiddleware: IMiddleware = (storeApi) => (next) => (action: EntityAction<any>) => {
|
||||
type IMiddleware = Middleware<Record<string, unknown>, EntityStoreRootState>
|
||||
export const apiMiddleware: IMiddleware =
|
||||
(storeApi) => (next) => (action: EntityAction<any>) => {
|
||||
try {
|
||||
switch (action.type) {
|
||||
case 'GET_FROM_API': {
|
||||
|
@ -76,7 +77,8 @@ export const apiMiddleware: IMiddleware = (storeApi) => (next) => (action: Entit
|
|||
return next(action)
|
||||
}
|
||||
|
||||
export const cacheMiddleware: IMiddleware = (storeApi) => (next) => (action: EntityAction<any>) => {
|
||||
export const cacheMiddleware: IMiddleware =
|
||||
(storeApi) => (next) => (action: EntityAction<any>) => {
|
||||
try {
|
||||
switch (action.type) {
|
||||
case 'GET_FROM_CACHE': {
|
||||
|
|
|
@ -18,7 +18,11 @@ describe('ApiProvider', () => {
|
|||
api = init()
|
||||
})
|
||||
it('enables useApi()', () => {
|
||||
const { getByTestId } = render(<ApiProvider api={api}><Login /></ApiProvider>)
|
||||
const { getByTestId } = render(
|
||||
<ApiProvider api={api}>
|
||||
<Login />
|
||||
</ApiProvider>
|
||||
)
|
||||
|
||||
expect(getByTestId('isLoggedIn').textContent).toEqual('n')
|
||||
})
|
||||
|
|
|
@ -15,8 +15,12 @@ type TApiProvider = FC<
|
|||
}>
|
||||
>
|
||||
const noopReporter: Reporter = {
|
||||
log: () => {},
|
||||
error: () => {},
|
||||
log: () => {
|
||||
// noop
|
||||
},
|
||||
error: () => {
|
||||
// noop
|
||||
},
|
||||
}
|
||||
export const ApiProvider: TApiProvider = ({
|
||||
children,
|
||||
|
|
|
@ -15,11 +15,7 @@ describe('useCalendar(child)', () => {
|
|||
let response
|
||||
let child
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -27,14 +23,18 @@ describe('useCalendar(child)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getCalendar.mockImplementation(() => (
|
||||
api.getCalendar.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_calendar_10': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
})
|
||||
afterEach(async () => {
|
||||
|
@ -51,7 +51,9 @@ describe('useCalendar(child)', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -63,7 +65,9 @@ describe('useCalendar(child)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useCalendar(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useCalendar(child), { wrapper })
|
||||
|
@ -80,7 +84,10 @@ describe('useCalendar(child)', () => {
|
|||
it('retrieves data from cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -92,7 +99,10 @@ describe('useCalendar(child)', () => {
|
|||
storage.clear()
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -103,7 +113,10 @@ describe('useCalendar(child)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -114,7 +127,10 @@ describe('useCalendar(child)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -128,7 +144,9 @@ describe('useCalendar(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -143,7 +161,9 @@ describe('useCalendar(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -158,7 +178,10 @@ describe('useCalendar(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -186,7 +209,10 @@ describe('useCalendar(child)', () => {
|
|||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -213,7 +239,10 @@ describe('useCalendar(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useCalendar(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useCalendar(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -221,7 +250,10 @@ describe('useCalendar(child)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting CALENDAR from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting CALENDAR from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -18,38 +18,43 @@ describe('useChildList()', () => {
|
|||
let echildrenResponse
|
||||
let skola24Response
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
beforeEach(() => {
|
||||
echildrenCache = [{ id: 2, name: 'Uwe Übrink (elev)' }]
|
||||
skola24Cache = [{ personGuid: '2', firstName: 'Uwe', lastName: 'Vredstein Übrink' }]
|
||||
skola24Cache = [
|
||||
{ personGuid: '2', firstName: 'Uwe', lastName: 'Vredstein Übrink' },
|
||||
]
|
||||
|
||||
echildrenResponse = [{ id: 1, name: 'Uwe Übrink (elev)' }]
|
||||
skola24Response = [{ personGuid: '1', firstName: 'Uwe', lastName: 'Vredstein Übrink' }]
|
||||
skola24Response = [
|
||||
{ personGuid: '1', firstName: 'Uwe', lastName: 'Vredstein Übrink' },
|
||||
]
|
||||
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
|
||||
api.getChildren.mockImplementation(() => (
|
||||
api.getChildren.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(echildrenResponse), 50)
|
||||
})
|
||||
))
|
||||
api.getSkola24Children.mockImplementation(() => (
|
||||
)
|
||||
api.getSkola24Children.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(skola24Response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_etjanst_children': echildrenCache,
|
||||
'123_skola24_children': skola24Cache,
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
})
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
|
@ -65,7 +70,9 @@ describe('useChildList()', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -78,7 +85,9 @@ describe('useChildList()', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useChildList(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useChildList(), { wrapper })
|
||||
|
@ -97,7 +106,9 @@ describe('useChildList()', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -105,19 +116,23 @@ describe('useChildList()', () => {
|
|||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
||||
expect(result.current.data).toEqual([{
|
||||
expect(result.current.data).toEqual([
|
||||
{
|
||||
id: 2,
|
||||
name: 'Uwe Übrink (elev)',
|
||||
personGuid: '2',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
}])
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -128,7 +143,9 @@ describe('useChildList()', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -145,7 +162,9 @@ describe('useChildList()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -155,8 +174,12 @@ describe('useChildList()', () => {
|
|||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(JSON.stringify(echildrenResponse))
|
||||
expect(storage.cache['123_skola24_children']).toEqual(JSON.stringify(skola24Response))
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(
|
||||
JSON.stringify(echildrenResponse)
|
||||
)
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
JSON.stringify(skola24Response)
|
||||
)
|
||||
})
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
|
@ -164,7 +187,9 @@ describe('useChildList()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -172,8 +197,12 @@ describe('useChildList()', () => {
|
|||
await pause(20)
|
||||
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(JSON.stringify(echildrenCache))
|
||||
expect(storage.cache['123_skola24_children']).toEqual(JSON.stringify(skola24Cache))
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(
|
||||
JSON.stringify(echildrenCache)
|
||||
)
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
JSON.stringify(skola24Cache)
|
||||
)
|
||||
})
|
||||
})
|
||||
it('retries if etjanst-api fails', async () => {
|
||||
|
@ -182,7 +211,9 @@ describe('useChildList()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -202,13 +233,15 @@ describe('useChildList()', () => {
|
|||
await waitForNextUpdate()
|
||||
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{
|
||||
expect(result.current.data).toEqual([
|
||||
{
|
||||
id: 1,
|
||||
name: 'Uwe Übrink (elev)',
|
||||
personGuid: '1',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
}])
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
|
@ -219,7 +252,9 @@ describe('useChildList()', () => {
|
|||
api.getChildren.mockRejectedValueOnce(error)
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -240,13 +275,15 @@ describe('useChildList()', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{
|
||||
expect(result.current.data).toEqual([
|
||||
{
|
||||
id: 2,
|
||||
name: 'Uwe Übrink (elev)',
|
||||
personGuid: '1',
|
||||
firstName: 'Uwe',
|
||||
lastName: 'Vredstein Übrink',
|
||||
}])
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
|
@ -255,7 +292,9 @@ describe('useChildList()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -263,7 +302,10 @@ describe('useChildList()', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting ETJANST_CHILDREN from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting ETJANST_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,11 +15,7 @@ describe('useClassmates(child)', () => {
|
|||
let response
|
||||
let child
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -27,14 +23,18 @@ describe('useClassmates(child)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getClassmates.mockImplementation(() => (
|
||||
api.getClassmates.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_classmates_10': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
})
|
||||
afterEach(async () => {
|
||||
|
@ -51,7 +51,9 @@ describe('useClassmates(child)', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -63,7 +65,9 @@ describe('useClassmates(child)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useClassmates(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useClassmates(child), { wrapper })
|
||||
|
@ -80,7 +84,10 @@ describe('useClassmates(child)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -91,7 +98,10 @@ describe('useClassmates(child)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -102,7 +112,10 @@ describe('useClassmates(child)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -116,7 +129,9 @@ describe('useClassmates(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -131,7 +146,9 @@ describe('useClassmates(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -146,7 +163,10 @@ describe('useClassmates(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -174,7 +194,10 @@ describe('useClassmates(child)', () => {
|
|||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -201,7 +224,10 @@ describe('useClassmates(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useClassmates(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useClassmates(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -209,7 +235,10 @@ describe('useClassmates(child)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting CLASSMATES from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting CLASSMATES from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -14,11 +14,7 @@ describe('useEtjanstChildren()', () => {
|
|||
let storage
|
||||
let response
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -26,14 +22,18 @@ describe('useEtjanstChildren()', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getChildren.mockImplementation(() => (
|
||||
api.getChildren.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_etjanst_children': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
})
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
|
@ -49,7 +49,9 @@ describe('useEtjanstChildren()', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -61,7 +63,9 @@ describe('useEtjanstChildren()', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
@ -78,7 +82,10 @@ describe('useEtjanstChildren()', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -89,7 +96,10 @@ describe('useEtjanstChildren()', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -100,7 +110,10 @@ describe('useEtjanstChildren()', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -114,7 +127,9 @@ describe('useEtjanstChildren()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -129,7 +144,9 @@ describe('useEtjanstChildren()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -144,7 +161,10 @@ describe('useEtjanstChildren()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -172,7 +192,10 @@ describe('useEtjanstChildren()', () => {
|
|||
api.getChildren.mockRejectedValueOnce(error)
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -199,7 +222,10 @@ describe('useEtjanstChildren()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useEtjanstChildren(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -207,7 +233,10 @@ describe('useEtjanstChildren()', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting ETJANST_CHILDREN from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting ETJANST_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,11 +15,7 @@ describe('useMenu(child)', () => {
|
|||
let response
|
||||
let child
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -27,14 +23,18 @@ describe('useMenu(child)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getMenu.mockImplementation(() => (
|
||||
api.getMenu.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_menu_10': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
})
|
||||
afterEach(async () => {
|
||||
|
@ -51,7 +51,9 @@ describe('useMenu(child)', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -63,7 +65,9 @@ describe('useMenu(child)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useMenu(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useMenu(child), { wrapper })
|
||||
|
@ -80,7 +84,9 @@ describe('useMenu(child)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -91,7 +97,9 @@ describe('useMenu(child)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -102,7 +110,9 @@ describe('useMenu(child)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -116,7 +126,9 @@ describe('useMenu(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -131,7 +143,9 @@ describe('useMenu(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -146,7 +160,9 @@ describe('useMenu(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -174,7 +190,9 @@ describe('useMenu(child)', () => {
|
|||
api.getMenu.mockRejectedValueOnce(error)
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -201,7 +219,9 @@ describe('useMenu(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -209,7 +229,10 @@ describe('useMenu(child)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting MENU from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting MENU from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,11 +15,7 @@ describe('useNews(child)', () => {
|
|||
let response
|
||||
let child
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -27,14 +23,18 @@ describe('useNews(child)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getNews.mockImplementation(() => (
|
||||
api.getNews.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_news_10': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
})
|
||||
afterEach(async () => {
|
||||
|
@ -51,7 +51,9 @@ describe('useNews(child)', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -63,7 +65,9 @@ describe('useNews(child)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNews(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useNews(child), { wrapper })
|
||||
|
@ -80,7 +84,9 @@ describe('useNews(child)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -91,7 +97,9 @@ describe('useNews(child)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -102,7 +110,9 @@ describe('useNews(child)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -116,7 +126,9 @@ describe('useNews(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -131,7 +143,9 @@ describe('useNews(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -146,7 +160,9 @@ describe('useNews(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -174,7 +190,9 @@ describe('useNews(child)', () => {
|
|||
api.getNews.mockRejectedValueOnce(error)
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -201,7 +219,9 @@ describe('useNews(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -209,7 +229,10 @@ describe('useNews(child)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting NEWS from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting NEWS from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -17,11 +17,7 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
let child
|
||||
let newsItem
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -30,14 +26,18 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
response = { id: '1337', modified: 'now', body: 'rich and new' }
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getNewsDetails.mockImplementation(() => (
|
||||
api.getNewsDetails.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_news_details_1337': { ...cached },
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
newsItem = { id: '1337', modified: 'now', body: 'simple' }
|
||||
})
|
||||
|
@ -48,14 +48,19 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
})
|
||||
})
|
||||
it('returns correct initial value', () => {
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -67,7 +72,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
|
@ -75,7 +83,9 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
await waitForNextUpdate()
|
||||
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
expect(api.getNewsDetails).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
|
@ -84,7 +94,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -95,7 +108,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -106,7 +122,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -120,14 +139,19 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(JSON.stringify(response))
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(
|
||||
JSON.stringify(response)
|
||||
)
|
||||
})
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
|
@ -135,13 +159,18 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(JSON.stringify(cached))
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(
|
||||
JSON.stringify(cached)
|
||||
)
|
||||
})
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
|
@ -150,7 +179,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -178,7 +210,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -205,7 +240,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNewsDetails(child, newsItem),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -213,7 +251,10 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting NEWS_DETAILS from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting NEWS_DETAILS from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,11 +15,7 @@ describe('useNotifications(child)', () => {
|
|||
let response
|
||||
let child
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -27,14 +23,18 @@ describe('useNotifications(child)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getNotifications.mockImplementation(() => (
|
||||
api.getNotifications.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_notifications_10': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
})
|
||||
afterEach(async () => {
|
||||
|
@ -51,7 +51,9 @@ describe('useNotifications(child)', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -63,7 +65,9 @@ describe('useNotifications(child)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNotifications(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useNotifications(child), { wrapper })
|
||||
|
@ -80,7 +84,10 @@ describe('useNotifications(child)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -91,7 +98,10 @@ describe('useNotifications(child)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -102,7 +112,10 @@ describe('useNotifications(child)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -116,7 +129,9 @@ describe('useNotifications(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -131,7 +146,9 @@ describe('useNotifications(child)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -146,7 +163,10 @@ describe('useNotifications(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -174,7 +194,10 @@ describe('useNotifications(child)', () => {
|
|||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -201,7 +224,10 @@ describe('useNotifications(child)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNotifications(child), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useNotifications(child),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -209,7 +235,10 @@ describe('useNotifications(child)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting NOTIFICATIONS from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting NOTIFICATIONS from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -17,11 +17,7 @@ describe('useSchedule(child, from, to)', () => {
|
|||
let from
|
||||
let to
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -29,14 +25,18 @@ describe('useSchedule(child, from, to)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getSchedule.mockImplementation(() => (
|
||||
api.getSchedule.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_schedule_10_2021-01-01_2021-01-08': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { id: 10 }
|
||||
from = '2021-01-01'
|
||||
to = '2021-01-08'
|
||||
|
@ -48,14 +48,19 @@ describe('useSchedule(child, from, to)', () => {
|
|||
})
|
||||
})
|
||||
it('returns correct initial value', () => {
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -67,7 +72,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
|
@ -75,7 +83,9 @@ describe('useSchedule(child, from, to)', () => {
|
|||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
await waitForNextUpdate()
|
||||
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
expect(api.getSchedule).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
|
@ -84,7 +94,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -95,7 +108,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -106,7 +122,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -120,14 +139,19 @@ describe('useSchedule(child, from, to)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual('[{"id":1}]')
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual(
|
||||
'[{"id":1}]'
|
||||
)
|
||||
})
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
|
@ -135,13 +159,18 @@ describe('useSchedule(child, from, to)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual('[{"id":2}]')
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual(
|
||||
'[{"id":2}]'
|
||||
)
|
||||
})
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
|
@ -150,7 +179,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -178,7 +210,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -205,7 +240,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -213,7 +251,10 @@ describe('useSchedule(child, from, to)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting SCHEDULE from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting SCHEDULE from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -14,11 +14,7 @@ describe('useSkola24Children()', () => {
|
|||
let storage
|
||||
let response
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -26,14 +22,18 @@ describe('useSkola24Children()', () => {
|
|||
response = [{ personGuid: '1' }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getSkola24Children.mockImplementation(() => (
|
||||
api.getSkola24Children.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_skola24_children': [{ personGuid: '2' }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
})
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
|
@ -49,7 +49,9 @@ describe('useSkola24Children()', () => {
|
|||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -61,7 +63,9 @@ describe('useSkola24Children()', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useSkola24Children(), { wrapper })
|
||||
|
@ -78,7 +82,10 @@ describe('useSkola24Children()', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -89,7 +96,10 @@ describe('useSkola24Children()', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -100,7 +110,10 @@ describe('useSkola24Children()', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -114,14 +127,18 @@ describe('useSkola24Children()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_skola24_children']).toEqual('[{"personGuid":"1"}]')
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
'[{"personGuid":"1"}]'
|
||||
)
|
||||
})
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
|
@ -129,13 +146,17 @@ describe('useSkola24Children()', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
await pause(20)
|
||||
|
||||
expect(storage.cache['123_skola24_children']).toEqual('[{"personGuid":"2"}]')
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
'[{"personGuid":"2"}]'
|
||||
)
|
||||
})
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
|
@ -144,7 +165,10 @@ describe('useSkola24Children()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -172,7 +196,10 @@ describe('useSkola24Children()', () => {
|
|||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -199,7 +226,10 @@ describe('useSkola24Children()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSkola24Children(),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -207,7 +237,10 @@ describe('useSkola24Children()', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting SKOLA24_CHILDREN from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting SKOLA24_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -18,11 +18,7 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
let year
|
||||
let lang
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -30,14 +26,18 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
response = [{ id: 1 }]
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getTimetable.mockImplementation(() => (
|
||||
api.getTimetable.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_timetable_10_15_2021_sv': [{ id: 2 }],
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
child = { personGuid: '10' }
|
||||
week = 15
|
||||
year = 2021
|
||||
|
@ -50,14 +50,19 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
})
|
||||
})
|
||||
it('returns correct initial value', () => {
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -69,7 +74,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
|
@ -77,7 +85,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
await waitForNextUpdate()
|
||||
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
expect(api.getTimetable).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
|
@ -86,7 +97,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -97,7 +111,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -108,7 +125,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -122,7 +142,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -137,7 +160,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
const { waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -152,7 +178,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -180,7 +209,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -207,7 +239,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
const error = new Error('fail')
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useTimetable(child, week, year, lang),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -215,7 +250,10 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting TIMETABLE from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting TIMETABLE from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -14,11 +14,7 @@ describe('useUser()', () => {
|
|||
let storage
|
||||
let response
|
||||
const wrapper = ({ children }) => (
|
||||
<ApiProvider
|
||||
api={api}
|
||||
storage={storage}
|
||||
reporter={reporter}
|
||||
>
|
||||
<ApiProvider api={api} storage={storage} reporter={reporter}>
|
||||
{children}
|
||||
</ApiProvider>
|
||||
)
|
||||
|
@ -26,14 +22,18 @@ describe('useUser()', () => {
|
|||
response = { id: 1 }
|
||||
api = init()
|
||||
api.getPersonalNumber.mockReturnValue('123')
|
||||
api.getUser.mockImplementation(() => (
|
||||
api.getUser.mockImplementation(
|
||||
() =>
|
||||
new Promise((res) => {
|
||||
setTimeout(() => res(response), 50)
|
||||
})
|
||||
))
|
||||
storage = createStorage({
|
||||
)
|
||||
storage = createStorage(
|
||||
{
|
||||
'123_user': { id: 2 },
|
||||
}, 2)
|
||||
},
|
||||
2
|
||||
)
|
||||
})
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
|
@ -78,7 +78,9 @@ describe('useUser()', () => {
|
|||
it('calls cache', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -89,7 +91,9 @@ describe('useUser()', () => {
|
|||
it('updates status to loading', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -100,7 +104,9 @@ describe('useUser()', () => {
|
|||
it('updates status to loaded', async () => {
|
||||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -144,7 +150,9 @@ describe('useUser()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -172,7 +180,9 @@ describe('useUser()', () => {
|
|||
api.getUser.mockRejectedValueOnce(error)
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -199,7 +209,9 @@ describe('useUser()', () => {
|
|||
const error = new Error('fail')
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
const { result, waitForNextUpdate } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitForNextUpdate()
|
||||
await waitForNextUpdate()
|
||||
|
@ -207,7 +219,10 @@ describe('useUser()', () => {
|
|||
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
expect(reporter.error).toHaveBeenCalledWith(error, 'Error getting USER from API')
|
||||
expect(reporter.error).toHaveBeenCalledWith(
|
||||
error,
|
||||
'Error getting USER from API'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
"@react-native-community/cli": "6.0.0",
|
||||
"@react-native-community/cli-platform-android": "6.0.0",
|
||||
"@react-native-community/cli-platform-ios": "6.0.0",
|
||||
"@react-native-community/eslint-config": "^3.0.1",
|
||||
"@testing-library/jest-dom": "5.14.1",
|
||||
"@testing-library/jest-native": "4.0.2",
|
||||
"@testing-library/react": "11.2.6",
|
||||
|
@ -91,6 +92,7 @@
|
|||
"@types/base-64": "^1.0.0",
|
||||
"@types/detox": "17.14.2",
|
||||
"@types/he": "^1.1.1",
|
||||
"@types/i18n-js": "^3.8.2",
|
||||
"@types/jest": "26.0.24",
|
||||
"@types/luxon": "^1.26.4",
|
||||
"@types/node": "14.14.33",
|
||||
|
@ -110,6 +112,7 @@
|
|||
"eslint-plugin-jsx-a11y": "6.4.1",
|
||||
"eslint-plugin-react": "7.23.1",
|
||||
"eslint-plugin-react-hooks": "4.2.0",
|
||||
"eslint-plugin-react-native-a11y": "^2.0.4",
|
||||
"fetch-cookie": "^0.11.0",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"jest": "27.0.3",
|
||||
|
|
|
@ -5,11 +5,10 @@
|
|||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"target": "es2015",
|
||||
"module": "esnext",
|
||||
"strict": true,
|
||||
"lib": ["es2017", "dom"],
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true,
|
||||
|
|
Loading…
Reference in New Issue