mirror of
https://github.com/swc-project/swc.git
synced 2025-01-02 02:26:09 +03:00
0aafa75fef
**Description:** This implements something similar to `__snapshots__` of `jest`. Instead of storing the expected result as a string literal, we now store it in `$crate/tests/__swc_snapshots__/$path_to_test__$test_name.js`. **Related issue:** - Closes #4509
56 lines
1.1 KiB
Rust
56 lines
1.1 KiB
Rust
use swc_common::chain;
|
|
use swc_ecma_parser::{EsConfig, Syntax};
|
|
use swc_ecma_transforms_compat::es2020::export_namespace_from;
|
|
use swc_ecma_transforms_proposal::export_default_from;
|
|
use swc_ecma_transforms_testing::test;
|
|
use swc_ecma_visit::Fold;
|
|
|
|
fn syntax_default() -> Syntax {
|
|
Syntax::Es(EsConfig {
|
|
export_default_from: true,
|
|
..Default::default()
|
|
})
|
|
}
|
|
fn syntax_namespace() -> Syntax {
|
|
Syntax::Es(Default::default())
|
|
}
|
|
|
|
fn tr() -> impl Fold {
|
|
chain!(export_default_from(), export_namespace_from())
|
|
}
|
|
|
|
test!(
|
|
syntax_default(),
|
|
|_| tr(),
|
|
default_es6,
|
|
r#"export foo from "bar";"#
|
|
);
|
|
|
|
test!(
|
|
syntax_default(),
|
|
|_| tr(),
|
|
default_compounded_es6,
|
|
r#"export v, { x, y as w } from "mod";"#
|
|
);
|
|
|
|
test!(
|
|
syntax_default(),
|
|
|_| tr(),
|
|
namespace_compound_es6,
|
|
r"export * as foo, { bar } from 'bar';"
|
|
);
|
|
|
|
test!(
|
|
syntax_namespace(),
|
|
|_| tr(),
|
|
namespace_default,
|
|
"export * as default from 'foo';"
|
|
);
|
|
|
|
test!(
|
|
syntax_namespace(),
|
|
|_| tr(),
|
|
namespace_es6,
|
|
"export * as foo from 'bar';"
|
|
);
|