Skip to content

Commit

Permalink
fix: 馃悰 Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorlarsson committed Oct 15, 2021
1 parent 143c3ee commit d451cf1
Show file tree
Hide file tree
Showing 14 changed files with 747 additions and 322 deletions.
1 change: 1 addition & 0 deletions apps/skolplattformen-sthlm/.eslintrc.json
@@ -1,4 +1,5 @@
{
"parser": "@babel/eslint-parser",
"extends": [
"@react-native-community",
"plugin:react-native-a11y/all",
Expand Down
1 change: 1 addition & 0 deletions apps/skolplattformen-sthlm/babel.config.js
@@ -1,3 +1,4 @@
module.exports = {
plugins: ['jest-hoist'],
presets: ['module:metro-react-native-babel-preset'],
}
Expand Up @@ -8,9 +8,15 @@ import { useSMS } from '../../utils/SMS'
import { render } from '../../utils/testHelpers'
import Absence from '../absence.component'

jest.mock('../../utils/SMS')
jest.mock('@skolplattformen/hooks')

let sendSMS
let user = { personalNumber: '201701092395' }




const setup = (customProps = {}) => {
sendSMS = jest.fn()

Expand Down
2 changes: 2 additions & 0 deletions apps/skolplattformen-sthlm/components/__tests__/Auth.test.js
Expand Up @@ -3,6 +3,8 @@ import React from 'react'
import { render } from '../../utils/testHelpers'
import { Auth } from '../auth.component'

jest.mock('@skolplattformen/hooks')

const setup = () => {
useApi.mockReturnValue({
api: { on: jest.fn(), off: jest.fn() },
Expand Down
Expand Up @@ -16,6 +16,8 @@ import { render } from '../../utils/testHelpers'
import { translate } from '../../utils/translation'
import { Children } from '../children.component'

jest.mock('@skolplattformen/hooks')

const setup = () => {
return render(<Children />)
}
Expand Down
Expand Up @@ -4,6 +4,8 @@ import { render } from '../../utils/testHelpers'
import { ChildProvider } from '../childContext.component'
import { Classmates } from '../classmates.component'

jest.mock('@skolplattformen/hooks')

const defaultClassmates = [
{
className: '2B',
Expand Down
Expand Up @@ -4,7 +4,6 @@ import { Linking } from 'react-native'
import { render } from '../../utils/testHelpers'
import { ContactMenu } from '../contactMenu.component'


const defaultGuardian = {
address: 'Testgatan',
email: 'adam@adamsson.se',
Expand Down
2 changes: 2 additions & 0 deletions apps/skolplattformen-sthlm/components/__tests__/Menu.test.js
Expand Up @@ -4,6 +4,8 @@ import { render } from '../../utils/testHelpers'
import { translate } from '../../utils/translation'
import { Menu } from '../menu.component'

jest.mock('@skolplattformen/hooks')

const defaultItemList = [
{
title: 'M氓ndag vecka 10',
Expand Down
Expand Up @@ -3,6 +3,8 @@ import React from 'react'
import { render } from '../../utils/testHelpers'
import { NewsItem } from '../newsItem.component'

jest.mock('@skolplattformen/hooks')

const defaultNewsItem = {
author: 'K枚ket',
fullImageUrl: 'test.png',
Expand Down
Expand Up @@ -5,6 +5,17 @@ import Toast from 'react-native-simple-toast'
import { render } from '../../utils/testHelpers'
import { SaveToCalendar } from '../saveToCalendar.component'

jest.mock('react-native-simple-toast', () => ({
SHORT: 'short',
BOTTOM: 'bottom',
showWithGravity: jest.fn(),
}))

jest.mock('react-native-calendar-events', () => ({
saveEvent: jest.fn().mockResolvedValue('52'),
requestPermissions: jest.fn().mockResolvedValue('authorized'),
}))

const defaultEvent = {
title: 'Utvecklingssamtal',
startDate: '2021-06-19 13:00',
Expand Down
Expand Up @@ -20,6 +20,7 @@ import { defaultStackStyling } from '../design/navigationThemes'
import usePersonalStorage from '../hooks/usePersonalStorage'
import { Layout as LayoutStyle, Sizing, Typography } from '../styles'
import { studentName } from '../utils/peopleHelpers'
// @ts-expect-error Fix when migrating to TSX
import { useSMS } from '../utils/SMS'
import { translate } from '../utils/translation'
import { AlertIcon } from './icon.component'
Expand Down
13 changes: 0 additions & 13 deletions apps/skolplattformen-sthlm/test-setup.ts
Expand Up @@ -21,14 +21,12 @@ jest.mock('react-native-reanimated', () => {
return Reanimated
})

jest.mock('@skolplattformen/hooks')
jest.mock('@react-navigation/native')
jest.mock('@react-navigation/core')
jest.mock('react-native-localize')
jest.mock("react-native/Libraries/Linking/Linking", () => ({
openURL: jest.fn(() => Promise.resolve("mockResolve")),
}))

jest.mock('react-native', () => {
const RN = jest.requireActual('react-native')

Expand All @@ -38,14 +36,3 @@ jest.mock('react-native', () => {

return RN
})

jest.mock('react-native-simple-toast', () => ({
SHORT: 'short',
BOTTOM: 'bottom',
showWithGravity: jest.fn(),
}))

jest.mock('react-native-calendar-events', () => ({
saveEvent: jest.fn().mockResolvedValue('52'),
requestPermissions: jest.fn().mockResolvedValue('authorized'),
}))
11 changes: 7 additions & 4 deletions package.json
Expand Up @@ -8,6 +8,7 @@
"android": "nx run-android",
"build": "nx build",
"test": "nx test",
"lint": "nx lint",
"extract-licenses": "react-native-oss-license --json > licenses-oss.json && node library-extractor.js && rm licenses-oss.json && mv libraries.json apps/skolplattformen-sthlm",
"postinstall": "yarn extract-licenses"
},
Expand Down Expand Up @@ -70,6 +71,8 @@
"yup": "0.32.9"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/eslint-parser": "^7.15.8",
"@nrwl/cli": "12.9.0",
"@nrwl/detox": "12.9.0",
"@nrwl/eslint-plugin-nx": "12.9.0",
Expand Down Expand Up @@ -104,9 +107,9 @@
"@typescript-eslint/eslint-plugin": "~4.28.3",
"@typescript-eslint/parser": "~4.28.3",
"@ui-kitten/metro-config": "^5.1.1",
"babel-jest": "27.0.6",
"babel-jest": "^27.2.5",
"detox": "18.20.2",
"eslint": "7.22.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsx-a11y": "6.4.1",
Expand All @@ -115,8 +118,8 @@
"eslint-plugin-react-native-a11y": "^2.0.4",
"fetch-cookie": "^0.11.0",
"https-proxy-agent": "^5.0.0",
"jest": "27.0.3",
"jest-circus": "27.0.3",
"jest": "^27.2.5",
"jest-circus": "^27.2.5",
"jest-react-native": "18.0.0",
"metro": "0.66.2",
"metro-react-native-babel-preset": "0.66.2",
Expand Down

0 comments on commit d451cf1

Please sign in to comment.