Skip to content

Commit

Permalink
v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Jun 14, 2021
1 parent 9692726 commit 10cdab8
Show file tree
Hide file tree
Showing 7 changed files with 665 additions and 660 deletions.
45 changes: 23 additions & 22 deletions msg-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,30 @@ const optioner = Optioner({
allow: Joi.object({
missing: Joi.boolean().default(false),
}).default(),
calls: Joi.alternatives().try(Joi.function(),Joi.array().items(
Joi.object({
name: Joi.string().min(1),
print: Joi.boolean().default(false),
print_context: Joi.boolean().default(false),
pattern: Joi.string().min(3),
params: Joi.alternatives()
.try(Joi.object().unknown(), Joi.func())
.default({}),
out: Joi.alternatives().try(Joi.object().unknown(), Joi.array()),
err: Joi.object().unknown(),
delegate: Joi.alternatives(Joi.string(), Joi.array(), Joi.func()),
verify: Joi.func(),
line: Joi.string(),
}))
calls: Joi.alternatives().try(
Joi.function(),
Joi.array().items(
Joi.object({
name: Joi.string().min(1),
print: Joi.boolean().default(false),
print_context: Joi.boolean().default(false),
pattern: Joi.string().min(3),
params: Joi.alternatives()
.try(Joi.object().unknown(), Joi.func())
.default({}),
out: Joi.alternatives().try(Joi.object().unknown(), Joi.array()),
err: Joi.object().unknown(),
delegate: Joi.alternatives(Joi.string(), Joi.array(), Joi.func()),
verify: Joi.func(),
line: Joi.string(),
})
)
),
})

function msg_test(seneca, spec) {

// Seneca instance is optional
if(seneca && !seneca.seneca) {
if (seneca && !seneca.seneca) {
spec = seneca
seneca = null
}
Expand All @@ -60,12 +62,11 @@ function msg_test(seneca, spec) {

Assert('object' === typeof spec.delegates)


if(null == seneca) {
if (null == seneca) {
seneca = Seneca().test()
}

if(spec.init) {
if (spec.init) {
seneca = spec.init(seneca)
}

Expand Down Expand Up @@ -95,7 +96,7 @@ function msg_test(seneca, spec) {
})

let calls = Array.isArray(spec.calls) ? spec.calls : spec.calls(LN)

intern.missing_messages(seneca, spec, calls)

Object.keys(spec.delegates).forEach((dk) => {
Expand All @@ -109,7 +110,7 @@ function msg_test(seneca, spec) {
const intern = (module.exports.intern = {
run: async function (seneca, spec, calls) {
let callmap = spec.context

return new Promise((resolve, reject) => {
next_call(0, function (err) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seneca-msg-test",
"version": "3.1.0",
"version": "3.2.0",
"description": "Structured testing of seneca plugin messages.",
"main": "msg-test.js",
"scripts": {
Expand Down
1,004 changes: 505 additions & 499 deletions test/coverage.html

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions test/declarative.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

module.exports = {
init: (seneca) => seneca.use('./p0.js'),
test: true,
fix: 'role:p0',
calls: LN => [
calls: (LN) => [
LN({
pattern: 'get:foo',
params: { x:1 },
out: { ok:true, x:1, bar:'foo' },
params: { x: 1 },
out: { ok: true, x: 1, bar: 'foo' },
}),
]
],
}
Loading

0 comments on commit 10cdab8

Please sign in to comment.