Skip to content

Commit

Permalink
use await delay instead of yield callback
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Aug 29, 2021
1 parent 720f0cc commit ab07251
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/model.test.js
Expand Up @@ -5249,6 +5249,7 @@ describe('Model', function() {

describe('sessions (gh-6362)', function() {
let MyModel;

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

beforeEach(function(done) {
Expand Down Expand Up @@ -5304,6 +5305,9 @@ 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 @@ -5343,7 +5347,6 @@ describe('Model', function() {
});

it('sets session on child doc when creating new doc (gh-7104)', async function() {

let doc = await MyModel.create({ name: 'test', arr: [{ foo: 'bar' }] });

const session = await MyModel.startSession();
Expand Down Expand Up @@ -5380,6 +5383,9 @@ 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' });

Expand Down Expand Up @@ -5411,6 +5417,9 @@ 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 @@ -7614,3 +7623,5 @@ describe('Model', function() {
});




0 comments on commit ab07251

Please sign in to comment.