How to use the tap.same function in tap

To help you get started, we’ve selected a few tap 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 motdotla / dotenv / tests / test-cli-options.js View on Github external
/* @flow */

const t = require('tap')

const options = require('../lib/cli-options')

t.plan(5)

// matches encoding option
t.same(options(['node', '-e', "'console.log(testing)'", 'dotenv_config_encoding=utf8']), {
  encoding: 'utf8'
})

// matches path option
t.same(options(['node', '-e', "'console.log(testing)'", 'dotenv_config_path=/custom/path/to/your/env/vars']), {
  path: '/custom/path/to/your/env/vars'
})

// matches debug option
t.same(options(['node', '-e', "'console.log(testing)'", 'dotenv_config_debug=true']), {
  debug: 'true'
})

// ignores empty values
t.same(options(['node', '-e', "'console.log(testing)'", 'dotenv_config_path=']), {})
github isaacs / yallist / test / basic.js View on Github external
t.same(swiped, Yallist(8, 99, 9, 7, 66))
t.same(inserter, Yallist(2, 3, 5, 4, 1, 8))
swiped.unshiftNode(inserter.tail)
t.same(inserter, Yallist(2, 3, 5, 4, 1))
t.same(swiped, Yallist(8, 8, 99, 9, 7, 66))

t.throws(function remove_foreign_node () {
  e.removeNode(swiped.head)
}, {}, new Error('removing node which does not belong to this list'))
t.throws(function remove_unlisted_node () {
  e.removeNode(Yallist.Node('nope'))
}, {}, new Error('removing node which does not belong to this list'))

e = Yallist(1, 2)
e.removeNode(e.head)
t.same(e, Yallist(2))
e = Yallist(1, 2)
e.removeNode(e.tail)
t.same(e, Yallist(1))

// shift all the way down
e = Yallist()
e.push(1)
e.push(2)
e.push(3)
t.equal(e.shift(), 1)
t.equal(e.shift(), 2)
t.equal(e.shift(), 3)
t.equal(e.shift(), undefined)

// pop all the way down
e = Yallist()
github motdotla / dotenv / tests / test-env-options.js View on Github external
delete process.env[envVar]
  process.env[envVar] = tmpVal

  t.same(options(), expect)

  delete process.env[envVar]
}

t.plan(4)

// returns empty object when no options set in process.env
delete process.env.DOTENV_CONFIG_ENCODING
delete process.env.DOTENV_CONFIG_PATH
delete process.env.DOTENV_CONFIG_DEBUG

t.same(options(), {})

// sets encoding option
testOption('DOTENV_CONFIG_ENCODING', 'latin1', { encoding: 'latin1' })

// sets path option
testOption('DOTENV_CONFIG_PATH', '~/.env.test', { path: '~/.env.test' })

// sets debug option
testOption('DOTENV_CONFIG_DEBUG', 'true', { debug: 'true' })

// restore existing env
process.env.DOTENV_CONFIG_ENCODING = e
process.env.DOTENV_CONFIG_PATH = p
process.env.DOTENV_CONFIG_DEBUG = d
github motdotla / dotenv / tests / test-parse.js View on Github external
t.equal(parsed.SPACED_KEY, 'parsed', 'parses keys and values surrounded by spaces')

const payload = dotenv.parse(Buffer.from('BUFFER=true'))
t.equal(payload.BUFFER, 'true', 'should parse a buffer into an object')

const expectedPayload = { SERVER: 'localhost', PASSWORD: 'password', DB: 'tests' }

const RPayload = dotenv.parse(Buffer.from('SERVER=localhost\rPASSWORD=password\rDB=tests\r'))
t.same(RPayload, expectedPayload, 'can parse (\\r) line endings')

const NPayload = dotenv.parse(Buffer.from('SERVER=localhost\nPASSWORD=password\nDB=tests\n'))
t.same(NPayload, expectedPayload, 'can parse (\\n) line endings')

const RNPayload = dotenv.parse(Buffer.from('SERVER=localhost\r\nPASSWORD=password\r\nDB=tests\r\n'))
t.same(RNPayload, expectedPayload, 'can parse (\\r\\n) line endings')

