Socket
Socket
Sign inDemoInstall

@diotoborg/corrupti-beatae

Package Overview
Dependencies
Maintainers
0
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diotoborg/corrupti-beatae

[![npm version][npm-badge]][npm-url] ![Build](https://github.com/diotoborg/corrupti-beatae/workflows/build/badge.svg) [![Dependency Status][david-badge]][david-url] [![Coveralls][BadgeCoveralls]][Coveralls] [![Maintainability](https://api.codeclimate.com/


Version published
Weekly downloads
453
decreased by-3%
Maintainers
0
Weekly downloads
 
Created
Source

@diotoborg/corrupti-beatae

npm version Build Dependency Status Coveralls Maintainability Known Vulnerabilities Gitter

Structured testing of seneca plugin messages.

Run Seneca messages in series (not parallel) to validate behavior against expectations.

Example

See example folder

Note

To use @hapi/joi, require with:

const Joi = require('@diotoborg/corrupti-beatae').Joi

This ensures that the Joi versions match.

Test Specification

# file: test-spec.js
module.exports = {
  print: true,
  pattern: 'role:foo',
  data: {
    foo: {
      bar: {
        b0: { id: 'b0', b: 0 },
        b1: { id: 'b1', b: 1 }
      }
    }
  },
  calls: [
    {
      // combined with top level pattern to form msg: 
      // role:foo,cmd:get,id:b0
      pattern: 'cmd:get',
      params: { id: 'b0' },
 
      // output result must match this Optioner (Joi-based) structure
      // https://github.com/rjrodger/optioner
      out: { b: 0 }
    },
    {
      // name a call to reference it later
      name: 'list-0',
      pattern: 'cmd:list',
      params: {},
      out: [{b: 0}, {b: 1}]
    },
    {
      pattern: 'cmd:get',
      // use https://github.com/rjrodger/inks back reference syntax
      params: { id: '`list-0:out[1].id`' },
      out: { b: 1 }
    },
  ]
}

Test code

# basic.js
const Seneca = require('Seneca')
const SenecaMsgTest = require('..')

const seneca = Seneca().test()

// Test specification
const test_spec = require('./test-spec.js')


// Define some simplistic message actions
seneca
  .use('promisify')
  .use('entity')
  .message('role:foo,cmd:get', async function(msg) {
    return this.entity('foo/bar').load$(msg.id)
  })
  .message('role:foo,cmd:list', async function(msg) {
    return this.entity('foo/bar').list$()
  })

// Use this inside your testing code
const run_msgs = SenecaMsgTest(seneca, test_spec)

async function run_test() {
  await run_msgs()
}

run_test()

Printed output (optional)

CALL   :  cmd:get { id: 'b0' }
ERROR  :  null
RESULT :  $-/foo/bar;id=b0;{b:0}


CALL   :  cmd:list {}
ERROR  :  null
RESULT :  [ $-/foo/bar;id=b0;{b:0}, $-/foo/bar;id=b1;{b:1} ]


CALL   :  cmd:get { id: 'b1' }
ERROR  :  null
RESULT :  $-/foo/bar;id=b1;{b:1}

Keywords

FAQs

Package last updated on 16 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc