diff --git a/samples/client/petstore/typescript/tests/default/.gitignore b/samples/client/petstore/typescript/tests/default/.gitignore new file mode 100644 index 00000000000..1521c8b7652 --- /dev/null +++ b/samples/client/petstore/typescript/tests/default/.gitignore @@ -0,0 +1 @@ +dist diff --git a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js b/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js deleted file mode 100644 index e0e55de464a..00000000000 --- a/samples/client/petstore/typescript/tests/default/dist/auth/auth.test.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var ts_petstore_client_2 = require("ts-petstore-client"); -var chai_1 = require("chai"); -describe("Security Authentication", function () { - describe("No Authentication", function () { - it("No Authentication", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var noAuth = new ts_petstore_client_1.NoAuthentication(); - noAuth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); - describe("API Key Authentication", function () { - // TODO: make all params const variables - it("Header API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "header", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("paramName"); - chai_1.expect(ctx.getHeaders()["paramName"]).to.equal("apiKey"); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Query API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com?a=b", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "query", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.contain("paramName=apiKey"); - chai_1.expect(ctx.getHeaders()).to.deep.equal({}); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - it("Cookie API Key", function () { - var ctx = new ts_petstore_client_2.RequestContext("http://google.com", ts_petstore_client_2.HttpMethod.GET); - var auth = new ts_petstore_client_1.APIKeyAuthentication("my_name", "paramName", "cookie", "apiKey"); - auth.applySecurityAuthentication(ctx); - chai_1.expect(ctx.getUrl()).to.equal("http://google.com"); - chai_1.expect(ctx.getHeaders()).to.have.property("Cookie"); - chai_1.expect(ctx.getHeaders()["Cookie"]).to.contain("paramName=apiKey; "); - chai_1.expect(ctx.getBody()).to.equal(""); - }); - }); -}); diff --git a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js b/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js deleted file mode 100644 index bca167ad867..00000000000 --- a/samples/client/petstore/typescript/tests/default/dist/http/isomorphic-fetch.test.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var ts_petstore_client_1 = require("ts-petstore-client"); -var chai_1 = require("chai"); -var FormData = require("form-data"); -var libs = { - "isomorphic-fetch": new ts_petstore_client_1.IsomorphicFetchHttpLibrary() -}; -var _loop_1 = function (libName) { - var lib = libs[libName]; - describe("Isomorphic Fetch", function () { - it("GET-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/get", ts_petstore_client_1.HttpMethod.GET); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("POST-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/post", ts_petstore_client_1.HttpMethod.POST); - requestContext.setHeaderParam("X-Test-Token", "Test-Token"); - requestContext.addCookie("test-cookie", "cookie-value"); - var formData = new FormData(); - formData.append("test", "test2"); - formData.append("testFile", Buffer.from("abc"), "fileName.json"); - requestContext.setBody(formData); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["headers"]).to.exist; - chai_1.expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token"); - chai_1.expect(body["headers"]["Cookie"]).to.equal("test-cookie=cookie-value;"); - chai_1.expect(body["files"]["testFile"]).to.equal("abc"); - chai_1.expect(body["form"]["test"]).to.equal("test2"); - done(); - }).catch(function (e) { - done(e); - }); - }); - it("Cookies-Request", function (done) { - var requestContext = new ts_petstore_client_1.RequestContext("http://httpbin.org/cookies", ts_petstore_client_1.HttpMethod.GET); - requestContext.addCookie("test-cookie", "cookie-value"); - lib.send(requestContext).then(function (resp) { - chai_1.expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200); - var body = JSON.parse(resp.body); - chai_1.expect(body["cookies"]["test-cookie"]).to.equal("cookie-value"); - done(); - }).catch(function (e) { - done(e); - }); - }); - }); -}; -for (var libName in libs) { - _loop_1(libName); -} diff --git a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js index 94eeb6bb207..0a7f6547ffd 100644 --- a/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js +++ b/samples/client/petstore/typescript/tests/default/dist/test/models/ObjectSerializer.test.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var rewire = require("rewire"); var chai_1 = require("chai"); var ts_petstore_client_1 = require("ts-petstore-client"); -var objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js"); +var objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts"); var ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer"); describe("ObjectSerializer", function () { describe("Serialize", function () { diff --git a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts index 914f6fdea28..342ea63b26c 100644 --- a/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts +++ b/samples/client/petstore/typescript/tests/default/test/models/ObjectSerializer.test.ts @@ -3,7 +3,7 @@ import { expect} from "chai"; import {Pet, Category, Tag} from "ts-petstore-client" -const objectSerializerFile = rewire("../../node_modules/ts-petstore-client/dist/models/ObjectSerializer.js") +const objectSerializerFile = rewire(__dirname + "/../../node_modules/ts-petstore-client/models/ObjectSerializer.ts") const ObjectSerializer = objectSerializerFile.__get__("ObjectSerializer")