ordered map tests, extensions test
This commit is contained in:
parent
e268a581ce
commit
248e485ff0
2 changed files with 52 additions and 0 deletions
|
|
@ -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
framework/h/extensions_test.go
Normal file
22
framework/h/extensions_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
Loading…
Reference in a new issue