Skip to content

Commit

Permalink
ordered map tests, extensions test
Browse files Browse the repository at this point in the history
  • Loading branch information
maddalax committed Oct 31, 2024
1 parent e268a58 commit 248e485
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
30 changes: 30 additions & 0 deletions framework/datastructure/orderedmap/orderedmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ func TestOrderedMap(t *testing.T) {
assert.False(t, ok)
assert.Equal(t, 0, value)
}

func TestOrderedMapEach(t *testing.T) {
t.Parallel()
om := New[string, int]()
om.Set("one", 1)
om.Set("two", 2)
om.Set("three", 3)

expected := map[string]int{"one": 1, "two": 2, "three": 3}
actual := make(map[string]int)

om.Each(func(key string, value int) {
actual[key] = value
})

assert.Equal(t, expected, actual)
}

func TestOrderedMapValues(t *testing.T) {
t.Parallel()
om := New[string, int]()
om.Set("first", 10)
om.Set("second", 20)
om.Set("third", 30)

values := om.Values()
expectedValues := []int{10, 20, 30}

assert.Equal(t, expectedValues, values)
}
22 changes: 22 additions & 0 deletions framework/h/extensions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package h

import (
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestBaseExtensions(t *testing.T) {
// Test when not in development
os.Unsetenv("ENV")
result := BaseExtensions()
expected := "path-deps, response-targets, mutation-error, htmgo, sse"
assert.Equal(t, expected, result)

// Test when in development
os.Setenv("ENV", "development")
result = BaseExtensions()
expected = "path-deps, response-targets, mutation-error, htmgo, sse, livereload"
assert.Equal(t, expected, result)
}

0 comments on commit 248e485

Please sign in to comment.