Files
baseapi/platformapi/trenditapi/trendit_test.go
richboo111 0901cfc573 im
2023-04-25 10:31:54 +08:00

116 lines
3.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package trenditapi
import (
"fmt"
"testing"
)
var api = New(TiAppID, TiAppSecret)
func TestLen(t *testing.T) {
str := "--------------------------------"
fmt.Println(len(str))
}
//打印
func TestAPI_Print(t *testing.T) {
name1 := "[优]猪肉馅约250g/份"
name2 := "鲜鸡蛋约250g/份"
name3 := "[精选优品][精选优品][精选优品][精选优品][精选优品]豌豆米-手工剥豆约100g/份"
name4 := "娃娃菜200g/个"
len1 := len(name1)
len2 := len(name2)
len3 := len(name3)
len4 := len(name4)
len5 := len("--------------------------------")
fmt.Println(len1, len2, len3, len4, len5)
content := `
<LEFT>商品列表</LEFT><BR>`
content += "商品名" + StrRepeat(" ", 13) + "数量" + "<BR>"
content += `--------------------------------`
content += FormatPrintOrderItemV2(name1, 1, 1)
content += FormatPrintOrderItemV2(name2, 1, 2)
content += FormatPrintOrderItemV2(name3, 1, 3)
content += FormatPrintOrderItemV2(name4, 5, 4)
content += `<BR><LEFT><font# bolder=0 height=2 width=1>共4种9件商品</font#></LEFT><BR>`
content += `<font# bolder=0 height=2 width=1>--------------#20完-------------</font#>`
msg, err := api.Print(TestSn, content, VoiceNewShort)
fmt.Println(msg)
fmt.Println(err)
}
func TestCal(t *testing.T) {
str := "豌豆米-手工剥豆约100g/份"
//ans := "--------------------------------"
cnt := CalWidth(str)
fmt.Println(cnt)
}
//打印取消/退货模板
func TestAPI_Print2(t *testing.T) {
content := `<C><font# bolder=1 height=2 width=2>京西菜市</font#></C><BR>`
content += StrRepeat("-", 32) + `
<LEFT><font# bolder=1 height=1 width=1>下单时间2023-03-27 13:22:05</font#></LEFT>
<LEFT><font# bolder=0 height=2 width=1>订单编号: E22092832084572779</font#></LEFT><BR>
<font# bolder=1 height=2 width=2>美团外卖#20</font#>
<font# bolder=1 height=2 width=2>取消订单</font#>
<font# bolder=1 height=1 width=1>--------------------------------</font#>`
content += `<LEFT><font# bolder=1 height=2 width=1>共4种9件商品</font#></LEFT>
<LEFT><font# bolder=1 height=2 width=1>实付金额: 327.83元</font#></LEFT><BR>
<font# bolder=0 height=1 width=1>--------------#20完-------------</font#>`
msg, err := api.Print(TestSn, content, VoiceCancelShort)
fmt.Println(msg)
fmt.Println(err)
}
//增加打印机
func TestAddPrinter(t *testing.T) {
err := api.AddPrinter(TestSn, TestKey, "京西菜市打印机0327")
fmt.Println(err)
}
//修改打印机信息
func TestEditPrinter(t *testing.T) {
msg, err := api.EditPrinter("763675325672", "京西菜市打印机v2")
fmt.Println(msg)
fmt.Println(err)
}
//删除打印机
func TestAPI_DelPrinter(t *testing.T) {
err := api.DelPrinter([]string{TestSn})
fmt.Println(err)
}
//设置打印浓度
func TestAPI_SetDensity(t *testing.T) {
err := api.SetDensity(TestSn, DensityStrong)
fmt.Println(err)
}
//设置音量
func TestAPI_SetVolume(t *testing.T) {
err := api.SetVolume(TestSn, Volume1)
fmt.Println(err)
}
//查询打印机状态
func TestGetDevicesStatus(t *testing.T) {
onlineStatus, workStatus, err := api.GetDeviceStatus("570010021789")
fmt.Println(onlineStatus)
fmt.Println(workStatus)
fmt.Println(err)
}
//清空设备待打印队列
func TestAPI_CleanWaitingQueue(t *testing.T) {
err := api.CleanWaitingQueue(TestSn)
fmt.Println(err)
}
func TestInt(t *testing.T) {
temp := 1000
fmt.Println(int(temp / 1000))
}