mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
Move usermethods and models to data-schema
This commit is contained in:
parent
4808c5be48
commit
4049b5572c
93 changed files with 2396 additions and 1267 deletions
|
|
@ -3,18 +3,22 @@ const { MongoMemoryServer } = require('mongodb-memory-server');
|
|||
const { spendTokens, spendStructuredTokens } = require('./spendTokens');
|
||||
const { getBalanceConfig } = require('~/server/services/Config');
|
||||
const { getMultiplier, getCacheMultiplier } = require('./tx');
|
||||
const { Transaction } = require('./Transaction');
|
||||
const Balance = require('./Balance');
|
||||
const db = require('~/lib/db/connectDb');
|
||||
const { createTransaction } = require('./Transaction');
|
||||
|
||||
// Mock the custom config module so we can control the balance flag.
|
||||
jest.mock('~/server/services/Config');
|
||||
|
||||
let mongoServer;
|
||||
|
||||
let Balance;
|
||||
let Transaction;
|
||||
beforeAll(async () => {
|
||||
mongoServer = await MongoMemoryServer.create();
|
||||
const mongoUri = mongoServer.getUri();
|
||||
await mongoose.connect(mongoUri);
|
||||
await db.connectDb(mongoUri);
|
||||
|
||||
Balance = db.models.Balance;
|
||||
Transaction = db.models.Transaction;
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
|
@ -368,7 +372,7 @@ describe('NaN Handling Tests', () => {
|
|||
};
|
||||
|
||||
// Act
|
||||
const result = await Transaction.create(txData);
|
||||
const result = await createTransaction(txData);
|
||||
|
||||
// Assert: No transaction should be created and balance remains unchanged.
|
||||
expect(result).toBeUndefined();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue