-
Notifications
You must be signed in to change notification settings - Fork 2
/
goja_exception_test.go
45 lines (42 loc) · 1.3 KB
/
goja_exception_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gojsx
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestEx(t *testing.T) {
cases := []struct {
In string
Out string
}{
{
In: `GoError: Invalid module: 'test/App2'
at github.com/zbysir/gojsx/internal/pkg/goja_nodejs/require.(*RequireModule).require-fm (native)
at test/Index.jsx:1:16(55)
at github.com/zbysir/gojsx/internal/pkg/goja_nodejs/require.(*RequireModule).require-fm (native)
at root.js:1:1(1)`,
Out: `GoError: Invalid module: 'test/App2'
at test/Index.jsx:1:16
at root.js:1:1`,
},
{
In: `ReferenceError: i is not defined
at Index (test/Index.jsx:14:23(64))
at root.js:1:32(5)`,
Out: `ReferenceError: i is not defined
at Index (test/Index.jsx:14:23)
at root.js:1:32`,
},
{
In: `GoError: load file (test/Index.jsx) error :test/Index.jsx: (4:24)
export default function 1 Index(props) {
^ Expected "(" but found "1"
at github.com/zbysir/gojsx/internal/pkg/goja_nodejs/require.(*RequireModule).require-fm (native)`,
Out: `GoError: load file (test/Index.jsx) error :test/Index.jsx: (4:24)
export default function 1 Index(props) {
^ Expected "(" but found "1"`,
},
}
for _, c := range cases {
assert.Equal(t, c.Out, parseException(c.In).Error())
}
}