DefinitelyTyped/types/ember-mocha/index.d.ts
Rebecca Turner 12453a8fe1 [chai] Provide type definitions for chai.use (#37451)
* chai: Add types for chai.use and chai.util

Helps developers write Chai plugins; requested in #29922.

Closes #29922.

* Updated dependencies on Chai

- Minimum TS version: 3.0
    - Version bumps to TS 3.0 for the following type definitions which
      depend on chai directly or indirectly:
            bardjs, chai, chai-almost, chai-arrays, chai-as-promised,
            chai-datetime, chai-dom, chai-enzyme, chai-fs, chai-fuzzy,
            chai-jest-snapshot, chai-jquery, chai-json-schema,
            chai-moment, chai-oequal, chai-roughly, chai-spies,
            chai-string, chai-subset, chai-things, chai-uuid,
            chai-webdriverio, chai-xml, d3kit, deep-equal-in-any-order,
            dirty-chai, ember-mocha, hexo, hexo-log, hexo-util,
            jsx-chai, karma-chai, karma-chai-sinon, redux-test-utils,
            and sinon-chai
- Use Chai.ChaiPlugin instead of (chai: any, utils: any) => void

* Factor out pathval types

- Forgot that the pathval types aren't merged yet

* Factor out pathval types

- Forgot that the pathval types aren't merged yet

* Make 'chainingBehavior' non-mandatory
2019-08-08 08:58:47 -07:00

81 lines
2.8 KiB
TypeScript

// Type definitions for ember-mocha 0.14
// Project: https://github.com/emberjs/ember-mocha#readme
// Definitions by: Derek Wickern <https://github.com/dwickern>
// Simon Ihmig <https://github.com/simonihmig>
// Mike North <https://github.com/mike-north>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { TestContext, ModuleCallbacks } from "ember-test-helpers";
import Ember from 'ember';
import { it as mochaIt, ISuiteCallbackContext } from 'mocha';
// these globals are re-exported as named exports by ember-mocha
type mochaBefore = typeof before;
type mochaAfter = typeof after;
type mochaBeforeEach = typeof beforeEach;
type mochaAfterEach = typeof afterEach;
type mochaSetup = typeof setup;
type mochaTeardown = typeof teardown;
type mochaSuiteSetup = typeof suiteSetup;
type mochaSuiteTeardown = typeof suiteTeardown;
declare module 'ember-mocha' {
interface ContextDefinitionFunction {
(name: string, description: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void;
(name: string, description: string, tests: (this: ISuiteCallbackContext) => void): void;
(name: string, callbacks: ModuleCallbacks, tests: (this: ISuiteCallbackContext) => void): void;
(name: string, tests: (this: ISuiteCallbackContext) => void): void;
}
interface ContextDefinition extends ContextDefinitionFunction {
only: ContextDefinitionFunction;
skip: ContextDefinitionFunction;
}
interface SetupTest {
(name?: string, callbacks?: ModuleCallbacks): void;
(callbacks: ModuleCallbacks): void;
}
interface TestHooks {
beforeEach: mochaBeforeEach;
afterEach: mochaAfterEach;
}
interface SetupOptions {
resolver: Ember.Resolver;
}
type NewSetupTest = (options?: SetupOptions) => TestHooks;
/** @deprecated Use setupTest instead */
export const describeModule: ContextDefinition;
/** @deprecated Use setupComponentTest instead */
export const describeComponent: ContextDefinition;
/** @deprecated Use setupModelTest instead */
export const describeModel: ContextDefinition;
export const setupTest: NewSetupTest & SetupTest;
export const setupAcceptanceTest: SetupTest;
export const setupComponentTest: SetupTest;
export const setupModelTest: SetupTest;
export const setupRenderingTest: NewSetupTest;
export const setupApplicationTest: NewSetupTest;
export const it: typeof mochaIt;
/**
* Sets a Resolver globally which will be used to look up objects from each test's container.
*/
export function setResolver(resolver: Ember.Resolver): void;
}
declare module 'mocha' {
// augment test callback context
interface Context extends TestContext {}
}