interpreted

node-tap wrapper for testing input/output functionality

npm install interpreted
2 downloads in the last week
23 downloads in the last month

interpreted Build Status

node-tap wrapper for testing input/output functionality

Installation

npm install interpreted

Documentation


var interpreted = require('interpreted');

interpreted({

  // required. full path to the source file directory and the expected directory
  // the expected directory should contain JSON files (e.q. example.json)
  // and the source directory can contain anything. Note that the basename
  // must exist in both source and expected directroy.
  // (e.q yaml to json converter: source/example.yaml, expected/example.json)
  source: path.resolve(__dirname, 'source'),
  expected: path.resolve(__dirname, 'expected'),

  // optional. the basenames of the files to use in tests. If this is not specified
  // all tests will be used.
  run: ['example'],

  // optional, update flag. Instead of testing expected files, they will be overwritten with
  // the actual value. Default: false
  update: false,

  // optional. This method will execute before the file tests.
  start: function (callback) {
    callback(null);
  },

  // required. This method will be used to test the files. Note that there
  // must be passed a JSON valid value to the callback.
  test: function (name, content, callback) {
    callback(null, YAML.parse(content)); // real object (e. q. { test: true })
  },

  // optional. This method will execute after the file tests.
  close: function (callback) {
    callback(null);
  },

  // optional. This configuration object will be passed to the tap.test
  // function.
  tap: {
    timeout: 3000
  },

  // optional: by default json files are parsed and everything else is threaded
  // as a simple text. You can extend this behaviour.
  types: {
    'yaml': {
      'test': function (t, actual, expected) {
        t.deepEqual(actual, YAML.parse(expected));
      },
      'update': function (actual) {
        return YAML.stringify(actual);
      }
    }
  }
});

License

The software is license under "MIT"

Copyright (c) 2012 Andreas Madsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you