-
Notifications
You must be signed in to change notification settings - Fork 260
/
screenshot_test.go
48 lines (37 loc) · 1.06 KB
/
screenshot_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)
}
})
}