Skip to content

Commit

Permalink
🐣 adds support for .tsx
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
sverweij committed Sep 27, 2017
1 parent 4c0a11e commit 436ed22
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/extract/transpile/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const supportedTranspilers = require("../../../package.json").supportedTranspile
const extension2wrapper = {
".js" : javaScriptWrap,
".ts" : typeScriptWrap,
".tsx" : typeScriptWrap,
".d.ts" : typeScriptWrap,
".ls" : liveScriptWrap,
".coffee" : coffeeWrap,
Expand Down
2 changes: 1 addition & 1 deletion test/extract/transpile/meta.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("transpiler meta", () => {
it("tells which extensions can be scanned", () => {
expect(
meta.scannableExtensions
).to.deep.equal([".js", ".ts", ".d.ts", ".coffee", ".litcoffee", ".coffee.md"]);
).to.deep.equal([".js", ".ts", ".tsx", ".d.ts", ".coffee", ".litcoffee", ".coffee.md"]);
});

it("returns the 'js' wrapper for unknown extensions", () => {
Expand Down
56 changes: 56 additions & 0 deletions test/main/fixtures/tsx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"dependencies": [
{
"source": "test/main/fixtures/tsx/index.ts",
"dependencies": [
{
"resolved": "test/main/fixtures/tsx/sub/render.tsx",
"coreModule": false,
"followable": true,
"couldNotResolve": false,
"dependencyTypes": [
"local"
],
"module": "./sub/render",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "test/main/fixtures/tsx/sub/render.tsx",
"dependencies": [
{
"resolved": "react-dom",
"coreModule": false,
"followable": false,
"couldNotResolve": true,
"dependencyTypes": [
"unknown"
],
"module": "react-dom",
"moduleSystem": "es6",
"valid": true
}
]
},
{
"source": "react-dom",
"followable": false,
"coreModule": false,
"couldNotResolve": true,
"dependencyTypes": [
"unknown"
],
"dependencies": []
}
],
"summary": {
"violations": [],
"error": 0,
"warn": 0,
"info": 0,
"totalCruised": 3,
"optionsUsed": {}
}
}
5 changes: 5 additions & 0 deletions test/main/fixtures/tsx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {render as appRender} from './sub/render';

console.log(
appRender()
);
10 changes: 10 additions & 0 deletions test/main/fixtures/tsx/sub/render.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as ReactDOM from 'react-dom';

export async function render(container: Element | null) {
ReactDOM.render(
<Provider store={store}>
<Index />
</Provider>,
container,
);
};
17 changes: 12 additions & 5 deletions test/main/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use strict";
const chai = require('chai');
const expect = chai.expect;
const main = require("../../src/main");
const tsFixture = require('./fixtures/ts.json');
const depSchema = require('../../src/extract/jsonschema.json');
const chai = require('chai');
const expect = chai.expect;
const main = require("../../src/main");
const tsFixture = require('./fixtures/ts.json');
const tsxFixture = require('./fixtures/tsx.json');
const depSchema = require('../../src/extract/jsonschema.json');

chai.use(require('chai-json-schema'));

Expand All @@ -14,4 +15,10 @@ describe("main", () => {
expect(lResult).to.deep.equal(tsFixture);
expect(lResult).to.be.jsonSchema(depSchema);
});
it("Also processes tsx correctly", () => {
const lResult = main.cruise(["test/main/fixtures/tsx"]);

expect(lResult).to.deep.equal(tsxFixture);
expect(lResult).to.be.jsonSchema(depSchema);
});
});

0 comments on commit 436ed22

Please sign in to comment.