File size: 1,259 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
package bridge

import (
	"context"
	"strings"
	"testing"

	"github.com/pinchtab/pinchtab/internal/config"
)

func TestDisableAnimationsCSS(t *testing.T) {
	if !strings.Contains(DisableAnimationsCSS, "animation: none !important") {
		t.Error("CSS missing animation: none")
	}
	if !strings.Contains(DisableAnimationsCSS, "transition: none !important") {
		t.Error("CSS missing transition: none")
	}
	if !strings.Contains(DisableAnimationsCSS, "scroll-behavior: auto !important") {
		t.Error("CSS missing scroll-behavior: auto")
	}
}

func TestInjectNoAnimations(t *testing.T) {
	cfg := &config.RuntimeConfig{NoAnimations: true}
	b := &Bridge{Config: cfg}
	if b.Config.NoAnimations != true {
		t.Error("Expected NoAnimations to be true")
	}
}

func TestDisableAnimationsOnceReturnsErrorWhenContextCanceled(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	cancel()

	if err := DisableAnimationsOnce(ctx); err == nil {
		t.Fatal("expected error for canceled context")
	}
}

func TestInjectNoAnimationsReturnsErrorWhenContextCanceled(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())
	cancel()

	b := &Bridge{}
	if err := b.InjectNoAnimations(ctx); err == nil {
		t.Fatal("expected error for canceled context")
	}
}