| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package app
- import (
- "encoding/json"
- "strings"
- "testing"
- )
- func TestNewState(t *testing.T) {
- s := NewService()
- st := s.State()
- if st.Name != DefaultName || st.Dirty || st.SampleCount != 0 {
- t.Errorf("state %q dirty %v samples %d", st.Name, st.Dirty, st.SampleCount)
- }
- if len(st.Pads) != 128 || st.Pads[0].Label != "A01" || st.Pads[17].Label != "B02" || st.Pads[127].Label != "H16" {
- t.Fatalf("pads: %d", len(st.Pads))
- }
- for _, p := range st.Pads {
- if p.File != "" || p.HasNotes {
- t.Fatalf("pad %s not empty", p.Label)
- }
- }
- if st.SequenceCount != 1 || st.Sequences[0] != (Sequence{Slot: 0, Label: "A01", Name: "Sequence 01", BPM: 128, Bars: 2}) {
- t.Errorf("sequences %+v", st.Sequences)
- }
- if st.Limits.MaxMuteGroup != 16 || st.Limits.MinBPM != 20 || st.Limits.MaxBPM != 999 || st.Limits.MinCoarse != -24 {
- t.Errorf("limits %+v", st.Limits)
- }
- if st2 := s.New(); st2.Name != DefaultName || len(st2.Pads) != 128 {
- t.Error("New")
- }
- }
- func TestStateJSON(t *testing.T) {
- b, err := json.Marshal(NewService().State())
- if err != nil {
- t.Fatal(err)
- }
- for _, key := range []string{`"name":"NewKit"`, `"pads":[{"slot":0,"label":"A01"`, `"sequences":[{"slot":0`, `"limits":{`, `"muteGroup":0`} {
- if !strings.Contains(string(b), key) {
- t.Errorf("JSON lacks %s", key)
- }
- }
- }
- func TestAbout(t *testing.T) {
- a := NewService().About()
- if a.Version != Version || !strings.Contains(a.License, "2026 bajdev") || !strings.HasPrefix(a.Repo, "https://") {
- t.Errorf("%+v", a)
- }
- }
|