aboutsummaryrefslogtreecommitdiffstats
path: root/cover_test.go
blob: a0042c1d798ca9502edf74016e5d0853550e5813 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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)
}