Newer
Older
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
48
49
50
51
52
53
54
55
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2022 xx foundation //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file. //
////////////////////////////////////////////////////////////////////////////////
package wasm
import (
"gitlab.com/elixxir/client/bindings"
"reflect"
"testing"
)
// Tests that the map representing ChannelsManager returned by
// newChannelsManagerJS contains all of the methods on ChannelsManager.
func Test_newChannelsManagerJS(t *testing.T) {
cmType := reflect.TypeOf(&ChannelsManager{})
e2e := newChannelsManagerJS(&bindings.ChannelsManager{})
if len(e2e) != cmType.NumMethod() {
t.Errorf("ChannelsManager JS object does not have all methods."+
"\nexpected: %d\nreceived: %d", cmType.NumMethod(), len(e2e))
}
for i := 0; i < cmType.NumMethod(); i++ {
method := cmType.Method(i)
if _, exists := e2e[method.Name]; !exists {
t.Errorf("Method %s does not exist.", method.Name)
}
}
}
// Tests that ChannelsManager has all the methods that
// [bindings.ChannelsManager] has.
func Test_ChannelsManagerMethods(t *testing.T) {
cmType := reflect.TypeOf(&ChannelsManager{})
binCmType := reflect.TypeOf(&bindings.ChannelsManager{})
if binCmType.NumMethod() != cmType.NumMethod() {
t.Errorf("WASM ChannelsManager object does not have all methods from "+
"bindings.\nexpected: %d\nreceived: %d",
binCmType.NumMethod(), cmType.NumMethod())
}
for i := 0; i < binCmType.NumMethod(); i++ {
method := binCmType.Method(i)
if _, exists := cmType.MethodByName(method.Name); !exists {
t.Errorf("Method %s does not exist.", method.Name)
}
}
}