How to use nodeunitq - 10 common examples

To help you get started, we’ve selected a few nodeunitq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Medium / dynamite / test / testGetItem.js View on Github external
// Copyright 2013 The Obvious Corporation.

var utils = require('./utils/testUtils.js')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)

var onError = console.error.bind(console)
var initialData = [{"userId": "userA", "column": "@", "age": "29"}]

// basic setup for the tests, creating record userA with range key @
exports.setUp = function (done) {
  this.db = utils.getMockDatabase()
  this.client = utils.getMockDatabaseClient()
  utils.ensureLocalDynamo()
  utils.createTable(this.db, "user", "userId", "column")
    .thenBound(utils.initTable, null, {db: this.db, tableName: "user", data: initialData})
    .fail(onError)
    .fin(done)
}

exports.tearDown = function (done) {
github Medium / shepherd / test / importantDeps.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)
var graph

// set up a graph for testing
exports.setUp = function (done) {
  graph = this.graph = new (require ('../lib/shepherd')).Graph
  done()
}

// test that when nodes are provided to a parent node, only the important nodes runs
builder.add(function testOnlyImportantsRun(test) {
  var err = new Error('failed')
  var failCount = 0
  var successCount = 0

  this.graph.add('throws-first', function () {
    test.ok("First important node ran")
github Medium / dynamite / test / testTypeUtil.js View on Github external
// Copyright 2015 A Medium Corporation.

var typeUtil = require('../lib/typeUtil')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)
var Q = require('kew')

builder.add(function testAddToSet(test) {
  var set = typeUtil.valueToObject([1,2,3])
  test.equal(typeUtil.objectToType(set), 'NS')

  var additions = typeUtil.valueToObject([4])
  test.equal(typeUtil.objectToType(additions), 'NS')

  var modified = typeUtil.addToSet(set, additions)
  test.equal(typeUtil.objectToType(modified), 'NS')
  modified.NS.sort()

  test.deepEqual(set.NS, [1,2,3].map(String))
  test.deepEqual(modified.NS, [1,2,3,4].map(String))
github Medium / shepherd / test / subgraph.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)

// set up a graph for testing
exports.setUp = function (done) {
  this.graph = new (require ('../lib/shepherd')).Graph
  done()
}

// throw an error when an invalid arg is referenced
builder.add(function testErrorWhenMissingArg(test) {
  this.graph.add('val-echo', function (val) {
    return val
  }, ['val'])

  try {
    this.graph.add('val-shouldFail', this.graph.subgraph, ['val1', 'val2'])
      .builds('val-echo')
github Medium / shepherd / test / dot.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)

// set up a graph for testing
exports.setUp = function (done) {
  this.graph = new (require ('../lib/shepherd')).Graph
  done()
}

// test creating a dot graph from a given
builder.add(function testDotGraph(test) {
  this.graph.add('name-fromLiteral', {_literal: 'Jeremy'})
  this.graph.add('name-toUpper', function (name) {return name.toUpperCase()}, ['name'])
  this.graph.add('name-toLower', function (name) {return name.toLowerCase()}, ['name'])
  this.graph.add('age', 5)

  var dotOutput = this.graph.newBuilder('DOT_TEST')
    .builds('name-toUpper').using('name-fromLiteral')
github Medium / shepherd / test / builder.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)
var shepherd = require ('../lib/shepherd')
var semver = require('semver')
var graph

// set up a graph for testing
exports.setUp = function (done) {
  graph = this.graph = new shepherd.Graph
  done()
}

// test that builder names are required
builder.add(function testRequiredBuilderNames(test) {
  this.graph.enforceBuilderNames(shepherd.ErrorMode.ERROR)

  try {
    this.graph.newBuilder()
github Medium / shepherd / test / helpers.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)
var utils = require('../lib/utils')

// set up a graph for testing
exports.setUp = function (done) {
  this.graph = new (require ('../lib/shepherd')).Graph
  done()
}

// verify that clones show up in the getClones() list
builder.add(function testGetClones(test) {
  var graph1 = this.graph.clone()
  var graph2 = graph1.clone()
  var graph3 = graph2.clone()
  var clones

  clones = this.graph.getClones()
github Medium / shepherd / test / utils.js View on Github external
// Copyright 2013 The Obvious Corporation.

var Q = require('kew')
var nodeunitq = require('nodeunitq')
var semver = require('semver')
var builder = new nodeunitq.Builder(exports)
var utils = require('../lib/utils')

builder.add(function testNodeNames(test) {
  var ok = function (str) {
    utils.assertValidNodeName(str)
  }
  var bad = function (str) {
    test.throws(function () {
      ok(str)
    }, 'Expected error: ' + str)
  }

  ok('req')
  ok('req.body')
  ok('req.body.id')
  ok('*')
github Medium / shepherd / test / add.js View on Github external
// Copyright 2012 The Obvious Corporation.
var Q = require('kew')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)
var shepherd = require ('../lib/shepherd')

// set up a graph for testing
exports.setUp = function (done) {
  this.graph = new shepherd.Graph
  done()
}

// test that the function for a node can be retrieved
builder.add(function testFunction(test) {
  var echo = function (input) { return input }
  this.graph.add('echo', echo, ['input'])
  test.equal(this.graph.getFunction('echo'), echo, "The handler function should be returned")
  test.done()
})
github Medium / dynamite / test / testGetSet.js View on Github external
var utils = require('./utils/testUtils.js')
var nodeunitq = require('nodeunitq')
var builder = new nodeunitq.Builder(exports)

var onError = console.error.bind(console)
var initialData = [  {"userId": "userA", "column": "@", "postIds": ['1a', '1b', '1c']}
                   , {"userId": "userB", "column": "@", "postIds": [1, 2, 3]}
                   , {"userId": "userC", "column": "@"}]

/*
 * Sets up for test, and creates a record userA with range key @.
 */
exports.setUp = function (done) {
  this.db = utils.getMockDatabase()
  this.client = utils.getMockDatabaseClient()
  utils.ensureLocalDynamo()
  utils.createTable(this.db, "user", "userId", "column")
    .thenBound(utils.initTable, null, {db: this.db, tableName: "user", data: initialData})
    .fail(onError)

nodeunitq

Additional helpers and assertions for nodeunit, particularly optimized for Q

Apache-2.0
Latest version published 8 years ago

Package Health Score

42 / 100
Full package analysis

Popular nodeunitq functions

Similar packages