Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
harryadel committed Jan 8, 2024
1 parent 0845154 commit 3f6a3c4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/collection2.tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect';
import { Mongo } from 'meteor/mongo';
import SimpleSchema from "meteor/aldeed:simple-schema";
import SimpleSchema from 'meteor/aldeed:simple-schema';
import addMultiTests from './multi.tests.js';
import addBooksTests from './books.tests.js';
import addContextTests from './context.tests.js';
Expand Down Expand Up @@ -669,6 +669,21 @@ describe('collection2', function () {
expect(doc2.bar).toBe('test');
});

it('pins code when throwing out an error', async function () {
if (Meteor.isServer) {
const testCollection = new Mongo.Collection('duplicate_code_collection');
await testCollection.createIndexAsync({ name: 1 }, { unique: true });
// first insert
await testCollection.insertAsync({ name: 'foo' });
try {
// second insert, throws out error
await testCollection.insertAsync({ name: 'foo' });
} catch (e) {
expect(e.code).toBe(11000);
}
}
});

addBooksTests();
addContextTests();
addDefaultValuesTests();
Expand Down

0 comments on commit 3f6a3c4

Please sign in to comment.