File tree Expand file tree Collapse file tree 4 files changed +150
-0
lines changed
packages/compiler/test/tsx-sourcemaps Expand file tree Collapse file tree 4 files changed +150
-0
lines changed Original file line number Diff line number Diff line change 1+ import { test } from 'uvu' ;
2+ import * as assert from 'uvu/assert' ;
3+ import { testSourcemap } from '../utils' ;
4+
5+ test ( 'script is:inline' , async ( ) => {
6+ const input = `---
7+ /** @deprecated */
8+ const deprecated = "Astro"
9+ deprecated;
10+ const hello = "Astro"
11+ ---
12+ ` ;
13+ const output = await testSourcemap ( input , `deprecated;` ) ;
14+
15+ assert . equal ( output , {
16+ line : 4 ,
17+ column : 1 ,
18+ source : 'index.astro' ,
19+ name : null ,
20+ } ) ;
21+ } ) ;
22+
23+ test . run ( ) ;
Original file line number Diff line number Diff line change 1+ import { test } from 'uvu' ;
2+ import * as assert from 'uvu/assert' ;
3+ import { testSourcemap } from '../utils' ;
4+
5+ test ( 'svelte error' , async ( ) => {
6+ const input = `---
7+ import SvelteOptionalProps from "./SvelteOptionalProps.svelte"
8+ ---
9+
10+ <SvelteOptionalProps></SvelteOptionalProps>` ;
11+ const output = await testSourcemap ( input , '<SvelteOptionalProps>' ) ;
12+
13+ assert . equal ( output , {
14+ line : 5 ,
15+ column : 1 ,
16+ source : 'index.astro' ,
17+ name : null ,
18+ } ) ;
19+ } ) ;
20+
21+ test ( 'vue error' , async ( ) => {
22+ const input = `---
23+ import SvelteError from "./SvelteError.svelte"
24+ import VueError from "./VueError.vue"
25+ ---
26+
27+ <SvelteError></SvelteError>
28+ <VueError></VueError>` ;
29+ const svelte = await testSourcemap ( input , '<SvelteError>' ) ;
30+
31+ assert . equal ( svelte , {
32+ line : 6 ,
33+ column : 1 ,
34+ source : 'index.astro' ,
35+ name : null ,
36+ } ) ;
37+
38+ const vue = await testSourcemap ( input , '<VueError>' ) ;
39+
40+ assert . equal ( vue , {
41+ line : 7 ,
42+ column : 1 ,
43+ source : 'index.astro' ,
44+ name : null ,
45+ } ) ;
46+ } ) ;
47+
48+ test . run ( ) ;
Original file line number Diff line number Diff line change 1+ import { test } from 'uvu' ;
2+ import * as assert from 'uvu/assert' ;
3+ import { testSourcemap } from '../utils' ;
4+
5+ const fixture = `---
6+ const MyVariable = "Astro"
7+
8+ /** Documentation */
9+ const MyDocumentedVariable = "Astro"
10+
11+ /** @author Astro */
12+ const MyJSDocVariable = "Astro"
13+ ---
14+ ` ;
15+
16+ test ( 'hover I' , async ( ) => {
17+ const input = fixture ;
18+ const output = await testSourcemap ( input , 'MyVariable' ) ;
19+
20+ assert . equal ( output , {
21+ line : 2 ,
22+ column : 11 ,
23+ source : 'index.astro' ,
24+ name : null ,
25+ } ) ;
26+ } ) ;
27+
28+ test ( 'hover II' , async ( ) => {
29+ const input = fixture ;
30+ const output = await testSourcemap ( input , 'MyDocumentedVariable' ) ;
31+
32+ assert . equal ( output , {
33+ line : 5 ,
34+ column : 11 ,
35+ source : 'index.astro' ,
36+ name : null ,
37+ } ) ;
38+ } ) ;
39+
40+ test ( 'hover III' , async ( ) => {
41+ const input = fixture ;
42+ const output = await testSourcemap ( input , 'MyJSDocVariable' ) ;
43+
44+ assert . equal ( output , {
45+ line : 8 ,
46+ column : 11 ,
47+ source : 'index.astro' ,
48+ name : null ,
49+ } ) ;
50+ } ) ;
51+
52+ test . run ( ) ;
Original file line number Diff line number Diff line change 1+ import { test } from 'uvu' ;
2+ import * as assert from 'uvu/assert' ;
3+ import { testSourcemap } from '../utils' ;
4+
5+ test ( 'script is:inline' , async ( ) => {
6+ const input = `---
7+ // valid
8+ import { foo } from './script.js';
9+ import ComponentAstro from './astro.astro';
10+ import ComponentSvelte from './svelte.svelte';
11+ import ComponentVue from './vue.vue';
12+ // invalid
13+ import { baz } from './script';
14+ foo;baz;ComponentAstro;ComponentSvelte;ComponentVue;
15+ ---
16+ ` ;
17+ const output = await testSourcemap ( input , `'./script'` ) ;
18+
19+ assert . equal ( output , {
20+ line : 8 ,
21+ column : 23 ,
22+ source : 'index.astro' ,
23+ name : null ,
24+ } ) ;
25+ } ) ;
26+
27+ test . run ( ) ;
You can’t perform that action at this time.
0 commit comments