import assert = require("assert"); import Ext, {Viber} from "../src/index"; describe("Ext", ()=>{ describe("viber", ()=>{ it ("should assert style in keyboard template.", ()=>{ const style = new Viber.ButtonStyle(); style.bgColor = "red"; style.fgColor = "#FFFFFF" const button = Ext.viber.buttonTemplate(null, [ Ext.viber.postbackButton("Recime", "recime", style) ]); assert.equal(button.keyboard.Buttons[0].BgColor, "red"); assert.equal(button.keyboard.Buttons[0].Text, `Recime`); }); it ("should assert grid button template", ()=>{ const style = new Viber.ButtonStyle(); const button = new Viber.Button(style); button.type = 'web_url'; button.url = "https://recime.io" button.text = "Test"; const vb = new Viber.GridButton(button); vb.rows = 1; vb.columns = 6; assert.equal(vb.toJSONObject().Rows, 1); assert.equal(vb.toJSONObject().Columns, 6); assert.equal(vb.toJSONObject().ActionType, "open-url"); }); it ("should assert button template", ()=>{ const button = Ext.viber.buttonTemplate("text", [ Ext.viber.postbackButton('button1', 'about', { bgColor : '#e30c2e', fgColor : '#fff', row : 0, column : 0 }), Ext.viber.postbackButton('button1', 'about', { bgColor : '#e30c2e', fgColor : '#fff', row : 0, column : 1, }), ]); assert.equal(button.keyboard.Buttons[0].BgColor, "#e30c2e"); assert.equal(button.keyboard.Buttons[0].Columns, 3); }); it ("should assert naked button template", ()=>{ const button = Ext.viber.buttonTemplate("text", [{ bgColor : '#e30c2e', fgColor : '#fff', row : 0, column : 0 } ]); assert.equal(button.keyboard.Buttons[0].BgColor, "#e30c2e"); }); }); });