Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Apr 12, 2024
1 parent 2e41bd9 commit aeb723d
Showing 1 changed file with 9 additions and 31 deletions.
40 changes: 9 additions & 31 deletions tests/integration/test.basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,8 @@ adapters.forEach(function (adapter) {
});

[
null,
undefined,
null,
[],
[{ _id: 'foo' }, { _id: 'bar' }],
'this is not an object',
Expand All @@ -758,48 +758,26 @@ adapters.forEach(function (adapter) {
describe(`Should error when document is not an object #${idx}`, () => {
let db;

beforeEach(() => {
db = new PouchDB(dbs.name);
});

it('should error for .post()', async () => {
const expectNotAnObject = fn => async () => {
let threw;
try {
await db.post(badDoc);
await fn();
} catch (err) {
threw = true;
err.message.should.equal('Document must be a JSON object');
}
if (!threw) {
throw new Error('should have thrown');
}
});
};

it('should error for .put()', async () => {
let threw;
try {
await db.post(badDoc);
} catch (err) {
threw = true;
err.message.should.equal('Document must be a JSON object');
}
if (!threw) {
throw new Error('should have thrown');
}
beforeEach(() => {
db = new PouchDB(dbs.name);
});

it('should error for .bulkDocs()', async () => {
let threw;
try {
await db.bulkDocs({docs: [badDoc]});
} catch (err) {
threw = true;
err.message.should.equal('Document must be a JSON object');
}
if (!threw) {
throw new Error('should have thrown');
}
});
it('should error for .post()', expectNotAnObject(() => db.post(badDoc)));
it('should error for .put()', expectNotAnObject(() => db.put(badDoc)));
it('should error for .bulkDocs()', expectNotAnObject(() => db.bulkDocs({docs: [badDoc]})));
});
});

Expand Down

0 comments on commit aeb723d

Please sign in to comment.