Skip to content

Commit

Permalink
test(e2e): fix swc decorators case (#5355)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Feb 1, 2024
1 parent 38460e0 commit 43a6cee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
11 changes: 3 additions & 8 deletions tests/integration/swc/fixtures/decorator/new/modern.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
import { swcPlugin } from '@modern-js/plugin-swc';

export default defineConfig({
tools: {
swc: {
jsc: {
transform: {
/** use new decorator */
legacyDecorator: false,
},
},
source: {
decorators: {
version: '2022-03',
},
},
output: {
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/swc/fixtures/decorator/new/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
function newDecorator() {
function newDecorator(value) {
console.log('foo decorator');
return value;
}

class Foo {
@newDecorator()
@newDecorator
foo() {
console.log('foo');
}
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/swc/tests/decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fixtures = path.resolve(__dirname, '../fixtures');

const getJsFiles = (appDir: string) =>
readdirSync(path.resolve(appDir, 'dist/static/js'))
.filter(filepath => /\.js$/.test(filepath))
.filter(filepath => /\.js.map$/.test(filepath))
.map(filePath =>
readFileSync(path.join(appDir, 'dist/static/js', filePath)),
);
Expand All @@ -19,7 +19,9 @@ describe('swc use new decorator', () => {

const jsFiles = getJsFiles(appDir);
expect(
jsFiles.some(item => item.includes('@swc/helpers/esm/_decorate.js')),
jsFiles.some(item =>
item.includes('@swc/helpers/esm/_apply_decs_2203_r.js'),
),
).toBeTruthy();
});

Expand Down

0 comments on commit 43a6cee

Please sign in to comment.