Skip to content

Commit

Permalink
feat(Mocker.seed): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danibram committed May 13, 2020
1 parent dfb2ad6 commit 7faafab
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/lib/tests/Mocker.seed.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import test from 'ava'
import mocker, { Mocker } from '../../'

const cats = [
{
name: 'Luke'
},
{
name: 'Leia'
}
]

const mock = new Mocker()

test('Should seed data', async (t) => {
t.true(Object.keys(mock.DB).length === 0)
mock.seed('cats', cats)
t.true(Object.keys(mock.DB).length > 0)
t.deepEqual(mock.DB.cats, cats)
})

test('Should merge data from seed', async (t) => {
const mock = await mocker()
.seed('cats', cats)
.schema(
'cats',
{
name: {
values: ['txuri', 'pitxi', 'kitty']
}
},
1
)
.build()

console.log(mock)

t.true(mock.cats.length === 3)
})

0 comments on commit 7faafab

Please sign in to comment.