Skip to content

Commit

Permalink
chore: remove useless as
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jan 11, 2025
1 parent c162a36 commit 1ee8279
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"devDependencies": {
"@types/bluebird": "^3.5.37",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^8.0.1",
"@types/graceful-fs": "^4.1.5",
"@types/jsonstream": "^0.8.30",
"@types/mocha": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Database', () => {
const model = db.model('Test');
const json = db.toJSON();
json.meta.version.should.eql(0);
(json.models as any).Test.should.eql(model);
json.models.Test.should.eql(model);
console.log(db.toJSON());
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Document', () => {
const doc = User.new({});

return doc.save().then(item => {
User.findById(doc._id as string | number).should.exist;
User.findById(doc._id).should.exist;
return User.removeById(item._id);
});
});
Expand Down
21 changes: 10 additions & 11 deletions test/scripts/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import Promise from 'bluebird';
import sinon from 'sinon';
import { nanoid } from 'nanoid';
import Database from '../../src/database';
import type Query from '../../src/query';
import type Document from '../../src/document';
import type Model from '../../src/model';

interface UserType {
Expand Down Expand Up @@ -124,18 +122,19 @@ describe('Model', () => {

it('insert() - no id', () => {
const doc = User.new();
// @ts-ignore
delete doc._id;

return (User.insert(doc) as any).should.eventually.be.rejected;
return User.insert(doc).should.eventually.be.rejected;
});

it('insert() - already existed', () => {
let user;

return (User.insert({}).then(data => {
return User.insert({}).then(data => {
user = data;
return User.insert(data);
}).finally(() => User.removeById(user._id)) as any).should.eventually.be.rejected;
}).finally(() => User.removeById(user._id)).should.eventually.be.rejected;
});

it('insert() - hook', () => {
Expand Down Expand Up @@ -329,7 +328,7 @@ describe('Model', () => {
return data;
}).then(data => User.removeById(data._id)));

it('updateById() - id not exist', () => (User.updateById('foo', {}) as any).should.eventually.be.rejected);
it('updateById() - id not exist', () => User.updateById('foo', {}).should.eventually.be.rejected);

it('updateById() - hook', () => {
const db = new Database();
Expand Down Expand Up @@ -399,7 +398,7 @@ describe('Model', () => {
}).then(data => User.removeById(data._id));
});

it('replaceById() - id not exist', () => (User.replaceById('foo', {}) as any).should.eventually.be.rejected);
it('replaceById() - id not exist', () => User.replaceById('foo', {}).should.eventually.be.rejected);

it('replaceById() - pre-hook', () => {
const db = new Database();
Expand Down Expand Up @@ -458,7 +457,7 @@ describe('Model', () => {
});
});

it('removeById() - id not exist', () => (User.removeById('foo', () => {}) as any).should.eventually.be.rejected);
it('removeById() - id not exist', () => User.removeById('foo', () => {}).should.eventually.be.rejected);

it('removeById() - hook', () => {
const db = new Database();
Expand Down Expand Up @@ -555,7 +554,7 @@ describe('Model', () => {
{age: 30},
{age: 40}
]).then(data => {
const query = User.find({age: {$gt: 20}}) as Query<UserType>;
const query = User.find({age: {$gt: 20}});
query.data.should.eql(data.slice(2));
return data;
}).map<unknown, any>(item => User.removeById(item._id)));
Expand Down Expand Up @@ -695,7 +694,7 @@ describe('Model', () => {
{age: 30},
{age: 40}
]).then(data => {
(User.findOne({age: {$gt: 20}}, {lean: true}) as Document<UserType>)._id!.should.eql(data[2]._id);
(User.findOne({age: {$gt: 20}}, {lean: true}) as UserType & { _id: string })._id.should.eql(data[2]._id);
return data;
}).map<unknown, any>(item => User.removeById(item._id)));

Expand Down Expand Up @@ -1259,7 +1258,7 @@ describe('Model', () => {

const Test = db.model('Test', schema);

(Test as any).add({name: 'foo'}).then(data => {
Test.add({name: 'foo'}).then(data => {
data.name.should.eql('foo');
});

Expand Down

0 comments on commit 1ee8279

Please sign in to comment.