You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package svg
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestNormalize(t *testing.T) {
  9. res := Normalize([]byte("foo"), 1)
  10. assert.Equal(t, "foo", string(res))
  11. res = Normalize([]byte(`<?xml version="1.0"?>
  12. <!--
  13. comment
  14. -->
  15. <svg xmlns = "...">content</svg>`), 1)
  16. assert.Equal(t, `<svg width="1" height="1" class="svg">content</svg>`, string(res))
  17. res = Normalize([]byte(`<svg
  18. width="100"
  19. class="svg-icon"
  20. >content</svg>`), 16)
  21. assert.Equal(t, `<svg class="svg-icon" width="16" height="16">content</svg>`, string(res))
  22. }