-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHead_test.go
38 lines (30 loc) · 954 Bytes
/
Head_test.go
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
package godash_test
import (
"testing"
"github.com/changchanghwang/godash"
"github.com/stretchr/testify/assert"
)
func TestHead(t *testing.T) {
t.Run("Without Chain struct", func(t *testing.T) {
t.Run("It should return the first element of the slice", func(t *testing.T) {
target := []int{1, 2, 3}
result, exist := godash.Head(target)
assert.Equal(t, 1, result)
assert.Equal(t, true, exist)
})
t.Run("It should return the first element of the chaining slice", func(t *testing.T) {
target := []string{"A", "B", "C"}
result, exist := godash.Chain(target).Head()
assert.Equal(t, "A", result)
assert.Equal(t, true, exist)
})
})
t.Run("With Chain struct", func(t *testing.T) {
t.Run("It should return the first element of the chaining slice", func(t *testing.T) {
target := []string{}
result, exist := godash.Chain(target).Head()
assert.Equal(t, "", result)
assert.Equal(t, false, exist)
})
})
}