add global hooks
This commit is contained in:
@ -2,6 +2,6 @@
|
||||
"extension": ["ts"],
|
||||
"spec": "test/**/*.test.ts",
|
||||
"reporter": "mocha-unfunk-reporter",
|
||||
"require": ["test/global-setup.ts", "test/global-teardown.ts"],
|
||||
"require": ["test/global-setup.ts", "test/global-teardown.ts", "test/hooks.ts"],
|
||||
"timeout": 10000
|
||||
}
|
||||
|
||||
15
packages/api/test/hooks.ts
Normal file
15
packages/api/test/hooks.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Storage } from '@google-cloud/storage'
|
||||
import sinon from 'sinon'
|
||||
import * as uploads from '../src/utils/uploads'
|
||||
import { MockStorage } from './mock_storage'
|
||||
|
||||
export const mochaHooks = {
|
||||
beforeEach() {
|
||||
// Mock cloud storage
|
||||
sinon
|
||||
.stub(uploads, 'storage')
|
||||
.value(new MockStorage() as unknown as Storage)
|
||||
|
||||
console.log('mock cloud storage created')
|
||||
},
|
||||
}
|
||||
@ -159,12 +159,14 @@ describe('features resolvers', () => {
|
||||
})
|
||||
|
||||
context('when user is already opted in', () => {
|
||||
const grantedAt = new Date('2024-05-15')
|
||||
|
||||
before(async () => {
|
||||
// opt in
|
||||
await createFeature({
|
||||
user: { id: loginUser.id },
|
||||
name: featureName,
|
||||
grantedAt: new Date(),
|
||||
grantedAt,
|
||||
})
|
||||
})
|
||||
|
||||
@ -182,7 +184,7 @@ describe('features resolvers', () => {
|
||||
{
|
||||
uid: loginUser.id,
|
||||
featureName,
|
||||
grantedAt: Date.now() / 1000,
|
||||
grantedAt: grantedAt.getTime() / 1000,
|
||||
},
|
||||
env.server.jwtSecret,
|
||||
{ expiresIn: '1y' }
|
||||
@ -191,7 +193,7 @@ describe('features resolvers', () => {
|
||||
expect(res.body.data.optInFeature).to.eql({
|
||||
feature: {
|
||||
name: featureName,
|
||||
grantedAt: new Date().toISOString(),
|
||||
grantedAt: grantedAt.toISOString(),
|
||||
token,
|
||||
},
|
||||
})
|
||||
|
||||
@ -36,7 +36,7 @@ describe('Subscriptions API', () => {
|
||||
.post('/local/debug/fake-user-login')
|
||||
.send({ fakeEmail: user.email })
|
||||
|
||||
authToken = res.body.authToken
|
||||
authToken = res.body.authToken as string
|
||||
|
||||
// create test newsletter subscriptions
|
||||
const newsletterEmail = await createNewsletterEmail(user.id)
|
||||
@ -181,7 +181,7 @@ describe('Subscriptions API', () => {
|
||||
}))
|
||||
)
|
||||
} finally {
|
||||
deleteUser(user2.id)
|
||||
await deleteUser(user2.id)
|
||||
}
|
||||
})
|
||||
|
||||
@ -222,7 +222,7 @@ describe('Subscriptions API', () => {
|
||||
}))
|
||||
)
|
||||
} finally {
|
||||
deleteUser(user3.id)
|
||||
await deleteUser(user3.id)
|
||||
}
|
||||
})
|
||||
|
||||
@ -263,7 +263,7 @@ describe('Subscriptions API', () => {
|
||||
}))
|
||||
)
|
||||
} finally {
|
||||
deleteUser(user2.id)
|
||||
await deleteUser(user2.id)
|
||||
}
|
||||
})
|
||||
|
||||
@ -372,7 +372,7 @@ describe('Subscriptions API', () => {
|
||||
const url = 'https://www.omnivore.app/rss'
|
||||
const subscriptionType = SubscriptionType.Rss
|
||||
|
||||
before(async () => {
|
||||
before(() => {
|
||||
// fake rss parser
|
||||
sinon.replace(
|
||||
Parser.prototype,
|
||||
|
||||
Reference in New Issue
Block a user