当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ava.test函数代码示例

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


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

示例1: test

Object.keys(FORMAT_DEFAULTS.date).forEach(format => {
    test(`formatDate should format with the short hand "${format}"`, t => {
        t.context.formats.setLocale('en-US');
        t.is(t.context.formats.formatDate('12/04/1987', format), SHORT_HAND_VALUES['en-US'][format]);
        t.context.formats.setLocale('fr-FR');
        t.is(t.context.formats.formatDate('12/04/1987', format), SHORT_HAND_VALUES['fr-FR'][format]);
    });
});
开发者ID:bullhorn,项目名称:chomsky,代码行数:8,代码来源:formats.spec.ts

示例2: test

import { test } from 'ava'
import { MqttUtil } from './utility'

const util = MqttUtil

test('join', t => {
  t.is(util.join(['foo', 'bar', 'baz']), 'foo/bar/baz')
  t.is(util.join('foo', 'bar', 'baz'), 'foo/bar/baz')
})
test('split', t => {
  t.deepEqual(util.split('foo/bar/baz'), ['foo', 'bar', 'baz'])
})
test('strip', t => {
  t.deepEqual(util.strip('foo/bar/baz', 0, 1), 'bar/baz')
  t.deepEqual(util.strip('foo/bar/baz', 1, 1), 'foo/baz')
  t.deepEqual(util.strip('foo/bar/baz', 2, 1), 'foo/bar')
  t.deepEqual(util.strip('foo/bar/baz', 1, 2), 'foo')
  t.deepEqual(util.strip('foo/bar/baz'), 'foo/baz')
})

test('inject', t => {
  t.deepEqual(util.inject('foo/bar/baz/foo', 1, 2), 'foo/foo')
  t.deepEqual(util.inject('foo/bar/baz/foo', 1), 'foo')
  t.deepEqual(util.inject('foo/bar/baz/foo', 1, 3), 'foo')
  t.deepEqual(util.inject('foo/bar/baz/foo', 2), 'foo/bar')
  t.deepEqual(
    util.inject('foo/bar/baz/foo', 1, 2, 'bar/baz'),
    'foo/bar/baz/foo'
  )
})
开发者ID:ha4us,项目名称:ha4us.old,代码行数:30,代码来源:utility.spec.ts

示例3: test

test("it can time travel", t => {
    const m = TestModel.create()
    const tt = TimeTraveller.create({}, { targetStore: m })

    t.is(tt.canUndo, false)
    t.is(tt.canRedo, false)
    t.is(m.x, 1)

    m.inc()
    t.is(tt.canUndo, true)
    t.is(tt.canRedo, false)
    t.is(m.x, 2)

    m.inc()
    t.is(tt.canUndo, true)
    t.is(tt.canRedo, false)
    t.is(m.x, 3)

    tt.undo()
    t.is(m.x, 2)
    t.is(tt.canUndo, true)
    t.is(tt.canRedo, true)

    tt.undo()
    t.is(m.x, 1)
    t.is(tt.canUndo, false)
    t.is(tt.canRedo, true)

    tt.redo()
    t.is(m.x, 2)
    t.is(tt.canUndo, true)
    t.is(tt.canRedo, true)

    // resets 'future'
    m.inc()
    t.is(m.x, 3)
    t.is(tt.canUndo, true)
    t.is(tt.canRedo, false)
})
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:39,代码来源:TimeTraveller.ts

示例4: test

import { types } from "../src"
import { test } from "ava"

test("It should warn when using types.maybe(types.frozen)", t => {
    if (process.env.NODE_ENV === "development") {
        t.throws(
            () => types.maybe(types.frozen),
            `[mobx-state-tree] Unable to declare \`types.maybe(types.frozen)\`. Frozen already accepts \`null\`. Consider using \`types.optional(types.frozen, null)\` instead.`
        )
    } else {
        t.is(true, true)
    }
})
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:13,代码来源:maybe.ts

示例5: test

/**
 * Created by Kuitos
 * @homepage https://github.com/kuitos/
 * @since 2018/3/19 下午11:22
 */

import { test } from 'ava';
import isCacheLike from '../isCacheLike';

test('a object with specified method will be regard as cache', t => {

	let cache = {};
	t.is(isCacheLike(cache), false);

	cache = {

		// tslint:disable-next-line
		get() {
		},
		// tslint:disable-next-line
		set() {
		},
		// tslint:disable-next-line
		del() {
		},
	};
	t.is(isCacheLike(cache), true);
});
开发者ID:niantuo,项目名称:axios-extensions,代码行数:28,代码来源:test-isCacheLike.ts

