• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tape.test函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tape.test函数的典型用法代码示例。如果您正苦于以下问题:TypeScript test函数的具体用法?TypeScript test怎么用?TypeScript test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了test函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

import { autobindMethods } from '../../lib/objects';
import { test } from 'tape';

test('autobindMethods()', function(t) {
  t.test('it binds methods by name to an instance', function(st) {
    st.plan(4);
    class Foobar {
      foo() {
        return this;
      }

      bar() {
        return this;
      }

      baz() {
        return this;
      }
    }

    autobindMethods(Foobar, 'foo', 'bar');
    let instance = new Foobar();
    let { foo, bar, baz } = instance;

    st.equal(foo(), instance);
    st.equal(bar(), instance);
    st.equal(bar(), instance);
    st.equal(baz(), undefined);
  });
});
开发者ID:whastings,项目名称:js_utils,代码行数:30,代码来源:autobindMethods_tests.ts


示例2: test

test('curryN()', function(t) {
  t.test('it curries a function\'s arguments', function(st) {
    let curriedFunc;
    st.plan(1);

    function func(a, b, c, d) {
      st.same([a, b, c, d], [1, 2, 3, 4]);
    }

    curriedFunc = curryN(func);
    curriedFunc(1)(2)(3)(4);
  });

  t.test('it accepts an optional arity argument', function(st) {
    let curriedFunc;
    st.plan(1);

    function func(a, b, c, d, e) { // eslint-disable-line
      st.same([a, b, c], [1, 2, 3]);
    }

    curriedFunc = curryN(func, 3);
    curriedFunc(1)(2)(3);
  });

  t.test('two calls to same curried func will not affect each other', function(st) {
    let result;
    let firstCurried;
    st.plan(2);

    function func(a, b, c, d) {
      result = [a, b, c, d];
    }

    firstCurried = curryN(func)(1)(2);

    firstCurried(3)(4);
    st.same(result, [1, 2, 3, 4]);

    firstCurried(5)(6);
    st.same(result, [1, 2, 5, 6]);
  });
});
开发者ID:whastings,项目名称:js_utils,代码行数:43,代码来源:curryN_tests.ts


示例3:

Tape.test("taking items", (test: any) => {

  test.test("taking no items", (test: any) => {
    test.test("no items returned if none input", (test: any) => {

      let data: Array<any> = [];
      let queryable = new Queryable<any>(data);
      queryable.take(0);

      test.equal(queryable.toArray().length, 0);

      test.end();
    });

    test.test("no items returned if one input", (test: any) => {

      let data: Array<any> = [{}];
      let queryable = new Queryable<any>(data);
      queryable.take(0);

      test.equal(queryable.toArray().length, 0);

      test.end();
    });
  });

  test.test("taking one item", (test: any) => {
    test.test("one item returned if one input", (test: any) => {

      let data: Array<any> = [{}];
      let queryable = new Queryable<any>(data);
      queryable.take(1);

      test.equal(queryable.toArray().length, 1);

      test.end();
    });

    test.test("one item returned if two input", (test: any) => {

      let data: Array<any> = [{}, {}];
      let queryable = new Queryable<any>(data);
      queryable.take(1);

      test.equal(queryable.toArray().length, 1);

      test.end();
    });
  });

  test.test("taking one item after skiping one item", (test: any) => {
    test.test("no items returned if one input", (test: any) => {

      let data: Array<any> = [{}];
      let queryable = new Queryable<any>(data);
      queryable.skip(1);
      queryable.take(1);

      test.equal(queryable.toArray().length, 0);

      test.end();
    });

    test.test("one item returned if two input", (test: any) => {

      let data: Array<any> = [{}, {}];
      let queryable = new Queryable<any>(data);
      queryable.skip(1);
      queryable.take(1);

      test.equal(queryable.toArray().length, 1);

      test.end();
    });

    test.test("one item returned if three input", (test: any) => {

      let data: Array<any> = [{}, {}, {}];
      let queryable = new Queryable<any>(data);
      queryable.skip(1);
      queryable.take(1);

      test.equal(queryable.toArray().length, 1);

      test.end();
    });
  });
});
开发者ID:sift-it,项目名称:express-sift-it,代码行数:88,代码来源:take.tests.ts


示例4: test

import { reduce } from '../../lib/functional';
import { test } from 'tape';
import testCurriedMethod from './testCurriedMethod';

test('reduce()', function(t) {
  let args = [function() {}, 0];

  testCurriedMethod(t, reduce, 'reduce', args);
});
开发者ID:whastings,项目名称:js_utils,代码行数:9,代码来源:reduce_tests.ts


示例5: test

import { flatten } from '../../lib/array_utils';
import { test } from 'tape';

const TEST_ARRAY = [1, 2, [3, 4, [5, 6, [7], 8], 9, 10], 11, [12, [13, 14]]];

test('flatten()', function(t) {
  t.test('it flattens a multi-dimensional array', function(st) {
    st.plan(1);
    st.deepEqual(
      flatten(TEST_ARRAY),
      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
    );
  });

  t.test('it stops recursing at level when it is specified', function(st) {
    st.plan(1);
    st.deepEqual(
      flatten(TEST_ARRAY, 2),
      [1, 2, 3, 4, 5, 6, [7], 8, 9, 10, 11, 12, 13, 14]
    );
  });
});
开发者ID:whastings,项目名称:js_utils,代码行数:22,代码来源:flatten_tests.ts


