-
Notifications
You must be signed in to change notification settings - Fork 2
/
aggregates_test.go
54 lines (45 loc) · 1.16 KB
/
aggregates_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package yit
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gopkg.in/yaml.v3"
)
var _ = Describe("Aggregates", func() {
Describe("AnyMatch", func() {
It("returns true if any element matches the predicate", func() {
result := FromNode(docNode).AnyMatch(All)
Expect(result).To(BeTrue())
})
It("returns false if no element matches the predicate", func() {
result := FromNode(docNode).AnyMatch(None)
Expect(result).To(BeFalse())
})
})
Describe("AllMatch", func() {
It("returns true if all elements matches the predicate", func() {
result := FromNodes(
scalarNode("a"),
scalarNode("a"),
).AllMatch(WithValue("a"))
Expect(result).To(BeTrue())
})
It("returns false if any element does not matches the predicate", func() {
result := FromNodes(
scalarNode("a"),
scalarNode("b"),
).AllMatch(WithValue("a"))
Expect(result).To(BeFalse())
})
})
Describe("ToArray", func() {
It("adds all the iterated elements to an array", func() {
nodes := []*yaml.Node{
{Value: "a"},
{Value: "b"},
{Value: "c"},
}
result := FromNodes(nodes...).ToArray()
Expect(result).To(Equal(nodes))
})
})
})