package zhongwuapi

import (
	"testing"

	"git.rosy.net.cn/baseapi"

	"go.uber.org/zap"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

func init() {
	logger, _ := zap.NewDevelopment()
	sugarLogger = logger.Sugar()
	baseapi.Init(sugarLogger)

	api = New(8000192, "29435497822f52f3cf659c65da548a79")
}

func handleError(t *testing.T, err error) {
	if err != nil {
		sugarLogger.Debug(err)
		t.Fatal(err.Error())
	}
}

func TestPrintMsg(t *testing.T) {
	id, status, err := api.PrintMsg("deviceid", "devicesecret", "printdata")
	handleError(t, err)
	baseapi.SugarLogger.Debug(id, status)
}

func TestGetPrinterStatus(t *testing.T) {
	status, err := api.GetPrinterStatus("ZW202104501422", "")
	handleError(t, err)
	baseapi.SugarLogger.Debug(status)
}
