Reapply "feat(loyalty): EnakPoint & EnakCoin" (#32)
This reverts commit 4e24f9bbb0.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package transformer
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"apskel-pos-be/internal/contract"
|
||||
"apskel-pos-be/internal/models"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -46,3 +49,14 @@ func TestAddToOrderContractToModelCarriesWeight(t *testing.T) {
|
||||
require.NotNil(t, result.OrderItems[0].Weight)
|
||||
require.Equal(t, weight, *result.OrderItems[0].Weight)
|
||||
}
|
||||
|
||||
func TestOrderModelToContractCarriesEarnings(t *testing.T) {
|
||||
got := OrderModelToContract(&models.OrderResponse{PointsEarned: 875, CoinsEarned: 3})
|
||||
assert.Equal(t, int64(875), got.PointsEarned)
|
||||
assert.Equal(t, int64(3), got.CoinsEarned)
|
||||
|
||||
body, err := json.Marshal(OrderModelToContract(&models.OrderResponse{}))
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(body), `"points_earned":0`, "present as 0 when nothing was earned")
|
||||
assert.Contains(t, string(body), `"coins_earned":0`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user