From 56f1ab8a7e066ba7c5c93b6986f0b4b79a476cbb Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Fri, 18 Sep 2020 22:22:46 +0900 Subject: [PATCH] add tests --- lib/cdp/client_private_test.go | 13 ++++++++++++- page_test.go | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/cdp/client_private_test.go b/lib/cdp/client_private_test.go index 43de5ff2..5635deb6 100644 --- a/lib/cdp/client_private_test.go +++ b/lib/cdp/client_private_test.go @@ -72,9 +72,20 @@ func TestCancelOnReq(t *testing.T) { } func TestCancelBeforeSend(t *testing.T) { + cdp := New("") + cdp.ctx = context.Background() ctx, cancel := context.WithCancel(context.Background()) + cancel() + + _, err := cdp.Call(ctx, "", "", nil) + assert.EqualError(t, err, "context canceled") +} + +func TestCancelBeforeCallback(t *testing.T) { cdp := New("") - cdp.ctx = ctx + cdp.ctx = context.Background() + + ctx, cancel := context.WithCancel(context.Background()) go func() { <-cdp.chReq diff --git a/page_test.go b/page_test.go index 205728c8..558bdd84 100644 --- a/page_test.go +++ b/page_test.go @@ -678,10 +678,13 @@ func (s *S) TestFonts() { p.MustPDF("tmp", "fonts.pdf") } -func (s *S) TestPagePDFErr() { +func (s *S) TestPagePDF() { + p := s.page.MustNavigate(srcFile("fixtures/click.html")) + p.MustPDF("") + s.Panics(func() { s.stubErr(1, proto.PagePrintToPDF{}) - s.page.MustPDF() + p.MustPDF() }) }