aboutsummaryrefslogtreecommitdiffstats
path: root/cover_test.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-05-07 11:53:51 -0400
committerSam Anthony <sam@samanthony.xyz>2026-05-07 11:53:51 -0400
commitf2ee817ba1423b10b382f6b759a19184db8eeacc (patch)
tree57d7660024b9b21d2a9ac80c351b2911b5c573e7 /cover_test.go
parent09c91d21b083abc976a4cc6439899fb00438a630 (diff)
downloadlulu-f2ee817ba1423b10b382f6b759a19184db8eeacc.zip
refactor
Diffstat (limited to 'cover_test.go')
-rw-r--r--cover_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/cover_test.go b/cover_test.go
new file mode 100644
index 0000000..a0042c1
--- /dev/null
+++ b/cover_test.go
@@ -0,0 +1,57 @@
+package lulu
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestMarshalCoverDimensionsReq(t *testing.T) {
+ t.Parallel()
+ requireMarshalJsonEq(t, `{
+ "pod_package_id": "0600X0900.BW.STD.PB.060UW444.MXX",
+ "interior_page_count": 210,
+ "unit": "pt"}`,
+ coverDimensionsReq{
+ PkgId{
+ UsTrade,
+ Mono,
+ Standard,
+ Perfect,
+ P60UncoatedWhite,
+ Matte,
+ NoLinen,
+ NoFoil},
+ 210,
+ Points})
+}
+
+func TestUnmarshalCoverDimensions(t *testing.T) {
+ t.Parallel()
+ requireUnmarshalJsonEq(t,
+ CoverDimensions{123.4, 567.8, Points},
+ `{"width": "123.400", "height": "567.800", "unit": "pt"}`)
+ requireUnmarshalJsonEq(t,
+ CoverDimensions{123.4, 567.8, Millimeters},
+ `{"width": "123.400", "height": "567.800", "unit": "mm"}`)
+ requireUnmarshalJsonEq(t,
+ CoverDimensions{123.4, 567.8, Inches},
+ `{"width": "123.400", "height": "567.800", "unit": "inch"}`)
+}
+
+func TestCoverDimensions(t *testing.T) {
+ c := newClient(t)
+ mfg := PkgId{
+ UsTrade,
+ Mono,
+ Standard,
+ Perfect,
+ P60UncoatedWhite,
+ Matte,
+ NoLinen,
+ NoFoil,
+ }
+ dims, err := c.CoverDimensions(mfg, 210, Points)
+ require.NoError(t, err)
+ require.Equal(t, CoverDimensions{920, 666, Points}, dims)
+}