Consolidate mocks, fix tests
This commit is contained in:
@@ -105,3 +105,19 @@ jest.mock('expo-modules-core', () => ({
|
|||||||
return () => null
|
return () => null
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
jest.mock('expo-localization', () => ({
|
||||||
|
getLocales: () => [],
|
||||||
|
}))
|
||||||
|
|
||||||
|
jest.mock('statsig-react-native-expo', () => ({
|
||||||
|
Statsig: {
|
||||||
|
initialize() {},
|
||||||
|
initializeCalled() {
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
jest.mock('../src/lib/bitdrift', () => ({}))
|
||||||
|
jest.mock('../src/lib/statsig/statsig', () => ({}))
|
||||||
|
|||||||
+12
-14
@@ -6,18 +6,16 @@ import {initPromise} from './statsig/statsig'
|
|||||||
|
|
||||||
const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY
|
const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
initPromise.then(() => {
|
||||||
initPromise.then(() => {
|
let isEnabled = false
|
||||||
let isEnabled = false
|
try {
|
||||||
try {
|
if (Statsig.checkGate('enable_bitdrift')) {
|
||||||
if (Statsig.checkGate('enable_bitdrift')) {
|
isEnabled = true
|
||||||
isEnabled = true
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Statsig may complain about it being called too early.
|
|
||||||
}
|
}
|
||||||
if (isEnabled && BITDRIFT_API_KEY) {
|
} catch (e) {
|
||||||
init(BITDRIFT_API_KEY, {url: 'https://api-bsky.bitdrift.io'})
|
// Statsig may complain about it being called too early.
|
||||||
}
|
}
|
||||||
})
|
if (isEnabled && BITDRIFT_API_KEY) {
|
||||||
}
|
init(BITDRIFT_API_KEY, {url: 'https://api-bsky.bitdrift.io'})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
@@ -4,25 +4,12 @@ import {describe, expect, it, jest} from '@jest/globals'
|
|||||||
import {agentToSessionAccountOrThrow} from '../agent'
|
import {agentToSessionAccountOrThrow} from '../agent'
|
||||||
import {Action, getInitialState, reducer, State} from '../reducer'
|
import {Action, getInitialState, reducer, State} from '../reducer'
|
||||||
|
|
||||||
jest.mock('statsig-react-native-expo', () => ({
|
|
||||||
Statsig: {
|
|
||||||
initialize() {},
|
|
||||||
initializeCalled() {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
jest.mock('jwt-decode', () => ({
|
jest.mock('jwt-decode', () => ({
|
||||||
jwtDecode(_token: string) {
|
jwtDecode(_token: string) {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
jest.mock('expo-localization', () => ({
|
|
||||||
getLocales: () => [],
|
|
||||||
}))
|
|
||||||
|
|
||||||
describe('session', () => {
|
describe('session', () => {
|
||||||
it('can log in and out', () => {
|
it('can log in and out', () => {
|
||||||
let state = getInitialState([])
|
let state = getInitialState([])
|
||||||
|
|||||||
Reference in New Issue
Block a user