示例6: test

import { test } from 'tape';

test('timeout()', function(t) {
  let clock,
      sandbox;

  let wrapper = beforeAndAfterTest(
     function() {
       sandbox = sinon.sandbox.create();
       clock = sandbox.useFakeTimers();
     },
     function() {
       sandbox.restore();
     }
  );

  t.test('it resolves a promise after a given amount of time', wrapper(function(st) {
    let resolveSpy = sandbox.spy(),
        promise = timeout(1000);
    st.plan(2);

    promise.then(resolveSpy);

    clock.tick(999);
    st.ok(!resolveSpy.called, 'Does not resolve before time.');

    clock.tick(1);
    st.ok(!resolveSpy.calledOnce, 'Does resolve after time.');
  }));
});
开发者ID:whastings,项目名称:js_utils,代码行数:30,代码来源:timeout_tests.ts


示例7: test

import { test } from 'tape';
import { Anagram } from './anagram';


test('should get the name right', t => {
  const anagram = new Anagram('oh, hi Mark')
  const expected = 'oh, hi Mark'
  t.equal(anagram.innerText, expected)
  t.end()
})


test('should innerTexts equal', t => {
  const anagram = new Anagram('oh, hi Mark')
  const anagramCopy = new Anagram('oh, hi Mark')
  t.equal(anagram.innerText, anagramCopy.innerText)
  t.end()
})
开发者ID:Plonee,项目名称:codekatas,代码行数:18,代码来源:tests.ts


示例8: test

/// <reference path="../typings/index.d.ts" />

import {test} from 'tape';
import {Observable} from 'rxjs';
import * as index from '../index';

test('readfile and rxjs', t => {
    t.equal(
        index.readFileStream('foo') instanceof Observable,
        true,
        'it should return an Observable'
    );

    t.end();
});


test('writefile and rxjs', t => {
    t.equal(
        index.writeFileStream('./foo')('foo') instanceof Observable,
        true,
        'it should return an Observable'
    );

    t.end();
});


test('map a xml file into an object', t => {
    t.plan(1);
开发者ID:r-k-b,项目名称:newsblur-feed-info,代码行数:30,代码来源:index-spec.ts


示例9:

/*
 * Copyright 2016 Franรงois de Campredon <[email protected]>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as tape from 'tape';
import isNonEmptyString from '../../src/utils/IsNonEmptyString';

tape.test('isPlainObject', t => {
  t.equal(isNonEmptyString({}), false, 'it should not accept object');
  t.equal(isNonEmptyString(true), false, 'it should not accept booolean');
  t.equal(isNonEmptyString(3), false, 'it should not accept number');
  t.equal(isNonEmptyString(''), false, 'it should accept plain empty string');
  t.equal(isNonEmptyString('foo'), true, 'it should accept non empty string');
  t.end();
});
开发者ID:fdecampredon,项目名称:vstyle,代码行数:27,代码来源:isNonEmptyString-test.ts


示例10:

Tape.test("Sorting items", (test: any) => {

  test.test("sorting items by name", (test: any) => {
    test.test("two items ordered ascending returned by name A-Z", (test: any) => {

      let data: Array<any> = [{ name: "Anna"}, { name: "zebra"}];
      let queryable = new Queryable<any>(data);
      queryable.sortBy("name");

      test.equal(queryable.toArray()[0].name, "Anna");
      test.equal(queryable.toArray()[1].name, "zebra");

      test.end();
    });

    test.test("two items ordered descending returned by name A-Z", (test: any) => {

      let data: Array<any> = [{ name: "zebra"}, { name: "Anna"}];
      let queryable = new Queryable<any>(data);
      queryable.sortBy("name");

      test.equal(queryable.toArray()[0].name, "Anna");
      test.equal(queryable.toArray()[1].name, "zebra");

      test.end();
    });
  });

  test.test("sorting items by name descending", (test: any) => {
    test.test("two items ordered ascending returned by name Z-A", (test: any) => {

      let data: Array<any> = [{ name: "Anna"}, { name: "zebra"}];
      let queryable = new Queryable<any>(data);
      queryable.sortByDescending("name");

      test.equal(queryable.toArray()[0].name, "zebra");
      test.equal(queryable.toArray()[1].name, "Anna");

      test.end();
    });

    test.test("two items ordered descending returned by name Z-A", (test: any) => {

      let data: Array<any> = [{ name: "zebra"}, { name: "Anna"}];
      let queryable = new Queryable<any>(data);
      queryable.sortByDescending("name");

      test.equal(queryable.toArray()[0].name, "zebra");
      test.equal(queryable.toArray()[1].name, "Anna");

      test.end();
    });
  });
});
开发者ID:sift-it,项目名称:express-sift-it,代码行数:54,代码来源:sort.tests.ts



注:本文中的tape.test函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tape.Test类代码示例发布时间:2022-05-25
下一篇:
TypeScript tape.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap