package jxprintapi

import (
	"git.rosy.net.cn/baseapi"
	"go.uber.org/zap"
	"testing"
)

var (
	api         *API
	sugarLogger *zap.SugaredLogger
)

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

	api = New("1000", "rfBd56ti2SMtYvSg")
}

func TestAddPrinter(t *testing.T) {
	err := api.AddPrinter([]*AddPrinterParam{
		&AddPrinterParam{
			PrintNo: "20210615000012",
			Name:    "test1",
		},
	})
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestDelPrinter(t *testing.T) {
	err := api.DelPrinter([]string{"20210615000012"})
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestUpdatePrinter(t *testing.T) {
	err := api.UpdatePrinter(&UpdatePrinterParam{
		PrintNo: "20210615000011",
	})
	if err != nil {
		t.Fatalf("PrintMsg return error:%v", err)
	}
	//baseapi.SugarLogger.Debug(result)
}

func TestDelPrinterSeq(t *testing.T) {
	err := api.DelPrinterSeq("20210615000012")
	if err != nil {
		t.Fatal(err)
	}
	//t.Log(utils.Format4Output(result, false))
}

func TestGetPrintMsg(t *testing.T) {
	result, err := api.GetPrintMsg("20210715104649_F3Z2JXyj")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

func TestGetPrinterStatus(t *testing.T) {
	result, err := api.GetPrinterStatus("20210615000010")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}

// 20210615000012
func TestDoPrint(t *testing.T) {
	result, err := api.DoPrint("20210615000010", "<center>11111</center><br>", 2)
	if err != nil {
		t.Fatal(err)
	}
	t.Log(result)
}
