shithub: mycel

Download patch

ref: 72923e901d8543b2f1b753ef9d1b3433dd6eaf60
parent: be625b0f144f89179e63d680ef2cc59c6fb974d8
author: Philip Silva <philip.silva@protonmail.com>
date: Fri Jul 15 06:30:20 EDT 2022

fix all tests

--- a/browser/experimental_test.go
+++ b/browser/experimental_test.go
@@ -1,21 +1,47 @@
 package browser
 
 import (
+	"context"
+	"fmt"
+	"github.com/psilva261/opossum"
 	"github.com/psilva261/opossum/browser/fs"
+	"github.com/psilva261/opossum/logger"
 	"github.com/psilva261/opossum/js"
 	"github.com/psilva261/opossum/nodes"
 	"github.com/psilva261/opossum/style"
 	"golang.org/x/net/html"
 	"io/ioutil"
+	"net/url"
 	"strings"
 	"testing"
 )
 
 func init() {
+	log.Debug = true
+	js.SetFetcher(&TestFetcher{})
 	style.Init(nil)
 	go fs.Srv9p()
 }
 
+type TestFetcher struct {}
+
+func (tf *TestFetcher) Ctx() context.Context {
+	return context.Background()
+}
+
+func (tf *TestFetcher) Origin() (u *url.URL) {
+	u, _ = url.Parse("https://example.com")
+	return
+}
+
+func (tf *TestFetcher) LinkedUrl(string) (*url.URL, error) {
+	return nil, fmt.Errorf("not implemented")
+}
+
+func (tf *TestFetcher) Get(*url.URL) ([]byte, opossum.ContentType, error) {
+	return nil, opossum.ContentType{}, fmt.Errorf("not implemented")
+}
+
 func TestProcessJS2SkipFailure(t *testing.T) {
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
@@ -52,7 +78,7 @@
 		t.Errorf(err.Error())
 	}
 	t.Logf("h = %+v", h)
-	if !strings.Contains(h, `<body style="display: none;">`) {
+	if !strings.Contains(h, `<body style="display: none; ">`) {
 		t.Fail()
 	}
 	js.Stop()