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

TypeScript ava类代码示例

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

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



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

示例1:

import * as test from "ava";
import { factorial } from "../model/utils";

test("factorial", t => {
	t.is(factorial(0), 1);
	t.is(factorial(1), 1);
	t.is(factorial(2), 2);
	t.is(factorial(3), 6);
	t.is(factorial(4), 24);
});
开发者ID:PacktPublishing,项目名称:TypeScript-Blueprints,代码行数:10,代码来源:utils.ts


示例2: res

import dispatch from '../../lib/middleware/dispatch';
import * as test from 'ava';
import { app } from '../fixtures/overland';
import MyCtrl from '../fixtures/ctrl';
import * as Router from 'koa-router';

test('should invoke action', async function(t) {
  app.controllers.set('myApp.myCtrl', MyCtrl);
  const res = dispatch(app, 'myApp.myCtrl', 'index', {});  
  const ctx = { body: '', router: new Router() };
  await res(ctx);
  t.same(ctx.body, 'Hello, world.');
});
开发者ID:gitter-badger,项目名称:overland,代码行数:13,代码来源:dispatch.ts


示例3: function

import { Router } from '../../core';
import * as test from 'ava';

test(`should generate url helpers`, async function(t) {
  
  const r1 = new Router();
  r1.app = 'myApp';
  r1.resources('posts', { controller: 'post' }); 
  
  const r2 = new Router();
  r2.use('myApp', r1);
  
  t.ok(Object.keys(r2.helpers), [ 'myAppPosts', 'myAppNewPost', 'myAppEditPost', 'myAppPost' ]);
});
开发者ID:gitter-badger,项目名称:overland,代码行数:14,代码来源:routes.ts


示例4: Router

import * as test from 'ava';
import MyApp from '../fixtures/app';
import { App } from '../../core';
import { Router } from '../../core';
import { app as overland } from '../fixtures/overland';

test(`should have a readable/writeable 'app' property`, t => {
  const MyApp2 = Object.create(MyApp);
  MyApp2.app = 'Foobar';
  t.not(MyApp2.app, MyApp.app);
});

test(`'app' property should default to name of the constructor`, t => {
  t.is(MyApp.app, 'myBlog');
})

test(`should have a readable/writeable 'routes' property`, t => {
  const MyApp2 = Object.create(MyApp);
  MyApp2.routes = new Router();
  t.not(MyApp.routes, MyApp2.routes);
});

test(`should have a readable/writeable 'controllers' property`, t => {
  const MyApp2 = Object.create(MyApp);
  MyApp2.controllers = [];
  t.not(MyApp.controllers, MyApp2.controllers);
});

test(`should have a readable/writeable 'model' property`, t => {
  const MyApp2 = Object.create(MyApp);
  MyApp2.models = [];
开发者ID:gitter-badger,项目名称:overland,代码行数:31,代码来源:app.ts


示例5:

import * as test from 'ava';
import { Model } from 'objection';
import * as Models from '../fixtures/models';
import Migration from '../../lib/db/migration';
import * as Knex from 'knex';

test('should set tableName to function ctor name', t => {
  t.is(Models.One.tableName, 'myBlog_One');
});

test('should allow tableName to be set manually', t => {
  const M2 = Object.create(Models.One);
  M2.tableName = 'foobar';
  t.is(M2.tableName, 'foobar');
})

test('should generate ManyToMany relation mappings', t => {
  const actual = Models.Four.relationMappings;
  const expected = {
    modelClass: Models.Two,
    relation: Model.ManyToManyRelation,
    join: {
      from: 'myBlog_Four.id',
      to: 'myBlog_Two.myId',
      through: {
        modelClass: undefined,
        from: 'myBlog_Four_Two.fourId',
        to: 'myBlog_Four_Two.twoId'
      }
    }
  };
开发者ID:gitter-badger,项目名称:overland,代码行数:31,代码来源:model.ts


示例6: function

import { app } from '../fixtures/overland';
import MyApp from '../fixtures/app';
import Overland, { Router } from '../../core';
import { redirectTo } from '../../lib/helpers';
import * as test from 'ava';

test(`should generate a url from a model instance`, async function(t) {
  const res = await app.init()
  const r = redirectTo.bind(res);
  const Ctor = res.modelConstructors()[4];
  const instance = new Ctor({ id: 2 });
  const out = r(instance);
  t.same(out, '/app/posts/2');
});
开发者ID:gitter-badger,项目名称:overland,代码行数:14,代码来源:redirectTo.ts


示例7: override

import * as test from 'ava';
import { app } from '../fixtures/overland';
import MyCtrl from '../fixtures/ctrl';
import { request } from 'http';

test('should override provided method', async function(t) {
  
  await app.init();
  
  const ctx = {
    method: 'post',
    request: {
      body: { _method: 'patch' }
    }
  };
  
  let method;
  
  await override()(ctx, async function() {
    return async function(ctx) {
      method = ctx.method;
    }(ctx);
  });
  
  t.same(method, 'patch');
});

test('should ignore requests without request bodies', async function(t) {
  
  await app.init();
  
开发者ID:gitter-badger,项目名称:overland,代码行数:30,代码来源:override.ts


示例8: cb

    const obj = {};
    q.forEach(q => obj[q.name] = true);
    cb(obj);
  });
});

test(`should correctly determine a table drop.`, async function(t) {

  const m = new Migration(drop.one, drop.two);

  t.same(await m.schema(), {
    models: {
      added: {},
      altered: {},
      deleted: {
        test_table: true
      }
    },
    fields: {
      added: {},
      altered: {},
      deleted: {}
    }
  });
});

test(`should correctly determine a table rename.`, async function(t) {

  const m = new Migration(rename.one, rename.two);

  t.same(await m.schema(), {
开发者ID:gitter-badger,项目名称:overland,代码行数:31,代码来源:modelSchema.ts


示例9: cb

    const obj = {};
    q.forEach(q => obj[q.name] = true);
    cb(obj);
  });
});

test(`should correctly determine a field drop`, async function(t) {
  
  const m = new Migration(drop.one, drop.two);
  
  t.same(await m.schema(), {
    models: {
      added: {},
      altered: {},
      deleted: {}
    },
    fields: {
      added: {},
      altered: {},
      deleted: {
        test_table: { myText: true }
      }
    }
  });
});

test(`should correctly determine a field rename`, async function(t) {
  const m = new Migration(rename.one, rename.two);
  
  t.same(await m.schema(), {
    models: {
开发者ID:gitter-badger,项目名称:overland,代码行数:31,代码来源:fieldSchema.ts


示例10:

  t.context.log = console.log; 
  console.log = sinon.spy();
});

test.afterEach(t => {
  console.log = t.context.log;
});

test(`Should filter field props out of table.`, t => {
  const res = Migration.filterFields({
    app: 'myApp',
    tableName: 'myApp_foo',
    name: 'foo',
    fields: [
      { name: 'bar' },
      { name: 'baz' }
    ]
  })
  t.same(res, {
    app: 'myApp',
    tableName: 'myApp_foo',
    name: 'foo'
  });
});


test(`Should filter field props out of an array of tables.`, t => {
  const res = Migration.filterFields([{
    app: 'myApp',
    tableName: 'myApp_foo',
    name: 'foo',
    fields: [
开发者ID:gitter-badger,项目名称:overland,代码行数:32,代码来源:migration.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript axios类代码示例发布时间:2022-05-28
下一篇:
TypeScript autoprefixer类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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