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

     1  package states_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/process"
    10  	"flamingo.me/flamingo-commerce/v3/checkout/domain/placeorder/states"
    11  )
    12  
    13  func TestNew_Name(t *testing.T) {
    14  	s := states.New{}
    15  	assert.Equal(t, "New", s.Name())
    16  }
    17  
    18  func TestNew_Rollback(t *testing.T) {
    19  	s := states.New{}
    20  	assert.Nil(t, s.Rollback(context.Background(), nil))
    21  }
    22  
    23  func TestNew_Run(t *testing.T) {
    24  	p := &process.Process{}
    25  	state := states.New{}
    26  
    27  	state.Run(context.Background(), p)
    28  
    29  	assert.Equal(t, states.PrepareCart{}.Name(), p.Context().CurrentStateName, "Next state after New should be PrepareCart.")
    30  }
    31  
    32  func TestNew_IsFinal(t *testing.T) {
    33  	state := states.New{}
    34  	assert.False(t, state.IsFinal())
    35  }