Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 83 additions & 2 deletions operator_creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,92 @@ func TestOperatorCreationCombineLatestAny(t *testing.T) { //nolint:paralleltest
}

func TestOperatorCreationZip(t *testing.T) { //nolint:paralleltest
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestOperatorCreationZip(t *testing.T) { //nolint:paralleltest
func TestOperatorCreationZip(t *testing.T) {
t.Parallel()

// @TODO: implement
testWithTimeout(t, 100*time.Millisecond)
is := assert.New(t)

t.Run("Zip with single observable", func(t *testing.T) {
obs := Zip(
Just[any](1, 2, 3),
)

values, err := Collect(obs)
is.NoError(err)

is.Equal([][]any{
{1},
{2},
{3},
}, values)
})

t.Run("Zip with two observables", func(t *testing.T) {
obs := Zip(
Just[any](1, 2, 3),
Just[any]("A", "B", "C"),
)

values, err := Collect(obs)
is.NoError(err)

is.Equal([][]any{
{1, "A"},
{2, "B"},
{3, "C"},
}, values)
})

t.Run("Zip with three observables", func(t *testing.T) {
obs := Zip(
Just[any](1, 2, 3),
Just[any]("A", "B", "C"),
Just[any](true, false, true),
)

values, err := Collect(obs)
is.NoError(err)

is.Equal([][]any{
{1, "A", true},
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lo.T3(...)

{2, "B", false},
{3, "C", true},
}, values)
})
}

func TestOperatorCreationZip2(t *testing.T) { //nolint:paralleltest
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func TestOperatorCreationZip2(t *testing.T) { //nolint:paralleltest
func TestOperatorCreationZip(t *testing.T) {
t.Parallel()

// @TODO: implement
testWithTimeout(t, 100*time.Millisecond)
is := assert.New(t)

t.Run("Zip2 with equal length observables", func(t *testing.T) {
obs := Zip2(
Just(1, 2, 3),
Just("A", "B", "C"),
)

values, err := Collect(obs)
is.NoError(err)

is.Equal([]lo.Tuple2[int, string]{
{A: 1, B: "A"},
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lo.T2(...) instead

{A: 2, B: "B"},
{A: 3, B: "C"},
}, values)
})

t.Run("Zip2 with unequal length observables", func(t *testing.T) {
obs := Zip2(
Just(1, 2, 3, 4, 5),
Just("A", "B"),
)

values, err := Collect(obs)
is.NoError(err)

is.Equal([]lo.Tuple2[int, string]{
{A: 1, B: "A"},
{A: 2, B: "B"},
}, values)
})
}

func TestOperatorCreationZip3(t *testing.T) { //nolint:paralleltest
Expand Down