You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
830 B
33 lines
830 B
import { Filter } from 'adminjs'
|
|
import { factory } from 'factory-girl'
|
|
import Resource from '../../src/resource'
|
|
import { User } from '../utils/models'
|
|
|
|
|
|
describe('Resource #count', () => {
|
|
let resource
|
|
|
|
beforeEach(() => {
|
|
resource = new Resource(User)
|
|
})
|
|
|
|
it('returns given count without filters', async () => {
|
|
const NUMBER_OF_RECORDS = 12
|
|
await factory.createMany('user', NUMBER_OF_RECORDS)
|
|
|
|
const countedRecords = await resource.count(new Filter({}, resource))
|
|
|
|
expect(countedRecords).toEqual(NUMBER_OF_RECORDS)
|
|
})
|
|
|
|
it('returns given count for given filters', async () => {
|
|
const filterOutAllRecords = new Filter({
|
|
email: 'some-not-existing-email',
|
|
}, resource)
|
|
|
|
const counterRecords = await resource.count(filterOutAllRecords)
|
|
|
|
expect(counterRecords).toEqual(0)
|
|
})
|
|
})
|