Skip to content

Commit

Permalink
added unit test
Browse files Browse the repository at this point in the history
testing fix

testing fix 2
  • Loading branch information
aditi-khare-mongoDB committed Mar 19, 2024
1 parent e292a79 commit c9c1dd2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/mongo_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export type PullAllOperator<TSchema> = ({
export type UpdateFilter<TSchema> = {
$currentDate?: OnlyFieldsOfType<
TSchema,
Date | Timestamp,
Date | Timestamp | true,
true | { $type: 'date' | 'timestamp' }
>;
$inc?: OnlyFieldsOfType<TSchema, NumericType | undefined>;
Expand Down
37 changes: 36 additions & 1 deletion test/integration/crud/find_and_modify.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { expect } from 'chai';

import { type CommandStartedEvent, MongoServerError, ObjectId } from '../../mongodb';
import {
type Collection,
type CommandStartedEvent,
type Db,
MongoServerError,
ObjectId
} from '../../mongodb';
import { setupDatabase } from '../shared';

describe('Collection (#findOneAnd...)', function () {
Expand Down Expand Up @@ -324,6 +330,35 @@ describe('Collection (#findOneAnd...)', function () {
});
});
});

describe('update filter', function () {
context('when $currentDate is provided', function () {
let client;
let db: Db;
let collection: Collection;

beforeEach(async function () {
client = this.configuration.newClient({ w: 1 });
await client.connect();
db = client.db(this.configuration.db);
collection = db.collection('test_coll');
await collection.insertOne({ a: 'c' });
});

afterEach(async function () {
await collection.drop();
await client.close();
});

it(`should support fields with value 'true'`, async function () {
await collection.findOneAndUpdate(
{},
{ $set: { a: 1 }, $currentDate: { lastModified: true } },
{ writeConcern: { w: 1 } }
);
});
});
});
});

describe('#findOneAndReplace', function () {
Expand Down

0 comments on commit c9c1dd2

Please sign in to comment.