Skip to content

Commit

Permalink
test(populate): fix flaky test for Automattic#5737
Browse files Browse the repository at this point in the history
  • Loading branch information
Fonger committed Aug 13, 2018
1 parent 6af5f0b commit 06b64df
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions test/model.populate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3273,16 +3273,27 @@ describe('model: populate:', function() {
slice('fans', [0, 5]).
populate('fans').
exec(function(err, blogposts) {
assert.ifError(error);
assert.ifError(err);

assert.equal(blogposts[0].title, 'Test 1');
assert.equal(blogposts[1].title, 'Test 2');
assert.ok(blogposts.length === 2);

assert.equal(blogposts[0].fans[0].name, 'Fan 1');
assert.equal(blogposts[0].fans[1].name, 'Fan 2');
var test1, test2;
if (blogposts[0].title === 'Test 1') {
test1 = blogposts[0];
test2 = blogposts[1];
} else {
test1 = blogposts[1];
test2 = blogposts[0];
}

assert.equal(blogposts[1].fans[0].name, 'Fan 2');
assert.equal(blogposts[1].fans[1].name, 'Fan 1');
assert.ok(test1.title === 'Test 1');
assert.ok(test2.title === 'Test 2');

assert.equal(test1.fans[0].name, 'Fan 1');
assert.equal(test1.fans[1].name, 'Fan 2');

assert.equal(test2.fans[0].name, 'Fan 2');
assert.equal(test2.fans[1].name, 'Fan 1');
done();
});
});
Expand Down

0 comments on commit 06b64df

Please sign in to comment.