thelounge/test/plugins/inputs/indexTest.js

38 lines
1 KiB
JavaScript
Raw Normal View History

2019-07-02 18:02:02 +02:00
"use strict";
const expect = require("chai").expect;
const inputs = require("../../../src/plugins/inputs");
describe("inputs", function () {
2021-07-04 02:46:36 +02:00
const client = {
messageProvider: undefined,
};
const clientWithProvider = {
...client,
messageProvider: true,
};
describe(".getCommands", function () {
it("should return a non-empty array", function () {
2021-07-04 02:46:36 +02:00
expect(inputs.getCommands(client)).to.be.an("array").that.is.not.empty;
2019-07-02 18:02:02 +02:00
});
it("should only return strings with no whitespaces and starting with /", function () {
2021-07-04 02:46:36 +02:00
inputs.getCommands(client).forEach((command) => {
expect(command).to.be.a("string").that.does.not.match(/\s/);
2019-07-02 18:02:02 +02:00
expect(command[0]).to.equal("/");
});
});
2021-07-04 02:46:36 +02:00
it("should not include /search without a message provider", function () {
expect(inputs.getCommands(client)).to.be.an("array").that.does.not.contains("/search");
});
it("should include /search with a message provider", function () {
expect(inputs.getCommands(clientWithProvider))
.to.be.an("array")
.that.contains("/search");
});
2019-07-02 18:02:02 +02:00
});
});