github.com/linchen2chris/hugo@v0.0.0-20230307053224-cec209389705/resources/postpub/fields_test.go (about)

     1  // Copyright 2020 The Hugo Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package postpub
    15  
    16  import (
    17  	"testing"
    18  
    19  	qt "github.com/frankban/quicktest"
    20  
    21  	"github.com/gohugoio/hugo/media"
    22  )
    23  
    24  func TestCreatePlaceholders(t *testing.T) {
    25  	c := qt.New(t)
    26  
    27  	m := structToMap(media.CSSType)
    28  
    29  	insertFieldPlaceholders("foo", m, func(s string) string {
    30  		return "pre_" + s + "_post"
    31  	})
    32  
    33  	c.Assert(m, qt.DeepEquals, map[string]any{
    34  		"IsZero":      "pre_foo.IsZero_post",
    35  		"MarshalJSON": "pre_foo.MarshalJSON_post",
    36  		"Suffixes":    "pre_foo.Suffixes_post",
    37  		"Delimiter":   "pre_foo.Delimiter_post",
    38  		"FirstSuffix": "pre_foo.FirstSuffix_post",
    39  		"IsText":      "pre_foo.IsText_post",
    40  		"String":      "pre_foo.String_post",
    41  		"Type":        "pre_foo.Type_post",
    42  		"MainType":    "pre_foo.MainType_post",
    43  		"SubType":     "pre_foo.SubType_post",
    44  	})
    45  }