Files
wehub-resource-sync 95f0813436
build / build (push) Failing after 0s
nightly / nightly (push) Failing after 0s
build / snapshot (push) Failing after 0s
lint / lint (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 13:02:37 +08:00

49 lines
1.1 KiB
Go

package main
import "testing"
func TestScreenshot(t *testing.T) {
t.Run("makeScreenshot should add screenshot to map and disable capture", func(t *testing.T) {
path := "sample.png"
targetFrame := 60
opts := ScreenshotOptions{
nextScreenshotPath: path,
frameCapture: true,
screenshots: make(map[string]int),
}
opts.makeScreenshot(targetFrame)
frame, ok := opts.screenshots[path]
if !ok {
t.Errorf("Unable to create screenshot: %s", path)
}
if frame != targetFrame {
t.Errorf("Unable to create screenshot: %s", path)
}
if opts.frameCapture {
t.Error("frameCapture should be false after invoking makeScreenshot")
}
})
t.Run("enableFrameCapture", func(t *testing.T) {
path := "sample.png"
opts := ScreenshotOptions{
frameCapture: false,
}
opts.enableFrameCapture(path)
if !opts.frameCapture {
t.Error("frameCapture should be true after invoking enableFrameCapture")
}
if opts.nextScreenshotPath != path {
t.Errorf("nextScreenshotPath: %s, expected: %s", opts.nextScreenshotPath, path)
}
})
}