57 lines
1.8 KiB
Swift
57 lines
1.8 KiB
Swift
import Elementary
|
|
import Foundation
|
|
import Testing
|
|
|
|
@testable import WebsiteLibrary
|
|
|
|
@Suite(
|
|
"IndexPage page",
|
|
.tags(.page)
|
|
)
|
|
struct IndexPageTests {
|
|
|
|
// MARK: Functional tests
|
|
|
|
@Test
|
|
func `renders its markup`() {
|
|
let html = IndexPage(
|
|
locale: .init(identifier: "en")
|
|
).render()
|
|
|
|
#expect(html.contains("<!DOCTYPE html>"))
|
|
#expect(html.contains(#"lang="en""#))
|
|
#expect(html.contains("/css/shared.css"))
|
|
#expect(html.contains("/css/index.css"))
|
|
#expect(html.contains("/favicon.ico"))
|
|
#expect(html.contains("/icon.svg"))
|
|
#expect(html.contains("/apple-touch-icon.png"))
|
|
#expect(html.contains("/site.webmanifest"))
|
|
#expect(html.contains(#"media="(prefers-color-scheme: dark)""#))
|
|
#expect(html.contains("Hello world!"))
|
|
#expect(html.contains("/js/shared.js"))
|
|
#expect(html.contains("/js/index.js"))
|
|
}
|
|
|
|
@Test
|
|
func `renders no font preloads until fonts are declared`() {
|
|
// The template ships no fonts, so a preload link here would point at a file the service does not serve.
|
|
#expect(IndexPage.preloadedFonts.isEmpty)
|
|
#expect(!IndexPage(locale: .init(identifier: "en")).render().contains(#"rel="preload""#))
|
|
}
|
|
|
|
@Test
|
|
func `renders versioned asset URLs when given a version`() {
|
|
let html = IndexPage(
|
|
locale: .init(identifier: "en"),
|
|
assetVersion: "0123456789abcdef"
|
|
).render()
|
|
|
|
#expect(html.contains("/css/shared.css?v=0123456789abcdef"))
|
|
#expect(html.contains("/css/index.css?v=0123456789abcdef"))
|
|
#expect(html.contains("/js/shared.js?v=0123456789abcdef"))
|
|
#expect(html.contains("/js/index.js?v=0123456789abcdef"))
|
|
#expect(html.contains("/favicon.ico?v=0123456789abcdef"))
|
|
}
|
|
|
|
}
|