-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascripts_header_test.go
More file actions
48 lines (38 loc) · 1.08 KB
/
javascripts_header_test.go
File metadata and controls
48 lines (38 loc) · 1.08 KB
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 client
import (
"os/exec"
"testing"
)
// TestStoreRoundtrip ensures the mode is saved to and loaded from the Store
func TestStoreRoundtrip(t *testing.T) {
if _, err := exec.LookPath("tinygo"); err != nil {
t.Skip("tinygo not found in PATH")
}
store := &testDatabase{data: make(map[string]string)}
config := &Config{
Database: store,
}
New(config)
// Test all three supported shortcuts: coding, debugging, production
for _, mode := range []string{"L", "M", "S"} {
// Use a fresh WasmClient instance per mode to avoid shared state
w := New(config)
// Clear cache to ensure fresh generation
w.ClearJavaScriptCache()
// Change mode
w.Change(mode)
// Check that mode is saved in store
saved, err := store.Get(StoreKeySizeMode)
if err != nil {
t.Fatalf("failed to get mode from store for %q: %v", mode, err)
}
if saved != mode {
t.Fatalf("expected saved mode %q, got %q", mode, saved)
}
// Create new instance to test loading
w2 := New(config)
if w2.Value() != mode {
t.Fatalf("expected loaded mode %q, got %q", mode, w2.Value())
}
}
}