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

TypeScript expect.extend函数代码示例

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

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



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

示例1: function

  jasmine.addMatchers = (jasmineMatchersObject: JasmineMatchersObject) => {
    const jestMatchersObject = Object.create(null);
    Object.keys(jasmineMatchersObject).forEach(name => {
      jestMatchersObject[name] = function(
        this: MatcherState,
        ...args: Array<unknown>
      ): RawMatcherFn {
        // use "expect.extend" if you need to use equality testers (via this.equal)
        const result = jasmineMatchersObject[name](null, null);
        // if there is no 'negativeCompare', both should be handled by `compare`
        const negativeCompare = result.negativeCompare || result.compare;

        return this.isNot
          ? negativeCompare.apply(
              null,
              // @ts-ignore
              args,
            )
          : result.compare.apply(
              null,
              // @ts-ignore
              args,
            );
      };
    });

    const expect = global.expect;
    expect.extend(jestMatchersObject);
  };
开发者ID:Volune,项目名称:jest,代码行数:29,代码来源:jestExpect.ts


示例2: default

export default (config: {expand: boolean}) => {
  global.expect = expect;
  expect.setState({
    expand: config.expand,
  });
  expect.extend({
    toMatchInlineSnapshot,
    toMatchSnapshot,
    toThrowErrorMatchingInlineSnapshot,
    toThrowErrorMatchingSnapshot,
  });

  expect.addSnapshotSerializer = addSerializer;
};
开发者ID:Volune,项目名称:jest,代码行数:14,代码来源:jestExpect.ts


示例3: default

export default (config: {expand: boolean}) => {
  global.expect = expect;
  expect.setState({expand: config.expand});
  expect.extend({
    toMatchInlineSnapshot,
    toMatchSnapshot,
    toThrowErrorMatchingInlineSnapshot,
    toThrowErrorMatchingSnapshot,
  });
  expect.addSnapshotSerializer = addSerializer;

  const jasmine = global.jasmine as Jasmine;
  jasmine.anything = expect.anything;
  jasmine.any = expect.any;
  jasmine.objectContaining = expect.objectContaining;
  jasmine.arrayContaining = expect.arrayContaining;
  jasmine.stringMatching = expect.stringMatching;

  jasmine.addMatchers = (jasmineMatchersObject: JasmineMatchersObject) => {
    const jestMatchersObject = Object.create(null);
    Object.keys(jasmineMatchersObject).forEach(name => {
      jestMatchersObject[name] = function(
        this: MatcherState,
        ...args: Array<unknown>
      ): RawMatcherFn {
        // use "expect.extend" if you need to use equality testers (via this.equal)
        const result = jasmineMatchersObject[name](null, null);
        // if there is no 'negativeCompare', both should be handled by `compare`
        const negativeCompare = result.negativeCompare || result.compare;

        return this.isNot
          ? negativeCompare.apply(
              null,
              // @ts-ignore
              args,
            )
          : result.compare.apply(
              null,
              // @ts-ignore
              args,
            );
      };
    });

    const expect = global.expect;
    expect.extend(jestMatchersObject);
  };
};
开发者ID:Volune,项目名称:jest,代码行数:48,代码来源:jestExpect.ts


示例4: Adapter

// declare var babelHelpers: any
// Object.assign(babelHelpers, { applyDecoratedDescriptor, initializerDefineProperty })
// import "@babel/runtime"

import chalk from "chalk"
import Enzyme from "enzyme"
import Adapter from "enzyme-adapter-react-16"
import expect from "expect"
import { format } from "util"

import "lib/tests/renderUntil"
Enzyme.configure({ adapter: new Adapter() })

// Waiting on https://github.com/thymikee/snapshot-diff/pull/17
import diff from "snapshot-diff"
expect.extend({ toMatchDiffSnapshot: (diff as any).toMatchDiffSnapshot })

jest.mock("react-tracking")
import _track from "react-tracking"
const track = _track as jest.Mock<typeof _track>
track.mockImplementation((_ => x => x) as any)

// Mock this separately so react-tracking can be unmocked in tests but not result in the `window` global being accessed.
jest.mock("react-tracking/build/dispatchTrackingEvent")

jest.mock("./lib/NativeModules/NotificationsManager.tsx", () => ({
  NotificationsManager: {
    addListener: jest.fn(),
  },
}))
开发者ID:artsy,项目名称:emission,代码行数:30,代码来源:setupJest.ts


示例5: extend

import { Mock } from '../src/mock/Mock';
import expect, { extend } from 'expect';
import { It } from '../src/utils/It';
import { expectExtensions } from '../src/utils/ExpectExtensions';

extend(expectExtensions);

class MyService {
  testProperty: number;

  simple() {
    return true;
  }

  multipleArguments(any: any, string: string, number: number, obj: Object) {
    return true;
  }
}

class MyServiceExtended extends MyService {
  simpleString(s: string) {
    return true;
  }

  simpleNumber(s: number) {
    return true;
  }

  simpleObject(s: Object) {
    return true;
  }
开发者ID:otbe,项目名称:emock,代码行数:31,代码来源:Mock.ts


示例6: require

import * as mocha from 'mocha';
import { fromJS } from 'immutable';
//import * as expect from 'expect'; // doesn't work
var expect = require('expect');
import expectImmutable from 'expect-immutable';
expect.extend(expectImmutable);

import { LOGIN_SUCCESS, LOGOUT_SUCCESS } from './SessionActions';
import SessionReducer from './SessionReducer';

describe("SessionReducer", () => {
	context("with a user logged in", () => {
		const state = fromJS({ userId: 'pdavis', displayName: 'Phil' });

		it("can log in a different user", () => {
			const action = { type: LOGIN_SUCCESS, payload: { userId: 'jdavis', displayName: 'Jen' } };
			expect(SessionReducer(state, action)).toEqualImmutable(fromJS({ userId: 'jdavis', displayName: 'Jen' }));
		});

		it("can log out the user", () => {
			const action = { type: LOGOUT_SUCCESS, payload: {} };
			expect(SessionReducer(state, action)).toEqualImmutable(fromJS({}));
		});

		it("can register a new user but won't log them in"); // TODO // and todo permissions checking
	});

	context("with nobody logged in", () => {
		const state = fromJS({});

		it("can log in a user", () => {
开发者ID:PhilipDavis,项目名称:react-redux,代码行数:31,代码来源:SessionReducer_spec.ts


示例7: require

let assert = require('assert');
//import expect, { createSpy, spyOn, isSpy } from 'expect';
let expect = require('expect');
require('../src/Util/Number');	// for clamp

expect.extend( {
	toBeAColor() {
		expect.assert(
			this.actual.match(/^#[a-fA-F0-9]{3,6}$/),
			'expected %s to be an HTML color',
			this.actual
		);
		return this;
	},

	toBeSameTime(time: Date) {
		expect.assert(
			this.actual.getTime() == time.getTime(),
			'expected %s to be the same time\n'+
			this.actual.getTime() + ' != ' + time.getTime()+'\n'+
			this.actual.toString('yyyy-MM-dd HH:mm:ss') + ' != ' + time.toString('yyyy-MM-dd HH:mm:ss'),
			this.actual
		);
		return this;
	}
});

class MonthSelectTest {

	/**
	 * constructor should make an object
开发者ID:spidgorny,项目名称:umsaetze,代码行数:31,代码来源:MonthSelect.test.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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