﻿import * as assert from "assert";
import {getInfoFromString} from "./../../../main";

const code =
`interface SimpleInterface {
}

interface MyInterface {
    myString: string;
    mySecond: number;

    myMethod(): void;
    myMethodWithTypeParameter<T>(): void;
    myMethod2<T>(): string;
    myMethod2<T>(str?: string): string;
}

interface NewSignatureInterface {
    new<T>(str: string, t: T): string;
    new(any: any): string;
}

interface CallSignatureInterface {
    <T>(str: string, t: T): string;
    (num: number): number;
    (any: any): any;
}

interface IndexSignatureInterface {
    [str: string]: Date;
    [num: number]: Date;
}

interface MyTypeParameterInterface<T> {
}

interface MyExtenedInterface extends MyTypeParameterInterface<string> {
}

interface MyMultipleExtenedInterface extends MyTypeParameterInterface<string>, MyInterface {
}
`;

describe("InterfaceDefinition", () => {
    const file = getInfoFromString(code);

    describe("write()", () => {
        it("should have the same output as the input", () => {
            assert.equal(file.write(), code);
        });

        it("should write when calling it on the interface", () => {
            const expectedCode =
`interface SimpleInterface {
}
`;
            assert.equal(file.interfaces[0].write(), expectedCode);
        });
    });
});

﻿import * as assert from "assert";
import {getInfoFromString} from "./../../../main";

const code =
`interface MyInterface {
    myString: string;
    mySecond: number;

    myMethod(): void;
    myMethodWithTypeParameter<T>(): void;
    myMethod2<T>(): string;
    myMethod2<T>(str?: string): string;
}

interface NewSignatureInterface {
    new<T>(str: string, t: T): string;
    new(any: any): string;
}

interface CallSignatureInterface {
    <T>(str: string, t: T): string;
    (num: number): number;
    (any: any): any;
}

interface IndexSignatureInterface {
    [str: string]: Date;
    [num: number]: Date;
}

interface MyTypeParameterInterface<T> {
}

interface MyExtenedInterface extends MyTypeParameterInterface<string> {
}

interface MyMultipleExtenedInterface extends MyTypeParameterInterface<string>, MyInterface {
}
`;

describe("InterfaceDefinition", () => {
    const file = getInfoFromString(code);

    describe("write()", () => {
        it("should have the same output as the input", () => {
            assert.equal(file.write(), code);
        });
    });
});

--- 
+++ 
@@ -2,7 +2,10 @@
 import {getInfoFromString} from "./../../../main";
 
 const code =
-`interface MyInterface {
+`interface SimpleInterface {
+}
+
+interface MyInterface {
     myString: string;
     mySecond: number;
 
@@ -45,5 +48,13 @@
         it("should have the same output as the input", () => {
             assert.equal(file.write(), code);
         });
+
+        it("should write when calling it on the interface", () => {
+            const expectedCode =
+`interface SimpleInterface {
+}
+`;
+            assert.equal(file.interfaces[0].write(), expectedCode);
+        });
     });
 });
Add tests for InterfaceDefinition -> write.
