Skip to content

Commit

Permalink
ADD #143 test for $inc
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Jun 6, 2017
1 parent 43238e1 commit 63145a1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/unit/RxDocument.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,14 @@ describe('RxDocument.test.js', () => {
});
});
describe('update', () => {
it('sets a value with a mongo like query', async() => {
it('$set a value with a mongo like query', async() => {
const c = await humansCollection.createPrimary(1);
const doc = await c.findOne().exec();
await doc.update({$set: {firstName: 'new first name'}});
const updatedDoc = await c.findOne({firstName: 'new first name'}).exec();
assert.equal(updatedDoc.firstName, 'new first name');
});

it('unsets a value with a mongo like query', async() => {
it('$unset a value with a mongo like query', async() => {
const c = await humansCollection.create(1);
const doc = await c.findOne().exec();
await doc.update({
Expand All @@ -281,6 +280,20 @@ describe('RxDocument.test.js', () => {
const updatedDoc = await c.findOne().exec();
assert.equal(updatedDoc.age, undefined);
});
it('$inc a value with a mongo like query', async() => {
const c = await humansCollection.create(1);
const doc = await c.findOne().exec();
const agePrev = doc.age;
await doc.update({
$inc: {
age: 1
}
});
assert.equal(doc.age, agePrev + 1);
await doc.save;
const updatedDoc = await c.findOne().exec();
assert.equal(updatedDoc.age, agePrev + 1);
});
});
describe('pseudo-Proxy', () => {
describe('get', () => {
Expand Down

0 comments on commit 63145a1

Please sign in to comment.