本文整理匯總了TypeScript中tape.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript tape.default方法的具體用法?TypeScript tape.default怎麽用?TypeScript tape.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tape
的用法示例。
在下文中一共展示了tape.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
import * as React from 'react';
import * as test from 'tape';
import configureStore from './store';
declare const module: { hot: any };
test('Test Store', (t: test.Test) : void => {
let store = configureStore();
t.equal(store.getState().counterReducer, 0, 'Check default store data');
store = configureStore({ counterReducer: 1 });
t.equal(store.getState().counterReducer, 1, 'Check store data');
module.hot = {
accept: (dep: any, callback: Function) => {
callback();
}
};
store = configureStore({ counterReducer: 0 }, module);
t.equal(store.getState().counterReducer, 0, 'Check hot module replacement');
t.end();
});
示例2: setup
test('Tree', (t: test.Test) => {
t.test('creates a new Tree instance', (t: test.Test) => {
const treeInstance = new Tree<string>();
t.assert(treeInstance !== undefined, 'instance exists');
t.end();
});
t.test('creates a new Tree instance with the passed in data', (t: test.Test) => {
const treeInstance = new Tree<string>('test');
t.assert(treeInstance !== undefined, 'instance exists');
t.equal(treeInstance.getNodeData(), 'test');
t.end();
});
t.test('getNodeData', (t: test.Test) => {
const treeInstance = new Tree<number>(10);
t.test('retrieves the current value of node data', (t: test.Test) => {
t.equal(treeInstance.getNodeData(), 10);
t.end();
});
});
t.test('setNodeData', (t: test.Test) => {
const treeInstance = new Tree<number>();
t.test('sets the node data', (t: test.Test) => {
treeInstance.setNodeData(1);
t.equal(treeInstance.getNodeData(), 1);
t.end();
});
});
t.test('addChild', (t: test.Test) => {
const treeInstance = new Tree<Object>();
t.test('adds a child to the children list', (t: test.Test) => {
treeInstance.addChild({ test: 'foo' });
t.deepEquals(treeInstance.getChildAt(0).getNodeData(), { test: 'foo' });
t.end();
});
});
t.test('getChildAt', (t: test.Test) => {
const treeInstance = new Tree<string>('root');
t.test('gets a child at a valid location', (t: test.Test) => {
treeInstance.addChild('l1c1');
t.equals(treeInstance.getChildAt(0).getNodeData(), 'l1c1');
t.end();
});
t.test('gracefully handles invalid indices', (t: test.Test) => {
t.equals(treeInstance.getChildAt(1), undefined);
t.end();
});
});
t.test('removeChild', (t: test.Test) => {
function setup() {
const t = new Tree<number>(0);
t.addChild(1);
t.addChild(2);
t.addChild(3);
return t;
}
t.test('removes and returns child at given index', (t: test.Test) => {
const treeInstance = setup();
const removedChild = treeInstance.removeChild(1);
t.assert(removedChild !== undefined, 'exists');
t.assert(removedChild instanceof Tree, 'is a tree');
t.equal(removedChild.getNodeData(), 2);
t.end();
});
t.test('handles invalid indices gracefully', (t: test.Test) => {
const treeInstance = setup();
const removedChild = treeInstance.removeChild(45);
t.equal(removedChild, undefined);
t.end();
});
});
t.test('clone', (t: test.Test) => {
t.test('clones a single node', (t: test.Test) => {
const treeInstance = new Tree<number>(0);
const cloneTree = treeInstance.clone();
//.........這裏部分代碼省略.........
示例3:
/// <reference path="../../typings/main/ambient/node/index.d.ts" />
/// <reference path="../../typings/main/definitions/tape/index.d.ts" />
import * as test from "tape";
import { Notes } from "../Note";
test("Transposition does not mutate the original Note",
(assert) => {
assert.plan(1);
const C = Notes.C;
C.transpose(1);
assert.equal(C, Notes.C);
});
test("Transposing C up a semitone should yield C#",
(assert) => {
assert.plan(1);
const C = Notes.C;
const C_Sharp = C.transpose(1);
assert.deepEqual(C_Sharp, Notes.C_Sharp);
});
test("Transposing C up two semitones should yield D",
(assert) => {
assert.plan(1);
const C = Notes.C;
const D = C.transpose(2);
assert.deepEqual(D, Notes.D);
});
示例4: range
import * as Ix from '../Ix';
import * as test from 'tape';
const { concat } = Ix.iterable;
const { range } = Ix.iterable;
const { retry } = Ix.iterable;
const { sequenceEqual } = Ix.iterable;
const { _throw } = Ix.iterable;
import { hasNext } from '../iterablehelpers';
test('Iterable#retry infinite no errors does not retry', t => {
const xs = range(0, 10);
const res = retry(xs);
t.true(sequenceEqual(res, xs));
t.end();
});
test('Iterable#retry finite no errors does not retry', t => {
const xs = range(0, 10);
const res = retry(xs, 2);
t.true(sequenceEqual(res, xs));
t.end();
});
test('Iterable#retry finite eventually gives up', t => {
const err = new Error();
const xs = concat(range(0, 2), _throw(err));
const res = retry(xs, 2);
const it = res[Symbol.iterator]();
示例5: count
import * as Ix from '../Ix';
import * as test from 'tape';
const { count } = Ix.asynciterable;
const { empty } = Ix.asynciterable;
const { of } = Ix.asynciterable;
const { _throw } = Ix.asynciterable;
test('AsyncItearble#count some', async (t: test.Test) => {
const xs = of(1, 2, 3, 4);
const ys = await count(xs);
t.equal(ys, 4);
t.end();
});
test('AsyncIterable#count empty', async (t: test.Test) => {
const xs = empty<number>();
const ys = await count(xs);
t.equal(ys, 0);
t.end();
});
test('AsyncIterable#count throws', async (t: test.Test) => {
const err = new Error();
const xs = _throw<number>(err);
try {
await count(xs);
示例6: RenderState
import * as test from 'tape';
import RenderState from './render-state';
test('utils/render-state: init component', t => {
t.plan(4);
const comp: RenderState = new RenderState();
const value: any = {
name: 'hello'
};
t.notEqual(comp, undefined, 'should not be undefined');
t.deepEqual(comp.type(value), 'object', 'type should be object');
t.deepEqual(comp.keys(value), ['name'], 'should have name as keys');
t.doesNotThrow(() => {
comp.expandTree('name', new CustomEvent('test'))
}, undefined, 'should not throw error on expanded');
t.end();
})
示例7: range
import * as Ix from '../Ix';
import * as test from 'tape';
const { defer } = Ix.iterable;
const { range } = Ix.iterable;
const { sequenceEqual } = Ix.iterable;
test('Iterable#defer defers side effects', t => {
let i = 0;
let n = 5;
const xs = defer(() => {
i++;
return range(0, n);
});
t.equal(0, i);
t.true(sequenceEqual(xs, range(0, n)));
t.equal(1, i);
n = 3;
t.true(sequenceEqual(xs, range(0, n)));
t.equal(2, i);
t.end();
});
示例8: async
import * as Ix from '../Ix';
import * as test from 'tape';
const { empty } = Ix.asynciterable;
const { from } = Ix.asynciterable;
const { sequenceEqual } = Ix.iterable;
const { toArray } = Ix.asynciterable;
test('AsyncIterable#toArray some', async (t: test.Test) => {
const xs = [42, 25, 39];
const ys = from(xs);
const res = await toArray(ys);
t.true(sequenceEqual(res, xs));
t.end();
});
test('AsyncIterable#toArray empty', async (t: test.Test) => {
const xs = empty<number>();
const res = await toArray(xs);
t.equal(res.length, 0);
t.end();
});
示例9: Writable
import {Writable} from "stream";
test('Create logger', t => {
const results = [
'{"label":"Label","message":["Something went wrong"]}',
'{"label":"Label","message":["Foo",{"foo":"bar"}]}'
];
const writer = new Writable();
Reflect.defineProperty(writer, '_write', {
value: (data, enc, cb) => {
const actual = data.toString();
const expected = results.shift();
t.equal(expected, actual, 'written data should equal to ' + expected);
cb();
if (results.length === 0) {
t.end();
}
}
});
const log = logger('Label', writer);
t.ok(typeof log === 'function', '"log" should be a function');
t.throws(() => {
log();
}, 'log() should throw an error');
log('Something went wrong');
log('Foo', {foo: 'bar'});
});
示例10: Position
import * as test from 'tape';
import {Position} from '../../lib/values/Position';
test(`Position values can be encoded and decoded`, (t) => {
t.plan(2);
const p = new Position(4, 3, 1);
const bytes = p.encode();
t.ok(bytes instanceof Buffer);
t.deepEqual(Position.decode(bytes), p);
});
test(`Position values can be decoded when they are zero-padded`, (t) => {
t.plan(2);
const p = new Position(4, 3, 1);
const bytes = p.encode();
t.ok(bytes instanceof Buffer);
t.deepEqual(Position.decode(Buffer.concat([bytes, Buffer.alloc(128, 0x00)])), p);
});
test(`Position values can be decoded from a given set of bytes`, (t) => {
t.plan(1);
const bytes = '09000000000000104011000000000000084019000000000000f03f';
const p = new Position(4, 3, 1);
t.deepEqual(Position.decode(Buffer.from(bytes, `hex`)), p);
});