Skip to content

Commit

Permalink
Create actionRowBuilder.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Jul 17, 2024
1 parent b36f1f8 commit 925bc96
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/util/builder/actionRowBuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
let expect;
before(async () => {
expect = (await import("chai")).expect;
});
const Button = require("../../../src/util/builder/buttonBuilder");
const ActionRow = require("../../../src/util/builder/actionRowBuilder");
const { COMPONENT_TYPES } = require("../../../src/constants");

describe("ActionRowBuilder", () => {
context("check import", function () {
it("should be an object", function () {
const actionRow = new ActionRow();
expect(actionRow).to.be.an("object");
});
});
context("check addComponent", function () {
it("should have method addComponent", function () {
const actionRow = new ActionRow();
expect(actionRow).to.respondTo("addComponent");
});
it("should add a component to the action row", function () {
const actionRow = new ActionRow();
const button = new Button()
.setCustomID("custom_id")
.setLabel("test")
.setStyle(1);
actionRow.addComponent(button);
expect(actionRow.components).to.have.lengthOf(1);
});
});
context("check toJSON", function () {
it("should have method toJSON", function () {
const actionRow = new ActionRow();
expect(actionRow).to.respondTo("toJSON");
});
it("should return the action row as an object", function () {
const actionRow = new ActionRow();
const button = new Button()
.setCustomID("custom_id")
.setLabel("test")
.setStyle(1);
actionRow.addComponent(button);
expect(actionRow.toJSON()).to.deep.equal({
type: COMPONENT_TYPES.ACTION_ROW,
components: [
{
type: button.type,
label: button.label,
style: button.style,
custom_id: button.custom_id,
},
],
});
});
});
});

0 comments on commit 925bc96

Please sign in to comment.