Remove or fix dependencies on mocha by other declarations

If dependency is unnecessary, replaces with stub declarations
If dependency is necessary, declares a requirement on at least TS2.1 to match mocha's
This commit is contained in:
Andrew Bradley 2018-03-11 19:27:28 -04:00
parent 9bb6dc2f8b
commit 9ea8da2d0e
22 changed files with 92 additions and 31 deletions

View File

@ -1,8 +1,11 @@
/// <reference types="mocha" />
/// <reference types="node" />
import assert = require('assert');
import { BinTree, RBTree } from 'bintrees';
// Declaring shims removes mocha dependency. These tests are never executed, only typechecked, so this is fine.
declare function describe(description: string, callback: () => void): void;
declare function it(description: string, callback: () => void): void;
describe('bintrees', () => {
it('builds a simple tree', () => {
let treeA = new RBTree((a: number, b: number) => a - b);

View File

@ -2,6 +2,7 @@
// Project: https://github.com/suchipi/chai-jest-snapshot#readme
// Definitions by: Matt Perry <https://github.com/mattvperry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="chai" />
/// <reference types="mocha" />

View File

@ -1,6 +1,5 @@
import * as chai from 'chai';
import * as spies from 'chai-spies';
import * as Mocha from 'mocha';
function original(): void {
// do something cool

View File

@ -1,6 +1,4 @@
/// <reference types="mocha" />
var should = chai.should();
var assert = chai.assert;
var expect = chai.expect;
@ -8,6 +6,11 @@ var expect = chai.expect;
import chai_string = require("chai-string");
chai.use(chai_string);
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe('chai-string', function() {
describe('#startsWith', function() {

View File

@ -1,8 +1,12 @@
/// <reference types="mocha" />
declare function equal<T>(a: T, b: T): void;
declare function deepEqual<T>(a: T, b: T): void;
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
import * as createError from 'create-error';
// Example taken from https://github.com/tgriesser/create-error/blob/0.3.1/README.md#use

View File

@ -1,6 +1,10 @@
/// <reference types="mocha" />
/// <reference types="chai" />
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
var expect = chai.expect;
describe('Skeleton', function(){
var element: Element, $element: d3.Selection<any>, $svg: d3.Selection<any>, skeleton: d3kit.Skeleton;

View File

@ -1,8 +1,11 @@
/// <reference types="mocha"" />
import { Expectation, Extension, Spy, createSpy, isSpy, assert, spyOn, extend, restoreSpies } from 'expect';
import * as expect from 'expect';
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe('chaining assertions', () => {
it('should allow chaining for array-like applications', () => {
expect([ 1, 2, 'foo', 3 ])

View File

@ -1,9 +1,12 @@
/// <reference types="mocha" />
// transplant from https://github.com/spmason/expectations/blob/695c25bd35bb1751533a8082a5aa378e3e1b381f/test/expect.tests.js
var root = this;
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe('expect', ()=> {
describe('toEqual', ()=> {
it('can expect true to be true', ()=> {

View File

@ -1,5 +1,4 @@
///<reference types="node" />
///<reference types="mocha" />
'use strict';
@ -11,6 +10,11 @@ import { EventEmitter, EventSubscription } from 'fbemitter';
import * as util from 'util';
import * as assert from 'assert';
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe('EventEmitter', function tests() {
'use strict';

View File

@ -2,6 +2,7 @@
// Project: https://github.com/sindresorhus/gulp-mocha
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="mocha"/>
/// <reference types="node"/>

View File

@ -1,5 +1,3 @@
/// <reference types="mocha" />
import gulp = require('gulp');
import util = require('gulp-util');
import path = require('path');
@ -7,6 +5,11 @@ import Stream = require('stream');
import through = require('through2');
const es = require('event-stream');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
// TODO: These aren't useful as types tests since they take `any`.
declare const should: ShouldStatic;
interface ShouldStatic {

View File

@ -1,9 +1,13 @@
import fs = require('hexo-fs');
import { join, dirname } from 'path';
import 'mocha';
import chai = require('chai');
import Promise = require('bluebird');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
const should = chai.should();
function createDummyFolder(path: string) {
@ -198,7 +202,8 @@ it('copyFile() - callback', callback => {
if (err) return callback(err);
fs.readFile(dest, (err, content) => {
if (err) return callback(err);
if (err)
return callback(err);
content!.should.eql(body);
Promise.all([

View File

@ -1,6 +1,10 @@
/// <reference types="mocha" />
declare var expect: any;
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
import id = require('incremental-dom');
var patch = id.patch;
var elementVoid = id.elementVoid;

View File

@ -1,10 +1,13 @@
/// <reference types="mocha" />
import { Buffer } from 'buffer';
import assert = require('assert');
import * as async from 'async';
import PQ = require('libpq');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
declare const _: { times<T>(n: number, f: () => T): T[] };
declare const ok: Function;

View File

@ -2,6 +2,7 @@
// Project: https://github.com/rprieto/mocha-steps
// Definitions by: AryloYeung <https://github.com/Arylo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="mocha" />

View File

@ -1,8 +1,11 @@
/// <reference types="mocha" />
import assert = require('assert')
import fs = require('mz/fs')
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe('fs', function () {
it('.stat()', function (done) {

View File

@ -1,11 +1,14 @@
/// <reference types="mocha" />
import oxford = require("project-oxford");
import assert = require('assert');
import _Promise = require('bluebird');
import fs = require('fs');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
var client = new oxford.Client(process.env.OXFORD_KEY);
// Store variables, no point in calling the api too often

View File

@ -1,5 +1,7 @@
/// <reference types="mocha" />
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
function test_createFrame() {
var frame: QFrame;

View File

@ -13,7 +13,10 @@ import File = require('vinyl');
// const spies = require('./spy');
declare const spies: any;
import 'mocha';
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
// TODO: These aren't useful as types tests since they take `any`.
declare const should: ShouldStatic;

View File

@ -1,9 +1,12 @@
/// <reference types="mocha" />
import File = require('vinyl');
import Stream = require('stream');
import fs = require('fs');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
declare var fakeStream: NodeJS.ReadWriteStream;
// TODO: These aren't useful as types tests since they take `any`.

View File

@ -1,5 +1,3 @@
/// <reference types="mocha" />
import * as fs from 'fs';
import * as path from 'path';
import expect = require('expect');
@ -8,6 +6,11 @@ const cloneable = require('cloneable-readable');
import File = require('vinyl');
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
/**
* Custom and private properties needed for tests.
*

View File

@ -1,8 +1,11 @@
/// <reference types="mocha" />
import * as webdriverio from "webdriverio";
import { assert } from "chai";
// Stub mocha functions
const {describe, it, before, after, beforeEach, afterEach} = null as any as {
[s: string]: ((s: string, cb: (done: any) => void) => void) & ((cb: (done: any) => void) => void) & {only: any, skip: any};
};
describe("webdriver.io page", () => {
it("should have the right title - the good old callback way", () => {
assert.equal(