-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypescript_test.go
More file actions
47 lines (42 loc) · 1013 Bytes
/
Copy pathtypescript_test.go
File metadata and controls
47 lines (42 loc) · 1013 Bytes
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
46
47
package main
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestTypeScript(t *testing.T) {
cases := []struct {
input string
hasComment bool
output string
typeName string
}{
{
input: "input_comment.go",
hasComment: true,
output: "input_comment.ts",
typeName: "Owner",
},
{
input: "input_nocomment.go",
hasComment: false,
output: "input_nocomment.ts",
typeName: "Gender",
},
}
dir, err := os.Getwd()
require.NoError(t, err)
for _, testcase := range cases {
var g Generator
fullPath := filepath.Join(dir, "tsdata", testcase.input)
g.parsePackage([]string{fullPath})
g.generate(testcase.typeName, true, true, "noop", "", testcase.hasComment, "")
output := filepath.Join(dir, "tsdata", testcase.output)
expected, err := ioutil.ReadFile(output)
require.NoError(t, err)
assert.Equal(t, string(expected), g.tsBuf.String())
}
}