Last active
November 16, 2018 03:09
-
-
Save YuriGor/92ea4c21e92e84a15a7e8925c2ec6bcf to your computer and use it in GitHub Desktop.
Example of mongoDb test for builderbook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /test/server/models/User.test.js | |
// see https://github.com/vladgolubev/jest-mongodb for preparing in-memory mongoDB for this test. | |
const mongoose = require('mongoose'); | |
const User = require('../../../server/models/User'); | |
describe('slugify', () => { | |
beforeAll(async () => { | |
await mongoose.connect(global.__MONGO_URI__); | |
console.log('connected'); | |
}); | |
afterAll(async () => { | |
await mongoose.disconnect(); | |
console.log('disconnected'); | |
}); | |
test('no duplication', async () => { | |
expect.assertions(1); | |
await User.remove(); | |
const user = await User.signInOrSignUp({ | |
googleId: 'test1', | |
email: '[email protected]', | |
googleToken: { accessToken: 'test1', refreshToken: 'test1' }, | |
displayName: 'Test Name', | |
avatarUrl: 'test1', | |
}); | |
expect(user.slug).toBe('test-name'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment