Skip to content

Commit

Permalink
refactor(tests): Combine tests to improve TD dev experience
Browse files Browse the repository at this point in the history
Total test runtime is down to ~30 seconds, which is MUCH better than the ~3 minutes it used to be for consistantly running the tests during development.
  • Loading branch information
Gerrit0 committed Jan 13, 2020
1 parent 7152031 commit 1fd2185
Show file tree
Hide file tree
Showing 152 changed files with 12,473 additions and 16,305 deletions.
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ yarn.lock
.nyc_output
yarn-error.log

/src/typings/typescript/typescript.js

/tmp/
/etc/
/examples/*/doc
/examples/basic/json.json
/examples/definitely-typed/src/
/examples/plottable/src/
/examples/doppio/src/
/node_modules/
/typescript/
/coverage/
/dist/

typedoc*.tgz
typedoc*.tgz
15 changes: 7 additions & 8 deletions examples/basic/src/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* A variable that is made private via comment.
* @private
*/
// tslint:disable-next-line:no-var-keyword
export var fakePrivateVariable = 'test';

/**
* A variable that is made protected via comment.
* @protected
*/
export var fakeProtectedVariable = 'test';
export let fakeProtectedVariable = 'test';

/**
* A function that is made private via comment.
Expand All @@ -26,19 +27,18 @@ export function fakeProtectedFunction() {}
* A class that is documented as being private.
* @private
*/
export class PrivateClass
{
export class PrivateClass {
/**
* A variable that is made private via comment.
* @private
*/
fakePrivateVariable:string;
fakePrivateVariable: string;

/**
* A variable that is made protected via comment.
* @protected
*/
fakeProtectedVariable:string;
fakeProtectedVariable: string;

/**
* A function that is made private via comment.
Expand All @@ -57,7 +57,6 @@ export class PrivateClass
* A module that is documented as being private.
* @private
*/
export module PrivateModule
{
export module PrivateModule {
export function functionInsidePrivateModule() {}
}
}
112 changes: 47 additions & 65 deletions examples/basic/src/classes.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,78 @@
/**
* This is a simple interface.
*/
export interface INameInterface
{
export interface NameInterface {
/**
* This is a interface member of INameInterface.
*
* It should be inherited by all subinterfaces.
*/
name:string;
name: string;

/**
* This is a interface function of INameInterface.
*
* It should be inherited by all subinterfaces.
*/
getName():string;
getName(): string;
}


/**
* This is a simple interface.
*/
export interface IPrintInterface
{
export interface PrintInterface {
/**
* This is a interface function of IPrintInterface
*
* It should be inherited by all subinterfaces.
*/
print(value:string):void;
print(value: string): void;
}


/**
* This is a interface inheriting from two other interfaces.
*/
export interface IPrintNameInterface extends INameInterface, IPrintInterface
{
export interface PrintNameInterface extends NameInterface, PrintInterface {
/**
* This is a interface function of IPrintNameInterface
*/
printName():void;
printName(): void;
}


/**
* This is a simple base class.
*
* [[include:class-example.md]]
*/
export abstract class BaseClass implements INameInterface
{
export abstract class BaseClass implements NameInterface {
/**
* This is a simple public member.
*/
public name:string;
public name: string;

/**
* This is a simple protected member.
*/
protected kind:number;
protected kind: number;

/**
* This is a static member.
*
* Static members should not be inherited.
*/
static instance:BaseClass;
static instances:BaseClass[];
static instance: BaseClass;
static instances: BaseClass[];

/**
* This is an instance member of an internal class.
*/
private internalClass:InternalClass<keyof BaseClass>;
private internalClass: InternalClass<keyof BaseClass>;


constructor(name:string);
constructor(source:BaseClass);
constructor(name: string);
constructor(source: BaseClass);
constructor() {
if (arguments.length > 0) {
if (typeof arguments[0] == 'string') {
if (typeof arguments[0] === 'string') {
this.name = arguments[0];
} else if (arguments[0] instanceof BaseClass) {
this.name = arguments[0].name;
Expand All @@ -100,11 +92,10 @@ export abstract class BaseClass implements INameInterface
*
* @returns Return the name.
*/
public getName():string {
public getName(): string {
return this.name;
}


/**
* This is a simple static member function.
*
Expand All @@ -113,24 +104,22 @@ export abstract class BaseClass implements INameInterface
*
* @returns Return the name.
*/
static getName():string {
static getName(): string {
return 'A name';
}


/**
* This is a simple member function.
*
* It should be inherited by all subclasses.
*
* @param name The new name.
*/
public setName(name:string) {
public setName(name: string) {
this.name = name;
this.checkName();
}


/**
* This is a simple fat arrow function.
*
Expand All @@ -139,8 +128,7 @@ export abstract class BaseClass implements INameInterface
* @see https://github.com/sebastian-lenz/typedoc/issues/37
*/
public arrowFunction = (param2: string, param1: number): void => {
};

}

/**
* This is a private function.
Expand All @@ -149,30 +137,28 @@ export abstract class BaseClass implements INameInterface
return true;
}


/**
* This is a static function.
*
* Static functions should not be inherited.
*
* @returns An instance of BaseClass.
*/
static getInstance():BaseClass {
static getInstance(): BaseClass {
return BaseClass.instance;
}


/**
* @see https://github.com/sebastian-lenz/typedoc/issues/42
*/
public static caTest(originalValues:BaseClass, newRecord: any, fieldNames:string[], mandatoryFields:string[]): string {
var returnval = "";
var updates: string[] = [];
var allFields: string[] = fieldNames;
for (var j = 0; j < allFields.length; j++) {
var field = allFields[j];
var oldValue = originalValues[field];
var newValue = newRecord[field];
public static caTest(originalValues: BaseClass, newRecord: any, fieldNames: string[], mandatoryFields: string[]): string {
let returnval = '';
let updates: string[] = [];
let allFields: string[] = fieldNames;
for (let j = 0; j < allFields.length; j++) {
let field = allFields[j];
let oldValue = originalValues[field];
let newValue = newRecord[field];
}
return returnval;
}
Expand All @@ -181,9 +167,8 @@ export abstract class BaseClass implements INameInterface
/**
* This is an internal class, it is not exported.
*/
class InternalClass<TTT extends keyof BaseClass>
{
constructor(options:{name:string}) {
class InternalClass<TTT extends keyof BaseClass> {
constructor(options: {name: string}) {

}
}
Expand All @@ -194,19 +179,18 @@ class InternalClass<TTT extends keyof BaseClass>
* This class has no own constructor, so its constructor should be inherited
* from BaseClass.
*/
export class SubClassA extends BaseClass implements IPrintNameInterface
{
public name:string;
export class SubClassA extends BaseClass implements PrintNameInterface {
public name: string;

/**
* This is a simple interface function.
*/
public print(value:string):void { }
public print(value: string): void { }

/**
* @inheritdoc
*/
public printName():void {
public printName(): void {
this.print(this.getName());
}

Expand All @@ -215,7 +199,7 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
*
* @returns The return value.
*/
public get nameProperty():string {
public get nameProperty(): string {
return this.name;
}

Expand All @@ -225,7 +209,7 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
* @param value The new name.
* @returns The return value.
*/
public set nameProperty(value:string) {
public set nameProperty(value: string) {
this.name = value;
}

Expand All @@ -234,7 +218,7 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
*
* @returns The return value.
*/
public get readOnlyNameProperty():string {
public get readOnlyNameProperty(): string {
return this.name;
}

Expand All @@ -244,7 +228,7 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
* @param value The new name.
* @returns The return value.
*/
public set writeOnlyNameProperty(value:string) {
public set writeOnlyNameProperty(value: string) {
this.name = value;
}

Expand All @@ -258,19 +242,18 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
*
* The constructor of the original class should be overwritten.
*/
export class SubClassB extends BaseClass
{
export class SubClassB extends BaseClass {
public name: string;

constructor(name:string) {
constructor(name: string) {
super(name);
}

abstractMethod(): void {

}

doSomething(value:[string, SubClassA, SubClassB]) {
doSomething(value: [string, SubClassA, SubClassB]) {
}
}

Expand All @@ -279,9 +262,8 @@ export class SubClassB extends BaseClass
*
* @param T This a type parameter.
*/
export class GenericClass<T extends BaseClass>
{
public value:T;
export class GenericClass<T extends BaseClass> {
public value: T;

/**
* Constructor short text.
Expand All @@ -292,17 +274,17 @@ export class GenericClass<T extends BaseClass>
* @param p4 Public implicit any property
* @param p5 Readonly property
*/
constructor(p1, protected p2:T, public p3:number, private p4:number, readonly p5: string) {
constructor(p1, protected p2: T, public p3: number, private p4: number, readonly p5: string) {
}

/**
* @param value [[getValue]] is the counterpart.
*/
public setValue(value:T) {
public setValue(value: T) {
this.value = value;
}

public getValue():T {
public getValue(): T {
return this.value;
}
}
Expand Down
Loading

0 comments on commit 1fd2185

Please sign in to comment.