示例6: LateStore1

import { types } from "../src"
import { test } from "ava"
import { LateTodo2, LateStore2 } from "./circular2"
// combine function hosting with types.late to support circular refs between files!
export function LateStore1() {
    return types.model({
        todo: types.late(LateTodo2)
    })
}
export function LateTodo1() {
    return types.model({
        done: types.boolean
    })
}

test("circular test 1 should work", t => {
    const Store1 = types.late(LateStore1)
    const Store2 = types.late(LateStore2)
    t.is(Store1.is({}), false)
    t.is(Store1.is({ todo: { done: true } }), true)
    const s1 = Store1.create({ todo: { done: true } })
    t.is(s1.todo.done, true)
    t.is(Store2.is({}), false)
    t.is(Store2.is({ todo: { done: true } }), true)
    const s2 = Store2.create({ todo: { done: true } })
    t.is(s2.todo.done, true)
})
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:27,代码来源:circular1.ts

示例7: test

import { test } from 'ava'
import { createProvideJWTFn } from '../src/requestJWT'
import { privateKey } from './keys'

test('createProvideJWTFn() should create a function that returns a new JWT on every call', t => {
  const provideJWT = createProvideJWTFn('mockClientID', 'mockTokenEndpointURL',
    'mockThumbprint', privateKey.pemBuffer)
  t.true(typeof provideJWT() === 'string')
})
开发者ID:juriwiens,项目名称:o365-service-auth,代码行数:9,代码来源:requestJWT.test.ts

示例8: test

test('finbot > list builds > when no token set', (t) => {
  // arrange
  const robotName = 'irobot';

  const robot = new MockRobot();
  robot.name = robotName;
  const respondStub = sinon.stub(robot, 'respond');

  const response = new MockResponse();
  const replyStub = sinon.stub(response, 'reply');

  const secureBrain = new MockSecureBrain();
  sinon.stub(secureBrain, 'get').returns(null);

  response.message = {
    room: undefined,
    user: {
      id: 'asdsad',
      name: undefined,
      room: undefined
    },
    text: undefined,
    id: undefined,
    done: false
  };

  BuildsScript(robot, undefined, secureBrain);

  // act
  const responders = robot.getRespondMatches('list builds of a project slug');
  const [responder, match] = responders[0];
  response.match = match;
  responder.callback(response);

  // assert
  assert.strictEqual(responders.length, 1);
  sinon.assert.calledWith(replyStub, `You must whisper me your AppVeyor API token with "/msg @${robotName} set token <token>" first`);
});
开发者ID:Codesleuth,项目名称:hubot-appveyor,代码行数:38,代码来源:list_builds_with_no_token.tests.ts

示例9: BudgetContext

import Expense from "../client/expenses/expense";
import * as it from "../client/rates/intervaltype";
import Rate from "../client/rates/rate";
import {ExpenseDataSource, ExpenseController} from "../client/expenses/expensecontroller";

ava.test.beforeEach(t => {
    t.context.budgetContext = new BudgetContext();
});

ava.test("update", t => {
    let bc = t.context.budgetContext;
    let date = moment([2016, 0, 5]);
    let controller = new ExpenseController(bc, date);

    t.is(controller.vm.list().length, 0);
    bc.addExpense(new Expense("test", date, -25));
    t.is(controller.vm.list().length, 1);
    t.is(controller.vm.list()[0].id(), 1);
    t.is(controller.vm.total(), -25);

    controller.vm.remove(1);
    t.is(controller.vm.list().length, 0);
});

ava.test("add", t => {
    let bc = t.context.budgetContext;
    let date = moment([2016, 0, 5]);
    let controller = new ExpenseController(bc, date);

    let expense = controller.vm.item();
    expense.name("test");
    expense.day(date);
开发者ID:AlexanderLindsay,项目名称:dailybudgeteer,代码行数:32,代码来源:testExpenseController.ts

示例10: test

import * as fs from 'fs'
import * as path from 'path'
import { buildSchema } from 'graphql'
import { TypescriptDefinitionsGenerator } from './typescript-definitions'
import { test } from 'ava'

const typeDefs = fs.readFileSync(
  path.join(__dirname, '../../src/codegen/fixtures/schema.graphql'),
  'utf-8',
)
test('typescript definitions generator', t => {
  const schema = buildSchema(typeDefs)
  const generator = new TypescriptDefinitionsGenerator({
    schema,
    internalTypes: [],
  })
  const result = generator.render()
  t.snapshot(result)
})
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:19,代码来源:typescript-definitions.test.ts


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