package testconversions

import "github.com/google/safehtml/testconversions"

Package testconversions provides functions to to create arbitrary values of package safehtml types for use by tests only. Note that the created values may violate type contracts.

These functions are useful when types are constructed in a manner where using the package safehtml API is too inconvenient. Please use the package safehtml API whenever possible; there is value in having tests reflect common usage. Using the package safehtml API also avoids, by design, non-contract complying instances from being created.

Index

Functions

func MakeHTMLForTest

func MakeHTMLForTest(s string) safehtml.HTML

MakeHTMLForTest converts a plain string into a HTML. This function must only be used in tests.

func MakeIdentifierForTest

func MakeIdentifierForTest(s string) safehtml.Identifier

MakeIdentifierForTest converts a plain string into an Identifier. This function must only be used in tests.

func MakeScriptForTest

func MakeScriptForTest(s string) safehtml.Script

MakeScriptForTest converts a plain string into a Script. This function must only be used in tests.

func MakeStyleForTest

func MakeStyleForTest(s string) safehtml.Style

MakeStyleForTest converts a plain string into a Style. This function must only be used in tests.

func MakeStyleSheetForTest

func MakeStyleSheetForTest(s string) safehtml.StyleSheet

MakeStyleSheetForTest converts a plain string into a StyleSheet. This function must only be used in tests.

func MakeTrustedResourceURLForTest

func MakeTrustedResourceURLForTest(s string) safehtml.TrustedResourceURL

MakeTrustedResourceURLForTest converts a plain string into a TrustedResourceURL. This function must only be used in tests.

func MakeURLForTest

func MakeURLForTest(s string) safehtml.URL

MakeURLForTest converts a plain string into a URL. This function must only be used in tests.

Source Files

testconversions.go

Version
v0.1.0 (latest)
Published
Apr 30, 2022
Platform
linux/amd64
Imports
2 packages
Last checked
3 weeks ago

Tools for package owners.