本文整理汇总了TypeScript中tape类的典型用法代码示例。如果您正苦于以下问题:TypeScript tape类的具体用法?TypeScript tape怎么用?TypeScript tape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tape类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: bundleCasesFrom
function bundleCasesFrom(i: number) {
if (i >= cases.length) return;
const b = browserify();
b.ignore("tape");
b.add(`${__dirname}/${cases[i]}.js`);
b.transform(path.normalize(__dirname + "/../cwise.js"));
tape(cases[i], (t) => { // Without nested tests, the asynchronous nature of bundle causes issues with tape...
b.bundle((err, src) => {
if (err) {
throw new Error("failed to bundle!");
}
vm.runInNewContext(src.toString(), {
test: t.test.bind(t),
Buffer,
Int8Array,
Int16Array,
Int32Array,
Float32Array,
Float64Array,
Uint8Array,
Uint16Array,
Uint32Array,
Uint8ClampedArray,
console: { log: console.log.bind(console) }
});
t.end();
});
});
bundleCasesFrom(i + 1);
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:cwise-tests.ts
示例2: elementAt
import * as Ix from '../Ix';
import * as test from 'tape';
const { elementAt } = Ix.iterable;
test('Iterable#elementAt empty returns undefined', t => {
const res = elementAt<number>([], 0);
t.equal(res, undefined);
t.end();
});
test('Iterable#elementAt single value first index', t => {
const res = elementAt([42], 0);
t.equal(res, 42);
t.end();
});
test('Iterable#elementAt single value invalid index', t => {
const res = elementAt([42], 1);
t.equal(res, undefined);
t.end();
});
test('Iterable#elementAt multiple values valid index', t => {
const res = elementAt([1, 42, 3], 1);
t.equal(res, 42);
t.end();
});
test('Iterable#elementAt multiple values invalid index', t => {
const res = elementAt([1, 42, 3], 7);
t.equal(res, undefined);
开发者ID:trxcllnt,项目名称:IxJS,代码行数:31,代码来源:elementat-spec.ts
示例3: exec
import * as test from 'tape';
import {exec} from '../src/index';
test('fake command should error', t => {
t.plan(1);
exec('fake-command', null)
.then(out => t.error(out))
.catch(err => t.ok(true, err.message));
});
test('fake path should error', t => {
t.plan(1);
exec('mkdir foo', '/fake/path')
.then(out => t.error(out))
.catch(err => t.ok(true, err.message));
});
test('git version should return version', t => {
t.plan(1);
exec('git --version', null)
.then(out => t.ok(out.includes('git version'), out))
.catch(err => t.fail(err.message));
});
test('git status should return status', t => {
t.plan(1);
exec('git status', null)
.then(out => t.ok(true, out))
.catch(err => t.fail(err.message));
});
开发者ID:styfle,项目名称:exeggcute,代码行数:30,代码来源:index-test.ts
示例4: toMap
import * as Ix from '../Ix';
import * as test from 'tape';
const { toMap } = Ix.iterable;
test('Iterable#toMap stores values', t => {
const res = toMap([1, 4], x => x % 2);
t.equal(res.get(0), 4);
t.equal(res.get(1), 1);
t.end();
});
test('Iterable#toMap overwrites duplicates', t => {
const res = toMap([1, 4, 2], x => x % 2);
t.equal(res.get(0), 2);
t.equal(res.get(1), 1);
t.end();
});
test('Iterable#toMap with element selector', t => {
const res = toMap([1, 4], x => x % 2, x => x + 1);
t.equal(res.get(0), 5);
t.equal(res.get(1), 2);
t.end();
});
test('Iterable#toMap with element selector overwrites duplicates', t => {
const res = toMap([1, 4, 2], x => x % 2, x => x + 1);
t.equal(res.get(0), 3);
t.equal(res.get(1), 2);
t.end();
});
开发者ID:trxcllnt,项目名称:IxJS,代码行数:31,代码来源:tomap-spec.ts
示例5: delayItem
import * as test from 'tape';
const { throttle } = Ix.asynciterable;
import { hasNext, noNext } from '../asynciterablehelpers';
function delayItem<T>(item: T, delay: number) {
return new Promise<T>(res => setTimeout(() => res(item), delay));
}
test('AsyncIterable#throttle drops none', async t => {
const xs = async function*() {
yield await delayItem(1, 100);
yield await delayItem(2, 100);
yield await delayItem(3, 100);
};
const ys = throttle(xs(), 50);
const it = ys[Symbol.asyncIterator]();
await hasNext(t, it, 1);
await hasNext(t, it, 2);
await hasNext(t, it, 3);
await noNext(t, it);
t.end();
});
test('AsyncIterable#throttle drops some', async t => {
const xs = async function*() {
yield await delayItem(1, 100);
yield await delayItem(2, 100);
yield await delayItem(3, 100);
yield await delayItem(4, 100);
};
开发者ID:trxcllnt,项目名称:IxJS,代码行数:31,代码来源:throttle-spec.ts
示例6: compare
import * as test from 'tape';
import {compare} from './patch';
test('utils/patch: JSON patch should deal gracefully with undefined values', t => {
t.plan(3);
const obj1 = {a: 'foo', b: undefined};
const obj2 = {a: 'foo', b: undefined};
const changes = compare(obj1, obj2);
t.ok(changes, 'changes is not null');
t.ok(Array.isArray(changes), 'changes is an array');
t.notOk(changes.length, 'objects should compare as identical');
t.end();
});
test('utils/patch: JSON patch can generate a changeset for simple objects', t => {
t.plan(5);
const obj1 = {a: 'foo', b: 'bar'};
const obj2 = {a: 'foo', b: 'foo'};
const changes = compare(obj1, obj2);
t.ok(changes, 'changes is not null');
t.ok(Array.isArray(changes), 'changes is an array');
t.equals(1, changes.length, 'changes should contain one change');
t.equals('replace', changes[0].op, 'operation should be a "replace" op');
开发者ID:JayKan,项目名称:augury,代码行数:31,代码来源:patch.test.ts
示例7: kaktest
export function kaktest(
name: string,
cb: (kak: Kak<Splice>, t: test.Test, end: () => void) => void | Promise<any>
): void {
test(name, (t: test.Test) => {
t.timeoutAfter(1000)
t.plan(1)
const proc = libkak.Headless()
const session = proc.pid
const kak = Kak.Init(Splice, {session, client: 'unnamed0', debug})
const end = () => (proc.kill(), kak.teardown(), t.end())
cb(kak, t, end)
})
}
开发者ID:Franciman,项目名称:kakoune-languageclient,代码行数:14,代码来源:libkak.test.ts
示例8: delay
await delay(5);
ctx.body = "ok";
ctx.status = 200;
});
test('public:200', { skip: false }, async (t) => {
let store = await getStore(false);
let app = new Koa();
//public
app.use(publicRoute);
//Auth
app.use(authentication);
//Secured
app.use(secretRoute);
let request = supertest.agent(listen(app));
request
.get('/public')
.expect(200)
.end(async (err, res) => {
await delay(5);
t.assert(!err);
if (err) debug(err.message);
t.end();
});
});
const authentication = auth(users.service.fromCredentials);
const secretRoute = router.get('/secret',
async function (args, next) {
开发者ID:D10221,项目名称:koapp,代码行数:31,代码来源:routes_auth_test.ts
示例9: range
const { elementAt } = Ix.iterable;
const { first } = Ix.iterable;
const { isEmpty } = Ix.iterable;
const { last } = Ix.iterable;
const { range } = Ix.iterable;
const { sequenceEqual } = Ix.iterable;
const { skip } = Ix.iterable;
const { take } = Ix.iterable;
const { toArray } = Ix.iterable;
test('Iterable#range produces correct sequence', t => {
const rangeSequence = range(1, 100);
let expected = 0;
for (let item of rangeSequence) {
expected++;
t.equal(expected, item);
}
t.equal(100, expected);
t.end();
});
test('Iterable#range toArray produce correct result', t => {
const arr = toArray(range(1, 100));
for (let i = 0; i < arr.length; i++) {
t.equal(i + 1, arr[i]);
}
t.end();
});
开发者ID:trxcllnt,项目名称:IxJS,代码行数:31,代码来源:range-spec.ts
示例10: ContentItemBuilder
import { skipDirectories, skipMeta } from '../../src/transforms/skip-items';
import ContentItemBuilder from '../../src/content-item-builder';
test('skipItems', (t) => {
t.test('skipDirectories', (st) => {
{
const item = new ContentItemBuilder(true, '/').build();
st.ok(skipDirectories(item), 'is directory');
}
{
const item = new ContentItemBuilder(false, '/').build();
st.notOk(skipDirectories(item), 'isn\'t directory');
}
st.end();
});
t.test('skipMeta', (st) => {
{
const item = new ContentItemBuilder(false, '/meta.yaml').build();
st.ok(skipMeta(item), 'is meta');
}
{
const item = new ContentItemBuilder(false, '/whatever').build();
st.notOk(skipMeta(item), 'isn\'t meta');
}
st.end();
});
});
开发者ID:mjwbenton,项目名称:staircase-generator,代码行数:30,代码来源:skip-items.ts
注:本文中的tape类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论