github.com/fighterlyt/hugo@v0.47.1/hugolib/embedded_templates_test.go (about) 1 // Copyright 2018 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 hugolib 15 16 import ( 17 "testing" 18 19 "github.com/stretchr/testify/require" 20 ) 21 22 // Just some simple test of the embedded templates to avoid 23 // https://github.com/gohugoio/hugo/issues/4757 and similar. 24 func TestEmbeddedTemplates(t *testing.T) { 25 t.Parallel() 26 27 assert := require.New(t) 28 assert.True(true) 29 30 home := []string{"index.html", ` 31 GA: 32 {{ template "_internal/google_analytics.html" . }} 33 34 GA async: 35 36 {{ template "_internal/google_analytics_async.html" . }} 37 38 Disqus: 39 40 {{ template "_internal/disqus.html" . }} 41 42 `} 43 44 b := newTestSitesBuilder(t) 45 b.WithSimpleConfigFile().WithTemplatesAdded(home...) 46 47 b.Build(BuildCfg{}) 48 49 // Gheck GA regular and async 50 b.AssertFileContent("public/index.html", 51 "'anonymizeIp', true", 52 "'script','https://www.google-analytics.com/analytics.js','ga');\n\tga('create', 'ga_id', 'auto')", 53 "<script async src='https://www.google-analytics.com/analytics.js'>") 54 55 // Disqus 56 b.AssertFileContent("public/index.html", "\"disqus_shortname\" + '.disqus.com/embed.js';") 57 }