Skip to content

Commit f1a1b9c

Browse files
committed
use arrov functions in upsert
1 parent becd512 commit f1a1b9c

1 file changed

Lines changed: 12 additions & 27 deletions

File tree

tests/unit/test.mapreduce.js

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ describe('test.mapreduce.js-upsert', function () {
99
it('should throw an error if the doc errors', async function () {
1010
try {
1111
await upsert({
12-
get: function () {
13-
return Promise.reject(new Error('a fake error!'));
14-
},
12+
get: () => Promise.reject(new Error('a fake error!')),
1513
}, 'foo');
1614

1715
should.fail("Expected promise to be rejected");
@@ -22,28 +20,20 @@ describe('test.mapreduce.js-upsert', function () {
2220

2321
it('should fulfill if the diff returns false', async function () {
2422
const res = await upsert({
25-
get: function () {
26-
return Promise.resolve({ _rev: 'xyz' });
27-
},
28-
}, 'foo', function () {
29-
return false;
30-
});
23+
get: () => Promise.resolve({ _rev: 'xyz' }),
24+
}, 'foo', () => false
25+
);
3126

3227
res.updated.should.equal(false);
3328
res.rev.should.equal('xyz');
3429
});
3530

3631
it('should put if get throws 404', async function () {
3732
const res = await upsert({
38-
get: function () {
39-
return Promise.reject({ status: 404 });
40-
},
41-
put: function () {
42-
return Promise.resolve({ rev: 'abc' });
43-
},
44-
}, 'foo', function () {
45-
return { difference: "something" };
46-
});
33+
get: () => Promise.reject({ status: 404 }),
34+
put: () => Promise.resolve({ rev: 'abc' }),
35+
}, 'foo', () => ({ difference: "something" })
36+
);
4737

4838
res.updated.should.equal(true);
4939
res.rev.should.equal('abc');
@@ -52,15 +42,10 @@ describe('test.mapreduce.js-upsert', function () {
5242
it('should error if it can\'t put', async function () {
5343
try {
5444
await upsert({
55-
get: function () {
56-
return Promise.resolve({ _rev: 'xyz' });
57-
},
58-
put: function () {
59-
return Promise.reject(new Error('falala'));
60-
},
61-
}, 'foo', function () {
62-
return { difference: "something" };
63-
});
45+
get: () => Promise.resolve({ _rev: 'xyz' }),
46+
put: () => Promise.reject(new Error('falala')),
47+
}, 'foo', () => ({ difference: "something" })
48+
);
6449

6550
should.fail("Expected promise to be rejected");
6651
} catch (err) {

0 commit comments

Comments
 (0)