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

TypeScript chai.use函数代码示例

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

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



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

示例1:

import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';

import {
  PrecedenceOptions,
  requireScopesMiddleware,
  ScopeMiddlewareOptions
} from '../../../src';

import { Response, Request } from 'express';

chai.use(chaiAsPromised);
chai.use(sinonChai);
const expect = chai.expect;

describe('express tooling', () => {

  const loggerMock = undefined;

  const createRequestMock = (scopes: String[]): Request => ({
    get: (name: string) => name,
    $$tokeninfo: {
      scope: scopes
    }
  } as any as Request);

  const createResponseMock = (): Response => ({
    sendStatus: sinon.spy((status: string) => undefined)
  } as any as Response);
开发者ID:zalando-incubator,项目名称:lib-oauth-tooling,代码行数:31,代码来源:require-scopes-middleware.ts


示例2: use

import 'reflect-metadata';
import {expect, use} from 'chai';
import { createStore } from 'redux';
import {NgRedux} from '../../components/ng-redux';
import {select} from '../../decorators/select';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';
import * as _ from 'lodash';

use(sinonChai);

describe('@select', () => {

  let ngRedux;
  let targetObj;
  let defaultState;
  let rootReducer;
  let mockAppRef;

  beforeEach(() => {
    defaultState = {
      foo: 'bar',
      baz: -1
    };
    rootReducer = (state = defaultState, action) => {
      const newState = Object.assign({}, state, { baz: action.payload });
      return newState;
    };
    targetObj = {};
    mockAppRef = {
      tick: sinon.spy()
开发者ID:SaltyDH,项目名称:ng2-redux,代码行数:31,代码来源:select.spec.ts


示例3: getStateFlagName

import * as chai from 'chai';
import * as sinonChai from 'sinon-chai';
import { State } from '../src/index';

chai.use(sinonChai);
chai.use(function(_chai, utils) {
  const Assertion = _chai['Assertion'];

  Assertion.addProperty('$state');
  function getStateFlagName(state) {
    if (state === 0) return 'none';
    const names = [];
    if (state & State.isBinding) names.push('isBinding');
    if (state & State.isBound) names.push('isBound');
    if (state & State.isAttaching) names.push('isAttaching');
    if (state & State.isAttached) names.push('isAttached');
    if (state & State.isMounted) names.push('isMounted');
    if (state & State.isDetaching) names.push('isDetaching');
    if (state & State.isUnbinding) names.push('isUnbinding');
    if (state & State.isCached) names.push('isCached');
    return names.join('|');
  }

  for (const stateFlag of [
    State.none,
    State.isBinding,
    State.isBound,
    State.isAttaching,
    State.isAttached,
    State.isMounted,
    State.isDetaching,
开发者ID:aurelia,项目名称:aurelia,代码行数:31,代码来源:setup-node.ts


示例4: require

/* tslint:disable:no-unused-expression */
import logger from "./logger"
import { isPortAvailable } from "./net"
const chai = require("chai")
const chaiAsPromised = require("chai-as-promised")
const expect = chai.expect

chai.use(chaiAsPromised)

describe("Net", () => {
  const port = 4567
  const host = "0.0.0.0"
  const specialPort = process.platform.match("win") ? -1 : 80

  describe("#isPortAvailable", () => {
    context("when the port is not allowed to be bound", () => {
      it("returns a rejected promise", () => {
        return expect(isPortAvailable(specialPort, host)).to.eventually.be
          .rejected
      })
    })

    context("when the port is available", () => {
      it("returns a fulfilled promise", () => {
        return expect(isPortAvailable(port, host)).to.eventually.be.fulfilled
      })
    })

    context("when the port is unavailable", () => {
      it("returns a rejected promise", () => {
        createServer(port).then((_: { close(): any }) => {
开发者ID:pact-foundation,项目名称:pact-js,代码行数:31,代码来源:net.spec.ts


示例5:

import * as _ from 'lodash';
import * as chai from 'chai';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';

chai.use(sinonChai);

let expect: Chai.ExpectStatic = chai.expect;

describe('basics', () => {
	describe('primitivos', () => {
		it('deve ser assertivo nos tipos', () => {
			let booleanVar: boolean = true || false;
			let stringVar: string = 'string';
			let numberVar: number = 0;
			let undefinedVar: any = undefined;
			let nullVar: any = null;

			expect(booleanVar).to.be.a('boolean');
			expect(stringVar).to.be.a('string');
			expect(numberVar).to.be.a('number');
			expect(undefinedVar).to.be.undefined;
			expect(nullVar).to.be.null;
		});
	});

	describe('declaração de variáveis', () => {
		it('deve retornar undefined se variável não for atribuída', () => {
			let a: string;

			expect(a).to.be.undefined;
开发者ID:feliperohdee,项目名称:node-meetup-cheatsheet,代码行数:31,代码来源:basic.ts


示例6: test_somethingSyntax



import * as chai from 'chai';
import * as chaiThings from 'chai-things';
chai.use(chaiThings);

function test_somethingSyntax() {
    [].should.not.include.something();
    [].should.not.include.something.that.equals(1);

    var array = [{ a: 1 }, { b: 2 }];
    array.should.include.something();
    array.should.include.something.that.deep.equals({ b: 2 });
    array.should.include.something.that.not.deep.equals({ b: 2 });
    array.should.not.include.something.that.deep.equals({ c: 3 });
    array.should.include.something.that.not.deep.equals({ c: 3 });
    array.should.include.something.with.property('b', 2);
    array.should.not.include.something.with.property('b', 3);

    chai.expect(array).to.include.something();
    chai.expect(array).to.include.something.that.deep.equals({ b: 2 });
    chai.expect(array).to.include.something.that.not.deep.equals({ b: 2 });
    chai.expect(array).not.to.include.something.that.deep.equals({ c: 3 });
    chai.expect(array).to.include.something.that.not.deep.equals({ c: 3 });
    chai.expect(array).to.include.something.with.property('b', 2);
    chai.expect(array).not.to.include.something.with.property('b', 3);

    var array2 = [{ a: 'b' }, { a: 'b' }];
    array2.should.include.something.that.have.property("a");
    array2.should.include.something.that.have.property("a").not.equal("d");
    chai.expect(array2).to.include.something.that.have.property("a");
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:29,代码来源:chai-things-tests.ts


示例7: constructor

import * as chai from 'chai';
import { expect } from 'chai';
import * as spies from 'chai-spies';
import { getInfos } from './query.service';

chai.use(spies);

describe('Query service', () => {
  class MockRes {
    code: number;
    data: any;

    constructor() {}

    status(status: number) {
      this.code = status;
    }

    send(data: any) {
      this.data = data;
    }
  }

  it('should call find of model', () => {
    const spy = chai.spy();
    const model = {
      find: () => {
        spy();
        return Promise.resolve([{key: 'foo', value: 'bar'}]);
      }
    };
开发者ID:Cyphle,项目名称:Portfolio,代码行数:31,代码来源:query.service.spec.ts


示例8: chaiPlugin

/* eslint-env mocha */
// @flow
import { expect, use } from 'chai';
import Kefir from 'kefir';
import { chaiPlugin } from 'brookjs-desalinate';
import view from '../view';

const { plugin, stream, prop, value, send, error, end } = chaiPlugin({ Kefir });
use(plugin);

describe('view', () => {
  it('should be a function', () => {
    expect(view).to.be.a('function');
  });

  it('should take a callback and return a function', () => {
    expect(view(x => x)).to.be.a('function');
  });

  it('should be able to be passed to Observable#thru', () => {
    expect(stream().thru(view(x => x))).to.be.an.observable.stream();
    expect(prop().thru(view(x => x))).to.be.an.observable.property();
  });

  it('should emit result from function callback', () => {
    const a = stream();

    expect(a.thru(view(x => !x))).to.emit([value(true)], () => {
      send(a, [value(false)]);
    });
  });
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:31,代码来源:view.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript chai.assert类代码示例发布时间:2022-05-25
下一篇:
TypeScript chai.spy函数代码示例发布时间: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