flamingo.me/flamingo-commerce/v3@v3.11.0/checkout/domain/placeorder/states/show_html_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  
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func TestShowHTML_IsFinal(t *testing.T) {
    15  	s := states.ShowHTML{}
    16  	assert.False(t, s.IsFinal())
    17  }
    18  
    19  func TestShowHTML_Name(t *testing.T) {
    20  	s := states.ShowHTML{}
    21  	assert.Equal(t, "ShowHTML", s.Name())
    22  }
    23  
    24  func TestShowHTML_Rollback(t *testing.T) {
    25  	s := states.ShowHTML{}
    26  	assert.Nil(t, s.Rollback(context.Background(), nil))
    27  }
    28  
    29  func TestShowHTML_Run(t *testing.T) {
    30  	s := states.ShowHTML{}
    31  	isCalled := false
    32  	s.Inject(nil, func(_ context.Context, _ *process.Process, _ *application.PaymentService) process.RunResult {
    33  		isCalled = true
    34  		return process.RunResult{}
    35  	})
    36  
    37  	s.Run(context.Background(), nil)
    38  
    39  	assert.True(t, isCalled)
    40  }
    41  
    42  func TestNewShowHTMLStateData(t *testing.T) {
    43  	assert.Equal(t, process.StateData("<h2>test</h2>"), states.NewShowHTMLStateData("<h2>test</h2>"))
    44  }