// test debug path
const logStub = sinon.stub(console, 'log')
dotenv.parse(Buffer.from('what is this'), { debug: true })
t.ok(logStub.called)
logStub.restore()
github makercam / openjscam / tests / index.js View on Github external
reset()
    feed(200)
    arc({ x: 100 }, 90)
    tap.same(gcode(), [['F200'], ['G2 X100 Y100 Z0 I100 J0']], 'should draw an arc')

    reset()
    feed(200)
    arc({ x: 100 }, -90)
    tap.same(gcode(), [['F200'], ['G3 X100 Y-100 Z0 I100 J0']], 'should draw a counter clockwise arc')

    reset()
    feed(200)
    ellipse(5, 1, 0, 270, 0, 64)
    ellipse(10, 1.1, 0, 360, 270, 16)
    tap.same(Math.round(state.lastCoord.x * 10000) / 10000, 5, 'ellipse end coord should be correct')
    tap.same(Math.round(state.lastCoord.y * 10000) / 10000, 0.1, 'ellipse end coord should be correct')

    reset()
    feed(200)
    icut({ y: 1 })
    icut({ x: 1 })
    icut({ y: -1 })
    icut({ x: -1 })
    tap.same(gcode(), [['F200'], ['G1 Y1'], ['G1 X1'], ['G1 Y0'], ['G1 X0']], 'should make a square')

    reset()
    feed(200)
    rotate(90, () => {
        icut({ y: 1 })
        icut({ x: 1 })
        icut({ y: -1 })
        icut({ x: -1 })
github prantlf / nettime / tests / nettime.js View on Github external
function checkNull (timing) {
  test.same(timing, null)
}
github npm / pacote / test / util / proc-log.js View on Github external
process.once('log', (...args) => t.same(args, ['warn', 1, 2, 3]))
procLog.warn(1, 2, 3)
github YahooArchive / mendel / test / tree-variation-walker-server.js View on Github external
t.equals(MendelServerVariationWalker().constructor, MendelServerVariationWalker, 'constructor');

var stub1 = {
    index: 0,
    id: 'first',
    variations: ['a', 'b', 'special'],
    data: [
        {id:'a', sha:'ba', variation: 'a'},
        {id:'b', variation: 'b'},
        {id:'special', 'variation': 'special'},
    ],
};

var walker = MendelServerVariationWalker([['a'],['special']], 'special');
walker.find(stub1);
t.same(walker.found(),
    { first: 'a' },
    'variation map');

walker = new MendelServerVariationWalker([['special']], 'special');
walker.find(stub1);

t.same(walker.found(), {
    first: 'special' },
    'variation map');
github npm / node-tar / test / warn-mixin.js View on Github external
const t = require('tap')
const EE = require('events').EventEmitter
const warner = require('../lib/warn-mixin.js')

const Warner = warner(EE)

const w = new Warner()

t.isa(w.warn, 'function')

const warning = []
w.once('warn', (code, msg, data) => warning.push(code, msg, data))
w.warn('code', 'hello')
t.same(warning, ['code', 'hello', { tarCode: 'code', code: 'code' }])

warning.length = 0
w.once('warn', (code, msg, data) => warning.push(code, msg, data))
w.warn('ok', new Error('this is fine'), { foo: 'bar' })
t.match(warning, ['ok', 'this is fine', {
  message: 'this is fine',
  foo: 'bar',
}])

w.strict = true
t.throws(_ => w.warn('code', 'hello', { data: 123 }),
  { message: 'hello', data: 123 })
const poop = new Error('poop')
t.throws(_ => w.warn('ok', poop), poop)

w.file = 'some/file'
github focusaurus / peterlyons.com / app / play / photos / galleries-tap.js View on Github external
tap.test("photoJSONToObject should parse and format JSON", test => {
  const photos = galleries.photoJSONToObject(gallery, mockPhotoJSON);
  tap.same(photos.length, 1);
  tap.match(photos[0], {
    fullSizeURI: "/photos/testGallery/test-photo-name.jpg",
    thumbnailURI: "/photos/testGallery/test-photo-name-TN.jpg",
    pageURI: "/photos?gallery=testGallery&photo=test-photo-name"
  });
  test.end();
});