Compare commits
33 Commits
ae3a94e114
...
a1c922ef25
Author | SHA1 | Date |
---|---|---|
Lee | a1c922ef25 | |
Lee | 9601468251 | |
Lee | 0a9ad5a9ac | |
Lee | 3907ce242f | |
Lee | 9fbc02f024 | |
Lee | 468d21c531 | |
Lee | 1c8373ed58 | |
Lee | 8c23fdfc3b | |
Lee | 5b0eb65183 | |
Lee | 74f030003f | |
Lee | 86d3cacec6 | |
Lee | 1ad45e4ee6 | |
Lee | 042e6b358f | |
Lee | 8d970ecca4 | |
Lee | 815eabf1be | |
Lee | 9cf2c696a4 | |
Lee | d727ec1779 | |
Lee | ac1dcd2f5e | |
Lee | e7929005f1 | |
Lee | 4f5b6d3461 | |
Lee | be63e74da6 | |
Lee | 11352b1ce4 | |
Lee | 6793ca0be1 | |
Lee | 20ede022a9 | |
Lee | f389a4ae2c | |
Lee | 2173c07a07 | |
Lee | 19881a3de6 | |
Lee | d6fba4b7a7 | |
Lee | 40b2eaf2df | |
Lee | bad26e739a | |
Lee | 74291295f3 | |
Lee | 8a45b665dd | |
Lee | c40bf09bf8 |
|
@ -35,10 +35,6 @@ jobs:
|
|||
node-version: '18.13'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: ${{ github.workspace }}/apps/skolplattformen-app-new/package-lock.json
|
||||
- name: Set ENVFILE
|
||||
run: echo "$MAPS_API_KEY" > .env
|
||||
env:
|
||||
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
|
||||
- name: set npm version
|
||||
run: npm install -g npm@9.6.0 && echo "secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} secrets.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} workspace= ${{ github.workspace }} secrets.MAPS_API_KEY=${{secrets.MAPS_API_KEY}}"
|
||||
- name: install node modules
|
||||
|
@ -52,10 +48,10 @@ jobs:
|
|||
env:
|
||||
KEY_JSON: ${{ secrets.KEY_JSON }}
|
||||
- run: cd apps/skolplattformen-app-new/android && bundle exec fastlane android beta
|
||||
env:
|
||||
ENVFILE: .env
|
||||
# SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
||||
# ALIAS_KEY_PASSWORD: ${{ secrets.ALIAS_KEY_PASSWORD }}
|
||||
# env:
|
||||
# ENVFILE: .env
|
||||
# SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
||||
# ALIAS_KEY_PASSWORD: ${{ secrets.ALIAS_KEY_PASSWORD }}
|
||||
- name: 'Store artifact native_debug_symbols.zip'
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ failure() }}
|
||||
|
|
|
@ -73,9 +73,9 @@ android {
|
|||
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
||||
namespace "com.app"
|
||||
namespace "com.oppna_skolplattformen_new.app"
|
||||
defaultConfig {
|
||||
applicationId "com.app"
|
||||
applicationId "com.oppna_skolplattformen_new.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.oppna_skolplattformen_new.app">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# Filename: android/fastlane/Appfile
|
||||
|
||||
json_key_file("key.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
|
||||
package_name("com.projectname.app") # EDIT: The bundle identifier of your app
|
||||
package_name("com.oppna_skolplattformen_new.app") # EDIT: The bundle identifier of your app
|
||||
|
||||
|
||||
|
|
|
@ -11,11 +11,6 @@ platform :android do
|
|||
desc "Submit a new Beta Build to Play Store"
|
||||
lane :beta do |options|
|
||||
|
||||
if ENV['ENVFILE'].nil?
|
||||
puts "ENVFILE is not set. Please set ENVFILE to the path of your .env file. If unsure, look at .github/**/*android*yml"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
store_password = ENV['SIGNING_STORE_PASSWORD'] || prompt(text: "Signing Store Password: ", secure_text: true)
|
||||
key_password = ENV['ALIAS_KEY_PASSWORD'] || prompt(text: "Alias Key Password: ", secure_text: true)
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
plugins: [
|
||||
[
|
||||
'module-resolver',
|
||||
{
|
||||
root: ['./src/apps/skolplattformen-app-new/'],
|
||||
extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
|
||||
alias: {
|
||||
'@skolplattformen/api': ['libs/api/lib/index.ts'],
|
||||
'@skolplattformen/api-hjarntorget': [
|
||||
'libs/api-hjarntorget/lib/index.ts',
|
||||
],
|
||||
'@skolplattformen/api-skolplattformen': [
|
||||
'libs/api-skolplattformen/lib/index.ts',
|
||||
],
|
||||
'@skolplattformen/curriculum': ['libs/curriculum/src/index.ts'],
|
||||
'@skolplattformen/hooks': ['libs/hooks/src/index.ts'],
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'setImmediate'
|
||||
import { useNavigation } from '@react-navigation/core'
|
||||
import {
|
||||
useApi,
|
||||
|
@ -15,8 +16,6 @@ import * as RNLocalize from 'react-native-localize'
|
|||
import { render } from '../../utils/testHelpers'
|
||||
import { translate } from '../../utils/translation'
|
||||
import { Children } from '../children.component'
|
||||
import { setImmediate } from 'timers/promises'
|
||||
import { set } from 'mockdate'
|
||||
|
||||
jest.mock('../../libs/hooks/src')
|
||||
|
||||
|
@ -51,10 +50,8 @@ test('renders loading state', async () => {
|
|||
status: 'loading',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
expect(screen.getByText(translate('general.loading'))).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
expect(screen.getByText(translate('general.loading'))).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders empty state message', () => {
|
||||
|
@ -62,15 +59,12 @@ test('renders empty state message', () => {
|
|||
data: [],
|
||||
status: 'loaded',
|
||||
}))
|
||||
setImmediate(()=> {
|
||||
const screen = setup()
|
||||
|
||||
expect(
|
||||
screen.getByText(translate('children.noKids_description'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
test('renders error state message', () => {
|
||||
useChildList.mockImplementationOnce(() => ({
|
||||
|
@ -78,13 +72,11 @@ test('renders error state message', () => {
|
|||
status: 'error',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(
|
||||
screen.getByText(translate('children.loadingErrorHeading'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(
|
||||
screen.getByText(translate('children.loadingErrorHeading'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders child in preschool', () => {
|
||||
|
@ -98,11 +90,9 @@ test('renders child in preschool', () => {
|
|||
status: 'loaded',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders child in elementary school', () => {
|
||||
|
@ -116,11 +106,9 @@ test('renders child in elementary school', () => {
|
|||
status: 'loaded',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders child in high school', () => {
|
||||
|
@ -134,14 +122,12 @@ test('renders child in high school', () => {
|
|||
status: 'loaded',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.upperSecondarySchool'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.upperSecondarySchool'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders multiple children', () => {
|
||||
|
@ -159,19 +145,17 @@ test('renders multiple children', () => {
|
|||
status: 'loaded',
|
||||
}))
|
||||
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Storasyster Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.upperSecondarySchool'))
|
||||
).toBeTruthy()
|
||||
|
||||
expect(screen.getByText('Lillebror Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.compulsorySchool'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Storasyster Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.upperSecondarySchool'))
|
||||
).toBeTruthy()
|
||||
|
||||
expect(screen.getByText('Lillebror Testsson')).toBeTruthy()
|
||||
expect(
|
||||
screen.getByText(translate('abbrevations.compulsorySchool'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders child in class', () => {
|
||||
|
@ -194,13 +178,10 @@ test('renders child in class', () => {
|
|||
],
|
||||
status: 'loaded',
|
||||
}))
|
||||
setImmediate(() => {
|
||||
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(screen.getByText('8C • Vallaskolan')).toBeTruthy()
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(screen.getByText('8C • Vallaskolan')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('removes any parenthesis from name', () => {
|
||||
|
@ -213,12 +194,9 @@ test('removes any parenthesis from name', () => {
|
|||
],
|
||||
status: 'loaded',
|
||||
}))
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('handles multiple statuses for a child', () => {
|
||||
|
@ -231,19 +209,16 @@ test('handles multiple statuses for a child', () => {
|
|||
],
|
||||
status: 'loaded',
|
||||
}))
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
var multipleStatusesRendered = `${translate(
|
||||
'abbrevations.upperSecondarySchool'
|
||||
)}, ${translate('abbrevations.compulsorySchool')}, ${translate(
|
||||
'abbrevations.leisureTimeCentre'
|
||||
)}`
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(screen.getByText(multipleStatusesRendered)).toBeTruthy()
|
||||
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
var multipleStatusesRendered = `${translate(
|
||||
'abbrevations.upperSecondarySchool'
|
||||
)}, ${translate('abbrevations.compulsorySchool')}, ${translate(
|
||||
'abbrevations.leisureTimeCentre'
|
||||
)}`
|
||||
|
||||
expect(screen.getByText('Test Testsson')).toBeTruthy()
|
||||
expect(screen.getByText(multipleStatusesRendered)).toBeTruthy()
|
||||
})
|
||||
|
||||
test('says if there is nothing new this week', () => {
|
||||
|
@ -256,12 +231,9 @@ test('says if there is nothing new this week', () => {
|
|||
],
|
||||
status: 'loaded',
|
||||
}))
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
|
||||
expect(
|
||||
screen.getByText(translate('news.noNewNewsItemsThisWeek'))
|
||||
).toBeTruthy()
|
||||
|
||||
})
|
||||
const screen = setup()
|
||||
|
||||
expect(
|
||||
screen.getByText(translate('news.noNewNewsItemsThisWeek'))
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
|
|
@ -40,9 +40,8 @@ beforeEach(jest.clearAllMocks)
|
|||
|
||||
test('renders a parent', () => {
|
||||
const screen = setup()
|
||||
// act(() => {
|
||||
|
||||
fireEvent.press(screen.getByTestId('ShowContactInfoButton'))
|
||||
// });
|
||||
|
||||
expect(screen.getByText(/adam adamsson/i)).toBeTruthy()
|
||||
})
|
||||
|
@ -75,10 +74,6 @@ test('hides options to call and text if no phone number', () => {
|
|||
|
||||
fireEvent.press(screen.getByTestId('ShowContactInfoButton'))
|
||||
|
||||
// expect(screen.getByTestId('CallMenuItem')).toHaveStyle({display: 'none'});
|
||||
// expect(screen.getByTestId('CallMenuItem')).toBeFalsy();
|
||||
// expect(screen.getByTestId('SMSMenuItem')).toHaveStyle({display: 'none'});
|
||||
// expect(screen.getByTestId('SMSMenuItem')).toBeFalsy();
|
||||
expect(screen.queryByTestId('CallMenuItem')).toBeNull()
|
||||
expect(screen.queryByTestId('SMSMenuItem')).toBeNull()
|
||||
})
|
||||
|
@ -108,9 +103,6 @@ test('hides options to email phone number', () => {
|
|||
|
||||
fireEvent.press(screen.getByTestId('ShowContactInfoButton'))
|
||||
|
||||
// expect(screen.getByTestId('SendEmailMenuItem')).toHaveStyle({
|
||||
// display: 'none',
|
||||
// });
|
||||
expect(screen.queryByTestId('SendEmailMenuItem')).toBeNull()
|
||||
})
|
||||
|
||||
|
@ -141,8 +133,5 @@ test('hides address if it does not exist', () => {
|
|||
|
||||
fireEvent.press(screen.getByTestId('ShowContactInfoButton'))
|
||||
|
||||
// expect(screen.getByTestId('ShowHomeMenuItem')).toHaveStyle({
|
||||
// display: 'none',
|
||||
// });
|
||||
expect(screen.queryByTestId('ShowHomeMenuItem')).toBeNull()
|
||||
})
|
||||
|
|
|
@ -2,15 +2,12 @@ import { useApi, useNewsDetails } from '../../libs/hooks/src'
|
|||
import React from 'react'
|
||||
import { render } from '../../utils/testHelpers'
|
||||
import { NewsItem } from '../newsItem.component'
|
||||
import { setImmediate } from 'timers/promises'
|
||||
import { set } from 'mockdate'
|
||||
|
||||
jest.mock('../../libs/hooks/src')
|
||||
|
||||
const defaultNewsItem = {
|
||||
author: 'Köket',
|
||||
fullImageUrl:
|
||||
'https://images.unsplash.com/photo-1629652487043-fb2825838f8c?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2671&q=80',
|
||||
fullImageUrl: 'test.png',
|
||||
header: 'K-bullar!',
|
||||
published: '2021-02-15T09:13:28.484Z',
|
||||
modified: '2021-02-15T09:13:28.484Z',
|
||||
|
@ -50,22 +47,18 @@ const setup = (customProps = { newsItem: {} }) => {
|
|||
return render(<NewsItem {...props} />)
|
||||
}
|
||||
|
||||
test('gets article details using useNewsDetails', () => {
|
||||
setImmediate(() => {
|
||||
setup()
|
||||
test('gets article details using useNewsDetails', async () => {
|
||||
setup()
|
||||
|
||||
expect(useNewsDetails).toHaveBeenCalledWith({ id: 1 }, defaultNewsItem)
|
||||
})
|
||||
expect(useNewsDetails).toHaveBeenCalledWith({ id: 1 }, defaultNewsItem)
|
||||
})
|
||||
|
||||
test('renders an article', () => {
|
||||
setImmediate(() => {
|
||||
const screen = setup()
|
||||
const screen = setup()
|
||||
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Publicerad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.getByText('Uppdaterad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
})
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Publicerad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.getByText('Uppdaterad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders an article without published date if date is invalid', () => {
|
||||
|
@ -73,13 +66,11 @@ test('renders an article without published date if date is invalid', () => {
|
|||
...defaultNewsItem,
|
||||
published: '2020-08-16T21:10:00.000+02:0',
|
||||
}
|
||||
setImmediate(() => {
|
||||
const screen = setup({ newsItem: newsItemWithoutPublishedDate })
|
||||
const screen = setup({ newsItem: newsItemWithoutPublishedDate })
|
||||
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Uppdaterad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.queryByText('Publicerad: Invalid DateTime')).toBeFalsy()
|
||||
})
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Uppdaterad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.queryByText('Publicerad: Invalid DateTime')).toBeFalsy()
|
||||
})
|
||||
|
||||
test('renders an article without modified date if date is invalid', () => {
|
||||
|
@ -87,11 +78,9 @@ test('renders an article without modified date if date is invalid', () => {
|
|||
...defaultNewsItem,
|
||||
modified: null,
|
||||
}
|
||||
setImmediate(() => {
|
||||
const screen = setup({ newsItem: newsItemWithoutPublishedDate })
|
||||
const screen = setup({ newsItem: newsItemWithoutPublishedDate })
|
||||
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Publicerad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.queryByText('Uppdaterad: Invalid DateTime')).toBeFalsy()
|
||||
})
|
||||
expect(screen.getByText(/nu blir det köttbullar/i)).toBeTruthy()
|
||||
expect(screen.getByText('Publicerad: 15 feb 2021 10:13')).toBeTruthy()
|
||||
expect(screen.queryByText('Uppdaterad: Invalid DateTime')).toBeFalsy()
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useCalendar } from '../libs/hooks/src'
|
||||
import { CalendarItem } from '../libs/api/lib'
|
||||
import { CalendarItem } from '@skolplattformen/api'
|
||||
import {
|
||||
Divider,
|
||||
List,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child } from '../libs/api/lib'
|
||||
import { Child } from '@skolplattformen/api'
|
||||
import React, { createContext, useContext } from 'react'
|
||||
|
||||
interface ChildProviderProps {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { Child } from '../libs/api/lib'
|
||||
import { Child } from '@skolplattformen/api'
|
||||
import {
|
||||
useCalendar,
|
||||
useClassmates,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { NavigationProp, useNavigation } from '@react-navigation/core'
|
||||
import { NativeStackNavigationOptions } from '@react-navigation/native-stack'
|
||||
import { Child } from '../libs/api/lib'
|
||||
import { Child } from '@skolplattformen/api'
|
||||
import { useApi, useChildList } from '../libs/hooks/src'
|
||||
import {
|
||||
Button,
|
||||
|
@ -143,7 +143,6 @@ export const Children = () => {
|
|||
) : (
|
||||
<View style={styles.loadingMessage}>
|
||||
<Spinner size="large" status="primary" />
|
||||
<Text>Spinner here :D </Text>
|
||||
<Text category="h1" style={styles.loadingText}>
|
||||
{translate('general.loading')}
|
||||
</Text>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Classmate } from '../libs/api/lib'
|
||||
import { Classmate } from '@skolplattformen/api'
|
||||
import { useClassmates } from '../libs/hooks/src'
|
||||
import {
|
||||
Divider,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Classmate } from '../libs/api/lib'
|
||||
import { Classmate } from '@skolplattformen/api'
|
||||
import {
|
||||
Button,
|
||||
MenuGroup,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child } from '../libs/api/lib'
|
||||
import { Child } from '@skolplattformen/api'
|
||||
import { useTimetable } from '../libs/hooks/src'
|
||||
import { StyleService, Text, useStyleSheet } from '@ui-kitten/components'
|
||||
import moment, { Moment } from 'moment'
|
||||
|
|
|
@ -94,11 +94,8 @@ export const Login = () => {
|
|||
useEffect(() => {
|
||||
const loginHandler = async () => {
|
||||
console.debug('Running loginHandler')
|
||||
console.log('before user')
|
||||
try {
|
||||
const user = await api.getUser()
|
||||
console.log('after user')
|
||||
console.debug(user)
|
||||
await AppStorage.clearPersonalData(user)
|
||||
showModal(false)
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MenuItem } from '../libs/api/lib'
|
||||
import { MenuItem } from '@skolplattformen/api'
|
||||
import { useMenu } from '../libs/hooks/src'
|
||||
import {
|
||||
Divider,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MenuItem } from '../libs/api/lib'
|
||||
import { MenuItem } from '@skolplattformen/api'
|
||||
import { StyleService, Text, useStyleSheet } from '@ui-kitten/components'
|
||||
import React from 'react'
|
||||
import { View } from 'react-native'
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { NavigationContainer } from '@react-navigation/native'
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
||||
import { Child as ChildType, NewsItem as NewsItemType } from '../libs/api/lib'
|
||||
import {
|
||||
Child as ChildType,
|
||||
NewsItem as NewsItemType,
|
||||
} from '@skolplattformen/api'
|
||||
import { useApi } from '../libs/hooks/src'
|
||||
import { useTheme } from '@ui-kitten/components'
|
||||
import { Library } from 'libraries.json'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { NewsItem } from '../libs/api/lib'
|
||||
import { NewsItem } from '@skolplattformen/api'
|
||||
import { StyleService, useStyleSheet } from '@ui-kitten/components'
|
||||
import moment from 'moment'
|
||||
import React, { ReactNode } from 'react'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Notification as NotificationType } from '../libs/api/lib'
|
||||
import { Notification as NotificationType } from '@skolplattformen/api'
|
||||
import { StyleService, Text, useStyleSheet } from '@ui-kitten/components'
|
||||
import moment from 'moment'
|
||||
import React from 'react'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CalendarItem } from '../libs/api/lib'
|
||||
import { CalendarItem } from '@skolplattformen/api'
|
||||
import { Button, MenuItem, OverflowMenu, Text } from '@ui-kitten/components'
|
||||
import React from 'react'
|
||||
import RNCalendarEvents from 'react-native-calendar-events'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child, MenuItem, TimetableEntry } from '../libs/api/lib'
|
||||
import { Child, MenuItem, TimetableEntry } from '@skolplattformen/api'
|
||||
import { useMenu, useTimetable } from '../libs/hooks/src'
|
||||
import {
|
||||
List,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// import {Features, FeatureType} from '../../libs/api/lib'';
|
||||
import { Features } from '../../libs/api/lib'
|
||||
import { Features } from '@skolplattformen/api'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { User } from '../../libs/api/lib'
|
||||
import { User } from '@skolplattformen/api'
|
||||
import { act, renderHook } from '@testing-library/react'
|
||||
import usePersonalStorage from '../usePersonalStorage'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Features, FeatureType } from '../libs/api/lib'
|
||||
import { Features, FeatureType } from '@skolplattformen/api'
|
||||
import React from 'react'
|
||||
import { FeatureFlagsContext } from '../context/feature/featureContext'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { User } from '../libs/api/lib'
|
||||
import { User } from '@skolplattformen/api'
|
||||
import useAsyncStorage from './useAsyncStorage'
|
||||
|
||||
export default function usePersonalStorage<T>(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { EtjanstChild, Skola24Child } from '../../../../libs/api/lib'
|
||||
import { EtjanstChild, Skola24Child } from '@skolplattformen/api'
|
||||
|
||||
export const children = (): EtjanstChild[] => [
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child, Classmate } from '../../../../libs/api/lib'
|
||||
import { Child, Classmate } from '@skolplattformen/api'
|
||||
import { children } from './children'
|
||||
|
||||
export const classmates = (child: Child): Classmate[] =>
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
Notification,
|
||||
ScheduleItem,
|
||||
User,
|
||||
} from '../../../../libs/api/lib'
|
||||
} from '@skolplattformen/api'
|
||||
import { oneDayForward, oneWeekForward, twoDaysForward } from './dates'
|
||||
|
||||
const data: any = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child, MenuItem } from '../../../../libs/api/lib'
|
||||
import { Child, MenuItem } from '@skolplattformen/api'
|
||||
import { DateTime } from 'luxon'
|
||||
import { children } from './children'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { children } from './children'
|
||||
import { Child, NewsItem } from '../../../../libs/api/lib'
|
||||
import { Child, NewsItem } from '@skolplattformen/api'
|
||||
import * as dates from './dates'
|
||||
|
||||
export const news = (child: Child): NewsItem[] => newsData.get(child.id) ?? []
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { SchoolContact, Child } from '../../../../libs/api/lib'
|
||||
import { SchoolContact, Child } from '@skolplattformen/api'
|
||||
import { children } from './children'
|
||||
|
||||
export const schoolContacts = (child: Child): SchoolContact[] =>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Teacher, Child } from '../../../../libs/api/lib'
|
||||
import { Teacher, Child } from '@skolplattformen/api'
|
||||
import { children } from './children'
|
||||
|
||||
export const teachers = (child: Child): Teacher[] =>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Skola24Child, TimetableEntry } from '../../../../libs/api/lib'
|
||||
import { Skola24Child, TimetableEntry } from '@skolplattformen/api'
|
||||
|
||||
export const timetable = (child: Skola24Child): TimetableEntry[] => {
|
||||
if (!child.personGuid || !child.unitGuid) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
Fetcher,
|
||||
FrejaLoginStatusChecker,
|
||||
RequestInit,
|
||||
} from '../../../libs/api/lib'
|
||||
} from '@skolplattformen/api'
|
||||
export class FrejaChecker
|
||||
extends EventEmitter
|
||||
implements FrejaLoginStatusChecker
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import { loginStatus } from './routes'
|
||||
import { Fetcher, AuthTicket } from '../../../libs/api/lib'
|
||||
import { Fetcher, AuthTicket } from '@skolplattformen/api'
|
||||
|
||||
/*
|
||||
export enum LoginEvent {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import { loginStatus } from './routes'
|
||||
import { AuthTicket, Fetcher, LoginStatusChecker } from '../../../libs/api/lib'
|
||||
import { AuthTicket, Fetcher, LoginStatusChecker } from '@skolplattformen/api'
|
||||
|
||||
export class Checker extends EventEmitter implements LoginStatusChecker {
|
||||
public token: string
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Child } from '../../../api/lib'
|
||||
import { Child } from '@skolplattformen/api'
|
||||
import { etjanst } from './etjanst'
|
||||
|
||||
export const child = ({ id, sdsId, name, status, schoolId }: any): Child => ({
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { etjanst } from './etjanst'
|
||||
import { SchoolContact } from '../../../../libs/api/lib'
|
||||
import { SchoolContact } from '@skolplattformen/api'
|
||||
|
||||
export const schoolContact = ({
|
||||
title,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { etjanst } from './etjanst'
|
||||
import { Teacher } from '../../../../libs/api/lib'
|
||||
import { Teacher } from '@skolplattformen/api'
|
||||
|
||||
const abbreviate = (firstname?: string, lastname?: string): string =>
|
||||
`${firstname?.substr(0, 1)}${lastname?.substr(0, 2)}`.toUpperCase()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TimetableEntry } from '../../../../libs/api/lib'
|
||||
import { TimetableEntry } from '@skolplattformen/api'
|
||||
import parse, { Language } from '../../../curriculum/src'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { User } from '../../../../libs/api/lib'
|
||||
import { User } from '@skolplattformen/api'
|
||||
|
||||
export const user = ({
|
||||
socialSecurityNumber,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import QueueFetcher from './queue/queueFetcher'
|
||||
import { Fetcher, RequestInit, Response } from '../../../libs/api/lib'
|
||||
import { Fetcher, RequestInit, Response } from '@skolplattformen/api'
|
||||
|
||||
export default function queueFetcherWrapper(
|
||||
fetch: Fetcher,
|
||||
|
|
|
@ -32,7 +32,6 @@ describe('useApi()', () => {
|
|||
await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.emitter.emit('login')
|
||||
// await waitForValueToChange(() => result.current.isLoggedIn);
|
||||
})
|
||||
await waitFor(() => expect(result.current.isLoggedIn).toBe(true))
|
||||
})
|
||||
|
@ -44,7 +43,6 @@ describe('useApi()', () => {
|
|||
await act(async () => {
|
||||
api.isFake = true
|
||||
api.emitter.emit('login')
|
||||
// await waitForValueToChange(() => result.current.isFake);
|
||||
})
|
||||
await waitFor(() => expect(result.current.isFake).toBe(true))
|
||||
})
|
||||
|
|
|
@ -43,15 +43,11 @@ describe('hooks with fake data', () => {
|
|||
})
|
||||
it('does not use cache', async () => {
|
||||
storage.cache.user = JSON.stringify({ user: 'cached' })
|
||||
// await act(async () => {
|
||||
|
||||
const { result } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
|
||||
await waitFor(() =>
|
||||
expect(result.current.data).toEqual({
|
||||
firstName: 'Namn',
|
||||
|
@ -60,16 +56,12 @@ describe('hooks with fake data', () => {
|
|||
personalNumber: '195001182046',
|
||||
})
|
||||
)
|
||||
// })
|
||||
})
|
||||
it('returns user', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() =>
|
||||
expect(result.current.data).toEqual({
|
||||
firstName: 'Namn',
|
||||
|
@ -78,19 +70,11 @@ describe('hooks with fake data', () => {
|
|||
personalNumber: '195001182046',
|
||||
})
|
||||
)
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns child list', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data).toHaveLength(2))
|
||||
|
||||
// })
|
||||
})
|
||||
describe('data belonging to one child', () => {
|
||||
let child: any
|
||||
|
@ -98,95 +82,61 @@ describe('hooks with fake data', () => {
|
|||
;[child] = await api.getChildren()
|
||||
})
|
||||
it('returns calendar', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useCalendar(child), { wrapper })
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data.length).toBeGreaterThan(1))
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns classmates', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data.length).toBeGreaterThan(1))
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns menu', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data.length).toBeGreaterThan(1))
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns news', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data.length).toBeGreaterThan(1))
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns notifications', async () => {
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => expect(result.current.data.length).toBeGreaterThan(1))
|
||||
|
||||
// })
|
||||
})
|
||||
it('returns schedule', async () => {
|
||||
const from = '2021-01-01'
|
||||
const to = '2021-01-08'
|
||||
// await act(async () => {
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate()
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() =>
|
||||
// No fake schedule in embedded-api yet
|
||||
expect(result.current.data.length).not.toBeGreaterThan(1)
|
||||
)
|
||||
|
||||
// })
|
||||
})
|
||||
})
|
||||
it('handles reloads', async () => {
|
||||
// await act(async () => {
|
||||
store.dispatch({ type: 'CLEAR' } as any) // fixes test for invalid type
|
||||
|
||||
const [child] = await api.getChildren()
|
||||
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
//await waitForNextUpdate()
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
result.current.reload()
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// })
|
||||
})
|
||||
})
|
||||
|
|
|
@ -43,8 +43,6 @@ describe('logout - cleanup', () => {
|
|||
})
|
||||
|
||||
it('cleans up on logout', async () => {
|
||||
// await act(async () => {
|
||||
|
||||
act(() => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
@ -75,5 +73,4 @@ describe('logout - cleanup', () => {
|
|||
|
||||
await waitFor(() => expect(result2.current.data).toHaveLength(1))
|
||||
})
|
||||
// })
|
||||
})
|
||||
|
|
|
@ -51,102 +51,71 @@ describe('useCalendar(child)', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getCalendar).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useCalendar(child), { wrapper })
|
||||
renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
renderHook(() => useCalendar(child), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useCalendar(child), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useCalendar(child), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getCalendar).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// })
|
||||
})
|
||||
|
||||
it('retrieves data from cache', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
// });
|
||||
})
|
||||
|
||||
it('works when cache is empty', async () => {
|
||||
storage.clear()
|
||||
//await act(async () => {
|
||||
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 1 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useCalendar(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -154,19 +123,12 @@ describe('useCalendar(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_calendar_10']).toEqual('[{"id":1}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -174,18 +136,13 @@ describe('useCalendar(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_calendar_10']).toEqual('[{"id":2}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('retries if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
@ -194,27 +151,19 @@ describe('useCalendar(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('gives up after 3 retries', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
@ -225,28 +174,20 @@ describe('useCalendar(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('reports if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getCalendar.mockRejectedValueOnce(error)
|
||||
|
@ -255,9 +196,6 @@ describe('useCalendar(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -267,5 +205,4 @@ describe('useCalendar(child)', () => {
|
|||
)
|
||||
})
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
|
|
@ -70,36 +70,27 @@ describe('useChildList()', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(api.getChildren).toHaveBeenCalled()
|
||||
expect(api.getSkola24Children).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useChildList(), { wrapper })
|
||||
renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
renderHook(() => useChildList(), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useChildList(), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useChildList(), { wrapper })
|
||||
await waitFor(() => {
|
||||
|
@ -107,22 +98,14 @@ describe('useChildList()', () => {
|
|||
expect(api.getSkola24Children).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() =>
|
||||
expect(result.current.data).toEqual([
|
||||
{
|
||||
|
@ -134,44 +117,27 @@ describe('useChildList()', () => {
|
|||
},
|
||||
])
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -179,14 +145,6 @@ describe('useChildList()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(
|
||||
JSON.stringify(echildrenResponse)
|
||||
|
@ -195,12 +153,9 @@ describe('useChildList()', () => {
|
|||
JSON.stringify(skola24Response)
|
||||
)
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -208,11 +163,6 @@ describe('useChildList()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(storage.cache['123_etjanst_children']).toEqual(
|
||||
|
@ -222,8 +172,6 @@ describe('useChildList()', () => {
|
|||
JSON.stringify(skola24Cache)
|
||||
)
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it.skip('retries if etjanst-api fails', async () => {
|
||||
|
@ -306,23 +254,14 @@ describe('useChildList()', () => {
|
|||
})
|
||||
|
||||
it('reports if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result} = renderHook(() => useChildList(), {
|
||||
// wrapper,
|
||||
// });
|
||||
|
||||
const { result } = renderHook(() => useChildList(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -331,6 +270,5 @@ describe('useChildList()', () => {
|
|||
'Error getting ETJANST_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -50,78 +50,51 @@ describe('useClassmates(child)', () => {
|
|||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getClassmates).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useClassmates(child), { wrapper })
|
||||
renderHook(() => useClassmates(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useClassmates(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useClassmates(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getClassmates).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
// expect(result.current.status).toEqual('loading');
|
||||
// });
|
||||
})
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -129,18 +102,11 @@ describe('useClassmates(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
//await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_classmates_10']).toEqual('[{"id":1}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -148,43 +114,29 @@ describe('useClassmates(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
//await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_classmates_10']).toEqual('[{"id":2}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
@ -193,39 +145,25 @@ describe('useClassmates(child)', () => {
|
|||
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getClassmates.mockRejectedValueOnce(error)
|
||||
|
||||
const { result } = renderHook(() => useClassmates(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -234,6 +172,5 @@ describe('useClassmates(child)', () => {
|
|||
'Error getting CLASSMATES from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -48,81 +48,54 @@ describe('useEtjanstChildren()', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getChildren).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
it('only calls api once', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
//await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getChildren).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -130,68 +103,44 @@ describe('useEtjanstChildren()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_etjanst_children']).toEqual('[{"id":1}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
// renderHook(() => useEtjanstChildren(), {
|
||||
// wrapper,
|
||||
// });
|
||||
|
||||
renderHook(() => useEtjanstChildren(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_etjanst_children']).toEqual('[{"id":2}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('retries if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('gives up after 3 retries', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
@ -200,38 +149,26 @@ describe('useEtjanstChildren()', () => {
|
|||
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
//await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('reports if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getChildren.mockRejectedValueOnce(error)
|
||||
|
||||
const { result } = renderHook(() => useEtjanstChildren(), { wrapper })
|
||||
|
||||
// //await waitForNextUpdate();
|
||||
// //await waitForNextUpdate();
|
||||
// //await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -240,6 +177,5 @@ describe('useEtjanstChildren()', () => {
|
|||
'Error getting ETJANST_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -49,84 +49,58 @@ describe('useMenu(child)', () => {
|
|||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
expect(api.getMenu).toHaveBeenCalled()
|
||||
// });
|
||||
})
|
||||
it('only calls api once', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useMenu(child), { wrapper })
|
||||
renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useMenu(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useMenu(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useMenu(child), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getMenu).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useMenu(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -134,19 +108,12 @@ describe('useMenu(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_menu_10']).toEqual('[{"id":1}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -154,17 +121,11 @@ describe('useMenu(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_menu_10']).toEqual('[{"id":2}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
@ -173,26 +134,18 @@ describe('useMenu(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
@ -203,29 +156,19 @@ describe('useMenu(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getMenu.mockRejectedValueOnce(error)
|
||||
|
@ -234,10 +177,6 @@ describe('useMenu(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -246,6 +185,5 @@ describe('useMenu(child)', () => {
|
|||
'Error getting MENU from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -51,87 +51,60 @@ describe('useNews(child)', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => expect(api.getNews).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNews(child), { wrapper })
|
||||
renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
renderHook(() => useNews(child), { wrapper })
|
||||
//await waitFornextUpdate();
|
||||
|
||||
renderHook(() => useNews(child), { wrapper })
|
||||
//await waitFornextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useNews(child), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getNews).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -139,19 +112,12 @@ describe('useNews(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_news_10']).toEqual('[{"id":1}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -159,101 +125,63 @@ describe('useNews(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_news_10']).toEqual('[{"id":2}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('retries if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(() => useNews(child), {
|
||||
// wrapper,
|
||||
// });
|
||||
|
||||
const { result } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(() => useNews(child), {
|
||||
// wrapper,
|
||||
// });
|
||||
|
||||
const { result } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
//await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNews.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(() => useNews(child), {
|
||||
// wrapper,
|
||||
// });
|
||||
|
||||
const { result } = renderHook(() => useNews(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
//await waitFornextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -262,6 +190,5 @@ describe('useNews(child)', () => {
|
|||
'Error getting NEWS from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -57,28 +57,20 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getNewsDetails).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
|
@ -87,178 +79,109 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
expect(api.getNewsDetails).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual(cached))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(
|
||||
JSON.stringify(response)
|
||||
)
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
// const {waitForNextUpdate} = renderHook(
|
||||
// () => useNewsDetails(child, newsItem),
|
||||
// {wrapper},
|
||||
// );
|
||||
renderHook(() => useNewsDetails(child, newsItem), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
expect(storage.cache['123_news_details_1337']).toEqual(
|
||||
JSON.stringify(cached)
|
||||
)
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNewsDetails(child, newsItem),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual({ ...cached })
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual({ ...response })
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNewsDetails(child, newsItem),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual({ ...cached })
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual({ ...cached })
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNewsDetails.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNewsDetails(child, newsItem),
|
||||
// {wrapper},
|
||||
// );
|
||||
const { result } = renderHook(() => useNewsDetails(child, newsItem), {
|
||||
wrapper,
|
||||
})
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
@ -268,6 +191,5 @@ describe('useNewsDetails(child, newsItem)', () => {
|
|||
'Error getting NEWS_DETAILS from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -49,81 +49,54 @@ describe('useNotifications(child)', () => {
|
|||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getNotifications).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useNotifications(child), { wrapper })
|
||||
renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useNotifications(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useNotifications(child), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getNotifications).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -131,122 +104,69 @@ describe('useNotifications(child)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_notifications_10']).toEqual('[{"id":1}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
// const {waitForNextUpdate} = renderHook(() => useNotifications(child), {
|
||||
// wrapper,
|
||||
// });
|
||||
renderHook(() => useNotifications(child), {
|
||||
wrapper,
|
||||
})
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_notifications_10']).toEqual('[{"id":2}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNotifications(child),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNotifications(child),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getNotifications.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useNotifications(child),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useNotifications(child), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -255,6 +175,5 @@ describe('useNotifications(child)', () => {
|
|||
'Error getting NOTIFICATIONS from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -56,30 +56,22 @@ describe('useSchedule(child, from, to)', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getSchedule).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
|
@ -89,182 +81,111 @@ describe('useSchedule(child, from, to)', () => {
|
|||
expect(api.getSchedule).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useSchedule(child, from, to),
|
||||
{ wrapper }
|
||||
)
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual(
|
||||
'[{"id":1}]'
|
||||
)
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
// const {waitForNextUpdate} = renderHook(
|
||||
// () => useSchedule(child, from, to),
|
||||
// {wrapper},
|
||||
// );
|
||||
renderHook(() => useSchedule(child, from, to), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_schedule_10_2021-01-01_2021-01-08']).toEqual(
|
||||
'[{"id":2}]'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useSchedule(child, from, to),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useSchedule(child, from, to),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSchedule.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useSchedule(child, from, to),
|
||||
// {wrapper},
|
||||
// );
|
||||
const { result } = renderHook(() => useSchedule(child, from, to), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -273,6 +194,5 @@ describe('useSchedule(child, from, to)', () => {
|
|||
'Error getting SCHEDULE from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -48,81 +48,55 @@ describe('useSkola24Children()', () => {
|
|||
})
|
||||
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { waitForNextUpdate } = renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(api.getSkola24Children).toHaveBeenCalled())
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useSkola24Children(), { wrapper })
|
||||
renderHook(() => useSkola24Children(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useSkola24Children(), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useSkola24Children(), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getSkola24Children).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() =>
|
||||
expect(result.current.data).toEqual([{ personGuid: '2' }])
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
|
@ -130,20 +104,13 @@ describe('useSkola24Children()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
'[{"personGuid":"1"}]'
|
||||
)
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
|
@ -151,20 +118,14 @@ describe('useSkola24Children()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_skola24_children']).toEqual(
|
||||
'[{"personGuid":"2"}]'
|
||||
)
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
@ -173,28 +134,19 @@ describe('useSkola24Children()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ personGuid: '2' }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ personGuid: '1' }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
@ -205,44 +157,26 @@ describe('useSkola24Children()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ personGuid: '2' }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ personGuid: '2' }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getSkola24Children.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useSkola24Children(),
|
||||
// {wrapper},
|
||||
// );
|
||||
const { result } = renderHook(() => useSkola24Children(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -251,6 +185,5 @@ describe('useSkola24Children()', () => {
|
|||
'Error getting SKOLA24_CHILDREN from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -57,28 +57,20 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
expect(result.current.status).toEqual('pending')
|
||||
})
|
||||
it('calls api', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => expect(api.getTimetable).toHaveBeenCalled())
|
||||
// });
|
||||
})
|
||||
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
|
@ -87,97 +79,56 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
expect(api.getTimetable).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
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();
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
await waitFor(() => expect(result.current.data).toEqual([{ id: 2 }]))
|
||||
// expect(result.current.data).toEqual([{id: 2}]);
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loading'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => expect(result.current.status).toEqual('loaded'))
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
// const {waitForNextUpdate} = renderHook(
|
||||
// () => useTimetable(child, week, year, lang),
|
||||
// {wrapper},
|
||||
// );
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_timetable_10_15_2021_sv']).toEqual('[{"id":1}]')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
renderHook(() => useTimetable(child, week, year, lang), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
await waitFor(() =>
|
||||
expect(storage.cache['123_timetable_10_15_2021_sv']).toEqual('[{"id":2}]')
|
||||
)
|
||||
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
@ -186,80 +137,50 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual([{ id: 1 }])
|
||||
})
|
||||
|
||||
// });
|
||||
})
|
||||
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useTimetable(child, week, year, lang),
|
||||
// {wrapper},
|
||||
// );
|
||||
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual([{ id: 2 }])
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getTimetable.mockRejectedValueOnce(error)
|
||||
|
||||
// const {result, waitForNextUpdate} = renderHook(
|
||||
// () => useTimetable(child, week, year, lang),
|
||||
// {wrapper},
|
||||
// );
|
||||
const { result } = renderHook(() => useTimetable(child, week, year, lang), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -268,6 +189,5 @@ describe('useTimetable(child, week, year, lang)', () => {
|
|||
'Error getting TIMETABLE from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -48,10 +48,6 @@ describe('useUser()', () => {
|
|||
})
|
||||
it('calls api', async () => {
|
||||
api.isLoggedIn = true
|
||||
// const { waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate()
|
||||
// await waitForNextUpdate()
|
||||
|
||||
await waitFor(() => {
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
|
@ -59,107 +55,69 @@ describe('useUser()', () => {
|
|||
expect(api.getUser).toHaveBeenCalled()
|
||||
})
|
||||
it('only calls api once', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
// const {waitForNextUpdate} = renderHook(() => useUser(), {wrapper});
|
||||
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
// await waitForNextUpdate();
|
||||
|
||||
const { result } = renderHook(() => useUser(), { wrapper })
|
||||
await waitFor(() => {
|
||||
expect(api.getUser).toHaveBeenCalledTimes(1)
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('calls cache', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.data).toEqual({ id: 2 })
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('updates status to loading', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loading')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('updates status to loaded', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const { result } = renderHook(() => useUser(), {
|
||||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('stores in cache if not fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = false
|
||||
|
||||
// const { waitForNextUpdate } = renderHook(() => useUser(), { wrapper })
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate()
|
||||
// await waitForNextUpdate()
|
||||
// await waitForNextUpdate()
|
||||
// await act(async () => {
|
||||
// await pause(20);
|
||||
// });
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_user']).toEqual('{"id":1}')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('does not store in cache if fake', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
api.isFake = true
|
||||
|
||||
// const {waitForNextUpdate} = renderHook(() => useUser(), {wrapper});
|
||||
renderHook(() => useUser(), { wrapper })
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await pause(20);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(storage.cache['123_user']).toEqual('{"id":2}')
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('retries if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
@ -168,27 +126,17 @@ describe('useUser()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual({ id: 2 })
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.status).toEqual('loaded')
|
||||
expect(result.current.data).toEqual({ id: 1 })
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('gives up after 3 retries', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
@ -199,27 +147,18 @@ describe('useUser()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('loading')
|
||||
expect(result.current.data).toEqual({ id: 2 })
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
expect(result.current.status).toEqual('error')
|
||||
expect(result.current.data).toEqual({ id: 2 })
|
||||
})
|
||||
// });
|
||||
})
|
||||
it('reports if api fails', async () => {
|
||||
// await act(async () => {
|
||||
api.isLoggedIn = true
|
||||
const error = new Error('fail')
|
||||
api.getUser.mockRejectedValueOnce(error)
|
||||
|
@ -228,9 +167,6 @@ describe('useUser()', () => {
|
|||
wrapper,
|
||||
})
|
||||
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
// await waitForNextUpdate();
|
||||
await waitFor(() => {
|
||||
expect(result.current.error).toEqual(error)
|
||||
|
||||
|
@ -239,6 +175,5 @@ describe('useUser()', () => {
|
|||
'Error getting USER from API'
|
||||
)
|
||||
})
|
||||
// });
|
||||
})
|
||||
})
|
||||
|
|
|
@ -56,7 +56,8 @@
|
|||
"react-native-webview": "^13.6.0",
|
||||
"react-redux": "^8.1.2",
|
||||
"redux": "^4.2.1",
|
||||
"tough-cookie": "4.0.0",
|
||||
"setimmediate": "^1.0.5",
|
||||
"tough-cookie": "4.1.3",
|
||||
"tslib": "^2.6.2",
|
||||
"valtio": "^1.11.2",
|
||||
"yup": "^1.3.1"
|
||||
|
@ -78,6 +79,7 @@
|
|||
"@types/react": "^18.0.24",
|
||||
"@types/react-test-renderer": "^18.0.0",
|
||||
"babel-jest": "^29.7.0",
|
||||
"babel-plugin-module-resolver": "^5.0.0",
|
||||
"eslint": "^8.19.0",
|
||||
"esm": "^3.2.25",
|
||||
"jest": "^29.2.1",
|
||||
|
@ -6179,6 +6181,62 @@
|
|||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-module-resolver": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.0.tgz",
|
||||
"integrity": "sha512-g0u+/ChLSJ5+PzYwLwP8Rp8Rcfowz58TJNCe+L/ui4rpzE/mg//JVX0EWBUYoxaextqnwuGHzfGp2hh0PPV25Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"find-babel-config": "^2.0.0",
|
||||
"glob": "^8.0.3",
|
||||
"pkg-up": "^3.1.0",
|
||||
"reselect": "^4.1.7",
|
||||
"resolve": "^1.22.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-module-resolver/node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-module-resolver/node_modules/glob": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
|
||||
"integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^5.0.1",
|
||||
"once": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-module-resolver/node_modules/minimatch": {
|
||||
"version": "5.1.6",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
|
||||
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-polyfill-corejs2": {
|
||||
"version": "0.4.6",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.6.tgz",
|
||||
|
@ -8733,6 +8791,19 @@
|
|||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
},
|
||||
"node_modules/find-babel-config": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-2.0.0.tgz",
|
||||
"integrity": "sha512-dOKT7jvF3hGzlW60Gc3ONox/0rRZ/tz7WCil0bqA1In/3I8f1BctpXahRnEKDySZqci7u+dqq93sZST9fOJpFw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"json5": "^2.1.1",
|
||||
"path-exists": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/find-cache-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz",
|
||||
|
@ -12042,21 +12113,6 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/tough-cookie": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
|
||||
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"psl": "^1.1.33",
|
||||
"punycode": "^2.1.1",
|
||||
"universalify": "^0.2.0",
|
||||
"url-parse": "^1.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/tr46": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
|
||||
|
@ -12069,15 +12125,6 @@
|
|||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/universalify": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
||||
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jsdom/node_modules/webidl-conversions": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||
|
@ -14186,6 +14233,79 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz",
|
||||
"integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"find-up": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up/node_modules/find-up": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
|
||||
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"locate-path": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up/node_modules/locate-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
|
||||
"integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"p-locate": "^3.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up/node_modules/p-limit": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
|
||||
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"p-try": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up/node_modules/p-locate": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
|
||||
"integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"p-limit": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pkg-up/node_modules/path-exists": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
||||
"integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss-value-parser": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz",
|
||||
|
@ -14371,8 +14491,7 @@
|
|||
"node_modules/querystringify": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||
},
|
||||
"node_modules/queue": {
|
||||
"version": "6.0.2",
|
||||
|
@ -15212,7 +15331,12 @@
|
|||
"node_modules/requires-port": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
||||
},
|
||||
"node_modules/reselect": {
|
||||
"version": "4.1.8",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.8.tgz",
|
||||
"integrity": "sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
|
@ -15521,6 +15645,11 @@
|
|||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/setimmediate": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA=="
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
|
@ -16185,18 +16314,27 @@
|
|||
"integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg=="
|
||||
},
|
||||
"node_modules/tough-cookie": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
|
||||
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
|
||||
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
|
||||
"dependencies": {
|
||||
"psl": "^1.1.33",
|
||||
"punycode": "^2.1.1",
|
||||
"universalify": "^0.1.2"
|
||||
"universalify": "^0.2.0",
|
||||
"url-parse": "^1.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/tough-cookie/node_modules/universalify": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
||||
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
|
@ -16512,7 +16650,6 @@
|
|||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
|
||||
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"querystringify": "^2.1.1",
|
||||
"requires-port": "^1.0.0"
|
||||
|
|
|
@ -59,7 +59,8 @@
|
|||
"react-native-webview": "^13.6.0",
|
||||
"react-redux": "^8.1.2",
|
||||
"redux": "^4.2.1",
|
||||
"tough-cookie": "4.0.0",
|
||||
"setimmediate": "^1.0.5",
|
||||
"tough-cookie": "4.1.3",
|
||||
"tslib": "^2.6.2",
|
||||
"valtio": "^1.11.2",
|
||||
"yup": "^1.3.1"
|
||||
|
@ -81,6 +82,7 @@
|
|||
"@types/react": "^18.0.24",
|
||||
"@types/react-test-renderer": "^18.0.0",
|
||||
"babel-jest": "^29.7.0",
|
||||
"babel-plugin-module-resolver": "^5.0.0",
|
||||
"eslint": "^8.19.0",
|
||||
"esm": "^3.2.25",
|
||||
"jest": "^29.2.1",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { User } from '../../libs/api/lib'
|
||||
import { User } from '@skolplattformen/api'
|
||||
import AppStorage from '../appStorage'
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { User } from '../libs/api/lib'
|
||||
import { User } from '@skolplattformen/api'
|
||||
|
||||
export default class AppStorage {
|
||||
static settingsStorageKeyPrefix = 'appsetting_'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extends": "@tsconfig/react-native/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@skolplattformen/api": ["libs/api/lib/index.ts"],
|
||||
"@skolplattformen/api-hjarntorget": ["libs/api-hjarntorget/lib/index.ts"],
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Guardian } from '../libs/api/lib'
|
||||
import { Guardian } from '@skolplattformen/api'
|
||||
|
||||
export const studentName = (name?: string) => name?.replace(/\s?\(\w+\)$/, '')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { NewsItem } from '../libs/api/lib'
|
||||
import { NewsItem } from '@skolplattformen/api'
|
||||
import { useNews } from '../libs/hooks/src'
|
||||
import { MatchData, Searcher } from 'fast-fuzzy'
|
||||
import React, { ReactNode, useMemo } from 'react'
|
||||
|
|
|
@ -2596,6 +2596,17 @@ babel-plugin-jest-hoist@^29.6.3:
|
|||
"@types/babel__core" "^7.1.14"
|
||||
"@types/babel__traverse" "^7.0.6"
|
||||
|
||||
babel-plugin-module-resolver@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.0.tgz"
|
||||
integrity sha512-g0u+/ChLSJ5+PzYwLwP8Rp8Rcfowz58TJNCe+L/ui4rpzE/mg//JVX0EWBUYoxaextqnwuGHzfGp2hh0PPV25Q==
|
||||
dependencies:
|
||||
find-babel-config "^2.0.0"
|
||||
glob "^8.0.3"
|
||||
pkg-up "^3.1.0"
|
||||
reselect "^4.1.7"
|
||||
resolve "^1.22.1"
|
||||
|
||||
babel-plugin-polyfill-corejs2@^0.4.5, babel-plugin-polyfill-corejs2@^0.4.6:
|
||||
version "0.4.6"
|
||||
resolved "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.6.tgz"
|
||||
|
@ -2730,6 +2741,13 @@ brace-expansion@^1.1.7:
|
|||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
brace-expansion@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz"
|
||||
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
|
||||
braces@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz"
|
||||
|
@ -4140,6 +4158,14 @@ finalhandler@1.1.2:
|
|||
statuses "~1.5.0"
|
||||
unpipe "~1.0.0"
|
||||
|
||||
find-babel-config@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.npmjs.org/find-babel-config/-/find-babel-config-2.0.0.tgz"
|
||||
integrity sha512-dOKT7jvF3hGzlW60Gc3ONox/0rRZ/tz7WCil0bqA1In/3I8f1BctpXahRnEKDySZqci7u+dqq93sZST9fOJpFw==
|
||||
dependencies:
|
||||
json5 "^2.1.1"
|
||||
path-exists "^4.0.0"
|
||||
|
||||
find-cache-dir@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz"
|
||||
|
@ -4360,6 +4386,17 @@ glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.5:
|
|||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@^8.0.3:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz"
|
||||
integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^5.0.1"
|
||||
once "^1.3.0"
|
||||
|
||||
globals@^11.1.0:
|
||||
version "11.12.0"
|
||||
resolved "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz"
|
||||
|
@ -5596,7 +5633,7 @@ json-stringify-safe@~5.0.1:
|
|||
resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz"
|
||||
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==
|
||||
|
||||
json5@^2.2.3:
|
||||
json5@^2.1.1, json5@^2.2.3:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz"
|
||||
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||
|
@ -6171,6 +6208,13 @@ minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatc
|
|||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimatch@^5.0.1:
|
||||
version "5.1.6"
|
||||
resolved "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz"
|
||||
integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==
|
||||
dependencies:
|
||||
brace-expansion "^2.0.1"
|
||||
|
||||
minimist@^1.2.6:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz"
|
||||
|
@ -6694,6 +6738,13 @@ pkg-dir@^4.2.0:
|
|||
dependencies:
|
||||
find-up "^4.0.0"
|
||||
|
||||
pkg-up@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz"
|
||||
integrity sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==
|
||||
dependencies:
|
||||
find-up "^3.0.0"
|
||||
|
||||
postcss-value-parser@^4.0.2:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz"
|
||||
|
@ -7310,6 +7361,11 @@ requires-port@^1.0.0:
|
|||
resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz"
|
||||
integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==
|
||||
|
||||
reselect@^4.1.7:
|
||||
version "4.1.8"
|
||||
resolved "https://registry.npmjs.org/reselect/-/reselect-4.1.8.tgz"
|
||||
integrity sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==
|
||||
|
||||
resolve-cwd@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz"
|
||||
|
@ -7337,7 +7393,7 @@ resolve.exports@^2.0.0:
|
|||
resolved "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz"
|
||||
integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==
|
||||
|
||||
resolve@^1.10.0, resolve@^1.14.2, resolve@^1.20.0:
|
||||
resolve@^1.10.0, resolve@^1.14.2, resolve@^1.20.0, resolve@^1.22.1:
|
||||
version "1.22.6"
|
||||
resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz"
|
||||
integrity sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==
|
||||
|
@ -7551,6 +7607,11 @@ set-function-name@^2.0.0, set-function-name@^2.0.1:
|
|||
functions-have-names "^1.2.3"
|
||||
has-property-descriptors "^1.0.0"
|
||||
|
||||
setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz"
|
||||
integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
|
||||
|
||||
setprototypeof@1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz"
|
||||
|
@ -8029,7 +8090,7 @@ toposort@^2.0.2:
|
|||
resolved "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz"
|
||||
integrity sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==
|
||||
|
||||
tough-cookie@^4.1.2:
|
||||
tough-cookie@^4.1.2, tough-cookie@4.1.3:
|
||||
version "4.1.3"
|
||||
resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz"
|
||||
integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==
|
||||
|
@ -8047,15 +8108,6 @@ tough-cookie@~2.5.0:
|
|||
psl "^1.1.28"
|
||||
punycode "^2.1.1"
|
||||
|
||||
tough-cookie@4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz"
|
||||
integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==
|
||||
dependencies:
|
||||
psl "^1.1.33"
|
||||
punycode "^2.1.1"
|
||||
universalify "^0.1.2"
|
||||
|
||||
tr46@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz"
|
||||
|
@ -8232,7 +8284,7 @@ unicode-trie@^2.0.0:
|
|||
pako "^0.2.5"
|
||||
tiny-inflate "^1.0.0"
|
||||
|
||||
universalify@^0.1.0, universalify@^0.1.2:
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
|
Loading…
Reference in New Issue