code.gitea.io/gitea@v1.22.3/modules/svg/processor_test.go (about)

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