當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tape類代碼示例

本文整理匯總了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;未經允許,請勿轉載。