Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let bocha = require('bocha');
let testCase = bocha.testCase;
let assert = bocha.assert;
let refute = bocha.refute;
let nock = require('nock');
module.exports = testCase('validation', {
setUp() {
this.nock = nock('http://myserver.com');
},
tearDown() {
nock.cleanAll();
},
'save: with invalid entity': async function () {
this.nock
.post('/main', { name: 'Shark', type: 'fish' }).reply(200, {
id: 'C1',
rev: 'C1R'
});
let db = createDb({
let bocha = require('bocha');
let sinon = require('sinon');
let testCase = bocha.testCase;
let assert = bocha.assert;
let refute = bocha.refute;
let smartdb = require('../lib/smartdb.js');
module.exports = testCase('fake', {
'can fake get()': async function () {
let fakeDb = createFake({
entities: [
{ _id: 'F1', type: 'fish', name: 'Shark' }
]
});
let doc = await fakeDb.get('fish', 'F1');
assert.equals(doc, { _id: 'F1', type: 'fish', name: 'Shark' });
},
'updateWithRetry() can update entity': async function () {
let fakeDb = createFake({
let bocha = require('bocha');
let testCase = bocha.testCase;
let assert = bocha.assert;
let refute = bocha.refute;
let nock = require('nock');
module.exports = testCase('views', {
setUp() {
this.nock = nock('http://myserver.com');
},
tearDown() {
nock.cleanAll();
},
'list: without rewrite': async function () {
this.nock
.get('/animals/_design/fish/_list/myList/myView?group=true').reply(200, '<b>Shark</b>');
let db = createDb({
databases: [
{
url: 'http://myserver.com/animals',
let bocha = require('bocha');
let sinon = require('sinon');
let testCase = bocha.testCase;
let assert = bocha.assert;
let refute = bocha.refute;
let nock = require('nock');
module.exports = testCase('cache-provider', {
setUp() {
this.nock = nock('http://myserver.com');
},
tearDown() {
nock.cleanAll();
},
'can use provider to get cached item': async function () {
let db = createDb({
databases: [
{
url: 'http://myserver.com/animals',
entities: {
fish: {
let bocha = require('bocha');
let sinon = require('sinon');
let testCase = bocha.testCase;
let assert = bocha.assert;
let refute = bocha.refute;
let nock = require('nock');
module.exports = testCase('event-hooks', {
setUp() {
this.nock = nock('http://myserver.com');
},
tearDown() {
nock.cleanAll();
},
'preInsert: can manipulate doc before merge': function (done) {
this.nock
.get('/main/F1').reply(200, {
_id: 'F1',
_rev: 'F1R',
type: 'fish'
})