github.com/neohugo/neohugo@v0.123.8/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  	"github.com/neohugo/neohugo/media"
    21  )
    22  
    23  func TestCreatePlaceholders(t *testing.T) {
    24  	c := qt.New(t)
    25  
    26  	m := structToMap(media.Builtin.CSSType)
    27  
    28  	insertFieldPlaceholders("foo", m, func(s string) string {
    29  		return "pre_" + s + "_post"
    30  	})
    31  
    32  	c.Assert(m, qt.DeepEquals, map[string]any{
    33  		"IsZero":      "pre_foo.IsZero_post",
    34  		"MarshalJSON": "pre_foo.MarshalJSON_post",
    35  		"Suffixes":    "pre_foo.Suffixes_post",
    36  		"SuffixesCSV": "pre_foo.SuffixesCSV_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  }