Skip to content

Commit f5fb111

Browse files
author
Rob Figueiredo
committed
promise_test: add case for incorrect number of callbacks
1 parent ca47876 commit f5fb111

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

promise_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,24 @@ func TestPromiseRejected(t *testing.T) {
104104
t.Fatalf("expected call to onRejected, got none")
105105
}
106106
}
107+
108+
func TestPromiseThenPanic(t *testing.T) {
109+
t.Parallel()
110+
111+
iso, _ := v8go.NewIsolate()
112+
ctx, _ := v8go.NewContext(iso)
113+
res, _ := v8go.NewPromiseResolver(ctx)
114+
prom := res.GetPromise()
115+
116+
t.Run("no callbacks", func(t *testing.T) {
117+
defer func() { recover() }()
118+
prom.Then()
119+
t.Errorf("expected a panic")
120+
})
121+
t.Run("3 callbacks", func(t *testing.T) {
122+
defer func() { recover() }()
123+
fn := func(_ *v8go.FunctionCallbackInfo) *v8go.Value { return nil }
124+
prom.Then(fn, fn, fn)
125+
t.Errorf("expected a panic")
126+
})
127+
}

0 commit comments

Comments
 (0)