-
Notifications
You must be signed in to change notification settings - Fork 81
/
property_config_test.go
46 lines (44 loc) · 982 Bytes
/
property_config_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
46
package notionapi
import (
"encoding/json"
"reflect"
"testing"
)
func TestNumberPropertyConfig_MarshalJSON(t *testing.T) {
type fields struct {
Type PropertyConfigType
Format FormatType
}
tests := []struct {
name string
fields fields
want []byte
wantErr bool
}{
{
name: "returns correct json",
fields: fields{
Type: PropertyConfigTypeNumber,
Format: FormatDollar,
},
want: []byte(`{"type":"number","number":{"format":"dollar"}}`),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := NumberPropertyConfig{
Type: tt.fields.Type,
Number: NumberFormat{Format: tt.fields.Format},
}
got, err := json.Marshal(p)
if (err != nil) != tt.wantErr {
t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("MarshalJSON() got = %v, want %v", string(got), string(tt.want))
}
})
}
}