Skip to content

Commit 81227a4

Browse files
committed
options test
1 parent 49263f7 commit 81227a4

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package component
2+
3+
import (
4+
"github.com/stretchr/testify/assert"
5+
"testing"
6+
)
7+
8+
func TestOptions(t *testing.T) {
9+
tests := []struct {
10+
name string
11+
opts []GetSetVariableOption
12+
expected componentVariableOptions
13+
}{
14+
{
15+
name: "default options",
16+
expected: componentVariableOptions{
17+
attributeType: "",
18+
},
19+
opts: []GetSetVariableOption{},
20+
},
21+
{
22+
name: "with attribute type",
23+
expected: componentVariableOptions{
24+
attributeType: "abc",
25+
},
26+
opts: []GetSetVariableOption{
27+
WithAttributeType("abc"),
28+
},
29+
},
30+
}
31+
32+
for _, tt := range tests {
33+
t.Run(tt.name, func(t *testing.T) {
34+
opts := componentVariableOptions{}
35+
for _, opt := range tt.opts {
36+
opt(&opts)
37+
}
38+
39+
assert.Equal(t, tt.expected, opts)
40+
})
41+
}
42+
}

0 commit comments

Comments
 (0)