mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
resources/images: Add some golden tests for images.Text
This commit is contained in:
@@ -118,6 +118,55 @@ Home.
|
|||||||
{{ template "filters" (dict "name" "unsharpmask.jpg" "img" $sunset "filters" (images.UnsharpMask 10 0.4 0.03)) }}
|
{{ template "filters" (dict "name" "unsharpmask.jpg" "img" $sunset "filters" (images.UnsharpMask 10 0.4 0.03)) }}
|
||||||
|
|
||||||
|
|
||||||
|
{{ define "filters"}}
|
||||||
|
{{ if lt (len (path.Ext .name)) 4 }}
|
||||||
|
{{ errorf "No extension in %q" .name }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $img := .img.Filter .filters }}
|
||||||
|
{{ $name := printf "images/%s" .name }}
|
||||||
|
{{ with $img | resources.Copy $name }}
|
||||||
|
{{ .Publish }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
`
|
||||||
|
|
||||||
|
runGolden(t, name, files)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGoldenFiltersText(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if skipGolden {
|
||||||
|
t.Skip("Skip golden test on this architecture")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will be used to generate golden files.
|
||||||
|
name := "filters_text"
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- assets/sunset.jpg --
|
||||||
|
sourcefilename: ../testdata/sunset.jpg
|
||||||
|
|
||||||
|
-- layouts/index.html --
|
||||||
|
Home.
|
||||||
|
{{ $sunset := resources.Get "sunset.jpg" }}
|
||||||
|
{{ $textOpts := dict
|
||||||
|
"color" "#fbfaf5"
|
||||||
|
"linespacing" 8
|
||||||
|
"size" 28
|
||||||
|
"x" (div $sunset.Width 2 | int)
|
||||||
|
"alignx" "center"
|
||||||
|
"y" 190
|
||||||
|
}}
|
||||||
|
|
||||||
|
{{ $text := "Pariatur deserunt sunt nisi sunt tempor quis eu. Sint et nulla enim officia sunt cupidatat. Eu amet ipsum qui velit cillum cillum ad Lorem in non ad aute." }}
|
||||||
|
{{ template "filters" (dict "name" "text_alignx-center.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }}
|
||||||
|
{{ $textOpts = (dict "alignx" "right") | merge $textOpts }}
|
||||||
|
{{ template "filters" (dict "name" "text_alignx-right.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }}
|
||||||
|
{{ $textOpts = (dict "alignx" "left") | merge $textOpts }}
|
||||||
|
{{ template "filters" (dict "name" "text_alignx-left.jpg" "img" $sunset "filters" (images.Text $text $textOpts )) }}
|
||||||
|
|
||||||
{{ define "filters"}}
|
{{ define "filters"}}
|
||||||
{{ if lt (len (path.Ext .name)) 4 }}
|
{{ if lt (len (path.Ext .name)) 4 }}
|
||||||
{{ errorf "No extension in %q" .name }}
|
{{ errorf "No extension in %q" .name }}
|
||||||
|
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-center.jpg
vendored
Normal file
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-center.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-left.jpg
vendored
Normal file
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-left.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-right.jpg
vendored
Normal file
BIN
resources/images/testdata/images_golden/filters_text/text_alignx-right.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
Reference in New Issue
Block a user