vhs/screenshot_test.go
Elías Martínez eeb6058538
Feat/screenshot (#311)
* add screenshot command

* apply gif style to screenshot

* feat: add screenshot command

* fix: remove unused func and fix lint errors

* refactor: remove unused field

* chore: delete mask and bar files on vhs.CleanUp

* refactor: remove wrong commited files
2023-08-23 15:04:21 -04: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)
}
})
}