From a76262652b227c95ce140f3698c46f59b79354ac Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Thu, 10 Dec 2020 13:00:23 +0100 Subject: Move elements and attributes into html package (#52) This makes it easier to use dot-imports. Also updated the readme and examples with new usage, and move the `Classes` helper into the `components` package.--- el/elements_test.go | 82 ----------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 el/elements_test.go (limited to 'el/elements_test.go') diff --git a/el/elements_test.go b/el/elements_test.go deleted file mode 100644 index adce6df..0000000 --- a/el/elements_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package el_test - -import ( - "errors" - "testing" - - g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" - "github.com/maragudk/gomponents/el" -) - -type erroringWriter struct{} - -func (w *erroringWriter) Write(p []byte) (n int, err error) { - return 0, errors.New("don't want to write") -} - -func TestDocument(t *testing.T) { - t.Run("returns doctype and children", func(t *testing.T) { - assert.Equal(t, ``, el.Document(g.El("html"))) - }) - - t.Run("errors on write error in Render", func(t *testing.T) { - err := el.Document(g.El("html")).Render(&erroringWriter{}) - assert.Error(t, err) - }) -} - -func TestForm(t *testing.T) { - t.Run("returns a form element with action and method attributes", func(t *testing.T) { - assert.Equal(t, `
`, el.Form("/", "post")) - }) -} - -func TestInput(t *testing.T) { - t.Run("returns an input element with attributes type and name", func(t *testing.T) { - assert.Equal(t, ``, el.Input("text", "hat")) - }) -} - -func TestLabel(t *testing.T) { - t.Run("returns a label element with attribute for", func(t *testing.T) { - assert.Equal(t, ``, el.Label("hat", g.Text("Hat"))) - }) -} - -func TestOption(t *testing.T) { - t.Run("returns an option element with attribute label and content", func(t *testing.T) { - assert.Equal(t, ``, el.Option("Hat", "hat")) - }) -} - -func TestProgress(t *testing.T) { - t.Run("returns a progress element with attributes value and max", func(t *testing.T) { - assert.Equal(t, ``, el.Progress(5.5, 10)) - }) -} - -func TestSelect(t *testing.T) { - t.Run("returns a select element with attribute name", func(t *testing.T) { - assert.Equal(t, ``, - el.Select("hat", el.Option("Partyhat", "partyhat"))) - }) -} - -func TestTextarea(t *testing.T) { - t.Run("returns a textarea element with attribute name", func(t *testing.T) { - assert.Equal(t, ``, el.Textarea("hat")) - }) -} - -func TestA(t *testing.T) { - t.Run("returns an a element with a href attribute", func(t *testing.T) { - assert.Equal(t, `hat`, el.A("#", g.Text("hat"))) - }) -} - -func TestImg(t *testing.T) { - t.Run("returns an img element with href and alt attributes", func(t *testing.T) { - assert.Equal(t, `hat`, el.Img("hat.png", "hat", g.Attr("id", "image"))) - }) -} -- cgit 1.4.1