Skip to content

Commit

Permalink
fix: decorator test case
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Feb 18, 2024
1 parent 6e50788 commit 9dcef8c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 98 deletions.
35 changes: 0 additions & 35 deletions tests/e2e/builder/cases/decorator/latest/index.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions tests/e2e/builder/cases/decorator/latest/src/index.js

This file was deleted.

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
4 changes: 2 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,9 @@
function newDecorator() {
function newDecorator(value) {
console.log('foo decorator');
}

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 9dcef8c

Please sign in to comment.