feat(lib): fn.withArgs

This commit is contained in:
sh0rez 2020-05-13 12:31:07 +02:00
parent 0d8cf83b56
commit 4c6f532e05
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
6 changed files with 199 additions and 127 deletions

48
pkg/render/render_test.go Normal file
View file

@ -0,0 +1,48 @@
package render
import (
"testing"
"github.com/sh0rez/docsonnet/pkg/docsonnet"
"github.com/stretchr/testify/assert"
)
func TestSortFields(t *testing.T) {
api := docsonnet.Fields{
"new": dfn(),
"newNamed": dfn(),
"aaa": dfn(),
"bbb": dobj(),
"ccc": dfn(),
"metadata": dobj(),
}
sorted := []string{
"new",
"newNamed",
"aaa",
"ccc",
"bbb",
"metadata",
}
res := sortFields(api)
assert.Equal(t, sorted, res)
}
func dobj() docsonnet.Field {
return docsonnet.Field{
Object: &docsonnet.Object{},
}
}
func dfn() docsonnet.Field {
return docsonnet.Field{
Function: &docsonnet.Function{},
}
}