-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1c483d
commit e22ebb7
Showing
25 changed files
with
229 additions
and
920 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { randomNumber } from '../../helpers/' | ||
|
||
jest.mock('axios') | ||
describe('helpers:randomNumber', () => { | ||
it('must return a number less than 5', async () => { | ||
const response = randomNumber(5) | ||
expect(response < 5).toBeTruthy() | ||
}) | ||
|
||
it('must be greater than 0', async () => { | ||
const response = randomNumber(0) | ||
expect(response > 0).toBeTruthy() | ||
}) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import mongoose from 'mongoose' | ||
|
||
import Book from '../models/book' | ||
import Request from '../models/request' | ||
import User from '../models/user' | ||
import Verse from '../models/verse' | ||
import books from './mock/books' | ||
import verses from './mock/verses' | ||
|
||
export const connect = async () => { | ||
return mongoose.connect('mongodb://localhost/bibleapi_test', { | ||
useNewUrlParser: true, | ||
useCreateIndex: true, | ||
useUnifiedTopology: true | ||
}) | ||
} | ||
|
||
const createBooks = async () => { | ||
const promises = books.map(async book => new Book(book).save()) | ||
return Promise.all(promises) | ||
} | ||
|
||
const createVerses = async (books) => { | ||
const bookByKey = {} | ||
await books.map(book => { | ||
bookByKey[book.abbrev.en] = book | ||
}) | ||
|
||
const promises = verses.map(async verse => { | ||
verse.book = { | ||
id: bookByKey[verse.book.abbrev.en]._id, | ||
abbrev: bookByKey[verse.book.abbrev.en].abbrev | ||
} | ||
return new Verse(verse).save() | ||
}) | ||
return Promise.all(promises) | ||
} | ||
|
||
const createUser = async () => { | ||
return new User({ | ||
token: '1234567890', | ||
name: 'Fake User', | ||
email: '[email protected]', | ||
password: '123456', | ||
notifications: false | ||
}).save() | ||
} | ||
|
||
export const initDatabase = async () => { | ||
const connection = await connect() | ||
await User.deleteMany() | ||
await Book.deleteMany() | ||
await Verse.deleteMany() | ||
await Request.deleteMany() | ||
const books = await createBooks() | ||
await createVerses(books) | ||
await createUser() | ||
connection.disconnect() | ||
} | ||
|
||
initDatabase() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"abbrev":{"pt":"tg","en":"jm"},"name":"Tiago","chapters":5},{"abbrev":{"pt":"1pe","en":"1pe"},"name":"1 Pedro","chapters":5},{"abbrev":{"pt":"2pe","en":"2pe"},"name":"2 Pedro","chapters":3},{"abbrev":{"pt":"1jo","en":"1jo"},"name":"1 João","chapters":5},{"abbrev":{"pt":"2jo","en":"2jo"},"name":"2 João","chapters":1},{"abbrev":{"pt":"3jo","en":"3jo"},"name":"3 João","chapters":1},{"abbrev":{"pt":"jd","en":"jd"},"name":"Judas","chapters":1},{"abbrev":{"pt":"ap","en":"re"},"name":"Apocalipse","chapters":22}] |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.