2019-07-02 12:02:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
|
|
|
const inputs = require("../../../src/plugins/inputs");
|
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
describe("inputs", function () {
|
2021-07-03 20:46:36 -04:00
|
|
|
const client = {
|
|
|
|
messageProvider: undefined,
|
|
|
|
};
|
|
|
|
const clientWithProvider = {
|
|
|
|
...client,
|
|
|
|
messageProvider: true,
|
|
|
|
};
|
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
describe(".getCommands", function () {
|
|
|
|
it("should return a non-empty array", function () {
|
2021-07-03 20:46:36 -04:00
|
|
|
expect(inputs.getCommands(client)).to.be.an("array").that.is.not.empty;
|
2019-07-02 12:02:02 -04:00
|
|
|
});
|
|
|
|
|
2020-03-21 16:55:36 -04:00
|
|
|
it("should only return strings with no whitespaces and starting with /", function () {
|
2021-07-03 20:46:36 -04:00
|
|
|
inputs.getCommands(client).forEach((command) => {
|
2020-03-21 16:55:36 -04:00
|
|
|
expect(command).to.be.a("string").that.does.not.match(/\s/);
|
2019-07-02 12:02:02 -04:00
|
|
|
expect(command[0]).to.equal("/");
|
|
|
|
});
|
|
|
|
});
|
2021-07-03 20:46:36 -04: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 12:02:02 -04:00
|
|
|
});
|
|
|
|
});
|