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


TypeScript chai.use函数代码示例

本文整理汇总了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;未经允许,请勿转载。