flamingo.me/flamingo-commerce/v3@v3.11.0/checkout/domain/placeorder/states/wait_for_customer_test.go (about)

     1  package states_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/process"
     8  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/states"
     9  	"flamingo.me/flamingo-commerce/v3/payment/application"
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  func TestWaitForCustomer_IsFinal(t *testing.T) {
    14  	s := states.WaitForCustomer{}
    15  	assert.False(t, s.IsFinal())
    16  }
    17  
    18  func TestWaitForCustomer_Name(t *testing.T) {
    19  	s := states.WaitForCustomer{}
    20  	assert.Equal(t, "WaitForCustomer", s.Name())
    21  }
    22  
    23  func TestWaitForCustomer_Rollback(t *testing.T) {
    24  	s := states.WaitForCustomer{}
    25  	assert.Nil(t, s.Rollback(context.Background(), nil))
    26  }
    27  
    28  func TestWaitForCustomer_Run(t *testing.T) {
    29  	s := states.WaitForCustomer{}
    30  	isCalled := false
    31  	s.Inject(nil, func(_ context.Context, _ *process.Process, _ *application.PaymentService) process.RunResult {
    32  		isCalled = true
    33  		return process.RunResult{}
    34  	})
    35  
    36  	s.Run(context.Background(), nil)
    37  
    38  	assert.True(t, isCalled)
    39  }