Skip to content

Commit

Permalink
Add mock packages for commonjs/esmodule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbarke committed Feb 19, 2019
1 parent 966f5ec commit 3a3beac
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ npm-debug.log
package-lock.json
tmp
.idea
tests/**/*.js
2 changes: 2 additions & 0 deletions tests/integration-latest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"karma-typescript-cssmodules-transform": "latest",
"karma-typescript-es6-transform": "latest",
"karma-typescript-postcss-transform": "latest",
"kt-commonjs-a": "file:src/exports/kt-commonjs-a",
"kt-commonjs-b": "file:src/exports/kt-commonjs-b",
"lodash": "^4.17.4",
"lodash-es": "^4.17.4",
"moment": "^2.17.1",
Expand Down
10 changes: 9 additions & 1 deletion tests/integration-latest/src/exports/commonjs-tester.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import A from "./commonjs-a"
import A2 from "kt-commonjs-a";

describe("CommonJS", () => {

it("should extend class", () => {
it("should extend class B, Typescript", () => {

const a = new A();
expect(A.name).toEqual("A");
expect(a.hello()).toEqual("Hello from A! Hello from B!");
});

it("should extend class B, commonjs", () => {

expect(A2.name).toEqual("A");
expect(new (A2 as any)().hello()).toEqual("Hello from A! Hello from B!");
});
});
30 changes: 30 additions & 0 deletions tests/integration-latest/src/exports/kt-commonjs-a/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
// tslint:disable-next-line:no-var-requires
var B = require("kt-commonjs-b");
var A = /** @class */ (function (_super) {
__extends(A, _super);
function A() {
return _super !== null && _super.apply(this, arguments) || this;
}
A.prototype.hello = function () {
return "Hello from A! " + _super.prototype.hello.call(this);
};
return A;
}(B));
module.exports = A;
10 changes: 10 additions & 0 deletions tests/integration-latest/src/exports/kt-commonjs-a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "kt-commonjs-a",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "MIT",
"private": true
}

9 changes: 9 additions & 0 deletions tests/integration-latest/src/exports/kt-commonjs-b/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var B = /** @class */ (function () {
function B() {
}
B.prototype.hello = function () {
return "Hello from B!";
};
return B;
}());
module.exports = B;
10 changes: 10 additions & 0 deletions tests/integration-latest/src/exports/kt-commonjs-b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "kt-commonjs-b",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "MIT",
"private": true
}

0 comments on commit 3a3beac

Please sign in to comment.