-
-
Notifications
You must be signed in to change notification settings - Fork 495
/
GH4065.test.ts
29 lines (22 loc) · 878 Bytes
/
GH4065.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { MikroORM } from '@mikro-orm/mongodb';
import { Author, Book } from '../entities';
import { closeReplSets, initORMMongo } from '../bootstrap';
describe('GH4065', () => {
let orm: MikroORM;
beforeAll(async () => orm = await initORMMongo(true));
beforeEach(async () => orm.schema.clearDatabase());
afterAll(async () => {
await orm.close();
await closeReplSets();
});
test('should load entities with $fulltext and filter set', async () => {
const god = new Author('God', 'hello@heaven.god');
const bible = new Book('Bible', god);
await orm.em.persistAndFlush(bible);
orm.em.clear();
const booksRepository = orm.em.getRepository(Book);
orm.em.addFilter('BreakFulltext', { title: { $re: '.*' } }, Book, true);
const books = await booksRepository.find({ $fulltext: 'Bible' });
expect(books.length).toBe(1);
});
});