Skip to content

Commit

Permalink
fix: should transform jsx to js (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Apr 1, 2018
1 parent eedc2a0 commit 9d7fdac
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/assets_context.js
Expand Up @@ -62,7 +62,7 @@ class Assets {
}

setEntry(entry) {
this.entry = entry;
this.entry = entry.replace(/\.jsx?$/, '.js');
this.entryCss = entry.replace(/\.jsx?$/, '.css');
}

Expand Down
8 changes: 8 additions & 0 deletions test/assets.test.js
Expand Up @@ -34,6 +34,14 @@ describe('test/assets.test.js', () => {
.expect(/<script>window.__webpack_public_path__ = '\/';<\/script>/)
.expect(200);
});

it('should GET jsx', () => {
return app.httpRequest()
.get('/account')
.expect(/<link rel="stylesheet" href="http:\/\/127.0.0.1:8000\/account.css"><\/link>/)
.expect(/<script src="http:\/\/127.0.0.1:8000\/account.js"><\/script>/)
.expect(200);
});
});

describe('production', () => {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/apps/assets/app/controller/home.js
Expand Up @@ -9,6 +9,10 @@ class HomeController extends Controller {
});
}

async account() {
await this.ctx.render('account.jsx');
}

async renderString() {
await this.ctx.renderString('', {}, {
viewEngine: 'assets',
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/apps/assets/app/router.js
Expand Up @@ -4,5 +4,6 @@ module.exports = app => {
const { router, controller } = app;

router.get('/', controller.home.index);
router.get('/account', controller.home.account);
router.get('/renderString', controller.home.renderString);
};
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/apps/assets/config/config.default.js
Expand Up @@ -6,6 +6,7 @@ exports.keys = '123456';
exports.view = {
mapping: {
'.js': 'assets',
'.jsx': 'assets',
},
};
exports.assets = {
Expand Down

0 comments on commit 9d7fdac

Please sign in to comment.