Skip to content

Commit

Permalink
refactor more tests to async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Aug 29, 2021
1 parent ab07251 commit 72cdab0
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 378 deletions.
15 changes: 3 additions & 12 deletions test/model.test.js
Expand Up @@ -5250,8 +5250,6 @@ describe('Model', function() {
describe('sessions (gh-6362)', function() {
let MyModel;

const delay = ms => done => setTimeout(done, ms);

beforeEach(function(done) {
const nestedSchema = new Schema({ foo: String });
db.deleteModel(/Test/);
Expand Down Expand Up @@ -5305,9 +5303,6 @@ describe('Model', function() {
});

it('sets session when pulling a document from db', async function() {
async function delay(ms) {
await new Promise((resolve) => setTimeout(resolve, ms));
}
let doc = await MyModel.create({ name: 'test', nested: { foo: 'bar' } });

const session = await MyModel.startSession();
Expand Down Expand Up @@ -5383,10 +5378,6 @@ describe('Model', function() {
});

it('sets session when pulling multiple docs from db', async function() {
async function delay(ms) {
await new Promise((resolve) => setTimeout(resolve, ms));
}

const doc = await MyModel.create({ name: 'test' });

const session = await MyModel.startSession();
Expand Down Expand Up @@ -5417,9 +5408,6 @@ describe('Model', function() {
});

it('supports overwriting `session` in save()', async function() {
async function delay(ms) {
await new Promise((resolve) => setTimeout(resolve, ms));
}
let doc = await MyModel.create({ name: 'test' });

const session = await MyModel.startSession();
Expand Down Expand Up @@ -7625,3 +7613,6 @@ describe('Model', function() {



async function delay(ms) {
await new Promise((resolve) => setTimeout(resolve, ms));
}

0 comments on commit 72cdab0

Please sign in to comment.