fix(doc): Refactor searchable fields API and improve collection registration.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import * as smartmongo from '@push.rocks/smartmongo';
|
||||
import * as smartdata from '../ts/index.js';
|
||||
import { searchable, getSearchableFields } from '../ts/classes.doc.js';
|
||||
import { searchable } from '../ts/classes.doc.js';
|
||||
import { smartunique } from '../ts/plugins.js';
|
||||
|
||||
// Set up database connection
|
||||
|
@ -4,7 +4,7 @@ import { smartunique } from '../ts/plugins.js';
|
||||
|
||||
// Import the smartdata library
|
||||
import * as smartdata from '../ts/index.js';
|
||||
import { searchable, getSearchableFields } from '../ts/classes.doc.js';
|
||||
import { searchable } from '../ts/classes.doc.js';
|
||||
|
||||
// Set up database connection
|
||||
let smartmongoInstance: smartmongo.SmartMongo;
|
||||
@ -72,7 +72,7 @@ tap.test('should create test products with searchable fields', async () => {
|
||||
|
||||
tap.test('should retrieve searchable fields for a class', async () => {
|
||||
// Use the getSearchableFields function to verify our searchable fields
|
||||
const searchableFields = getSearchableFields('Product');
|
||||
const searchableFields = Product.getSearchableFields();
|
||||
console.log('Searchable fields:', searchableFields);
|
||||
|
||||
expect(searchableFields.length).toEqual(3);
|
||||
|
@ -64,7 +64,11 @@ tap.test('should watch a collection', async (toolsArg) => {
|
||||
// close the database connection
|
||||
// =======================================
|
||||
tap.test('close', async () => {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
try {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
} catch (err) {
|
||||
console.warn('dropDatabase error ignored in cleanup:', err.message || err);
|
||||
}
|
||||
await testDb.close();
|
||||
if (smartmongoInstance) {
|
||||
await smartmongoInstance.stop();
|
||||
|
Reference in New Issue
Block a user