Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dustjs-test-helper

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dustjs-test-helper

helper methods for testing dust

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

dustjs-test-helper

Test helpers to help test custom extensions (custom helpers, filter, etc.) of dustjs-linkedin.

  • lets you focus on unit testing
  • before and after hooks so you can modify or spy on the chunk, context, params, etc internals
  • does the boilerplate work of faking a template to exercise your extension
  • no dependency on the compiler

Install

$ npm install --save-dev dustjs-test-helper

Note: the test helper has a peer-dependency on dustjs-linkedin, which means you should have it installed in your repo as a dependency/dev dependency

Usage

you will likely want to use the test method. There is one specific for testing Dust's @helpers and a different one for Dust filters.

@see tests/example for an example using sinon, mocha and chai.

API

dustTester.helpers.test

var dustTester = require('dustjs-test-helper');
dustTesters.helpers.test(setupObject, function(err, out) {
  // same as a dust.render callback
});

test a custom helper using the fake template {@setupObjectName/}. use before hooks to modify this further.

dustTester.filters.test

var dustTester = require('dustjs-test-helper');
dustTesters.filters.test(setupObject, function(err, out) {
  // same as a dust.render callback
});

test a custom filter using the fake template {key|setupObjectName}. use before hooks to modify this further.

setupObject

Type: object

setupObject.name

Type:string

name of the @helper or |filter. Dust looks for this name in the dust.helpers and dust.filters objects and also matches what is used in the template

setupObject.fn

Type:function

the implementation of the helper or filter. The helper function signature is (chunk, context, bodies, params) while the filter function signature is (data)

setupObject.before

Type:function Default: function(){}

hook to be called before fn. gets the same params. useful for spying, setup, modifying, etc.

setupObject.after

Type:function Default: function(){}

hook to be called after fn. gets the same params. useful for asserting, doing cleanup, etc.

setupObject.ctx

Type:object Default: {}

context used to render the fake template

License

MIT [jimmyhchan]

Keywords

FAQs

Package last updated on 30 Jul 2016

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