/* Copyright (c) 2014 Richard Rodger, MIT License */
'use strict'

const Seneca = require('seneca')
const MemStore = require('seneca-mem-store')
const Shared = require('..')

const Lab = require('@hapi/lab')
const lab = (exports.lab = Lab.script())
const before = lab.before


const si = makeSeneca()
  .use(MemStore)

const merge = makeSeneca()
  .use(MemStore, { merge: false })


Shared.basictest({
  seneca: si,
  senecaMerge: merge,
  script: lab
})

Shared.sorttest({
  seneca: si,
  script: lab
})

Shared.limitstest({
  seneca: si,
  script: lab
})

Shared.upserttest({
  seneca: si,
  script: lab
})


function makeSeneca() {
  const si = Seneca({
    default_plugins: { 'mem-store': false }
  })

  si.test()

  if (si.version >= '2.0.0') {
    si.use('entity')
  }

  return si
}


@@ -291,34 +291,24 @@
 keSeneca
-()%0A  .use(MemStore
+ForTest(
 )%0A%0Aconst
@@ -308,16 +308,19 @@
 %0A%0Aconst 
+si_
 merge = 
@@ -333,27 +333,35 @@
 neca
-()%0A  .use(MemStore,
+ForTest(%7B%0A  mem_store_opts:
  %7B m
@@ -372,16 +372,18 @@
 : false 
+%7D%0A
 %7D)%0A%0A%0ASha
@@ -427,16 +427,19 @@
 aMerge: 
+si_
 merge,%0A 
@@ -629,17 +629,33 @@
 keSeneca
-(
+ForTest(opts = %7B%7D
 ) %7B%0A  co
@@ -726,21 +726,8 @@
 %7D)%0A%0A
-  si.test()%0A%0A
   if
@@ -779,16 +779,104 @@
 ')%0A  %7D%0A%0A
+  const %7B mem_store_opts = %7B%7D %7D = opts%0A  si.use(MemStore, mem_store_opts)%0A%0A  si.test()%0A%0A
   return

Tidy up