mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Formatting Preview Alpha
This commit is contained in:
parent
98e47e3796
commit
39f89a9f63
47 changed files with 4714 additions and 4581 deletions
190
test/wrappers.ts
190
test/wrappers.ts
|
@ -1,111 +1,107 @@
|
|||
import { strict as assert } from 'assert';
|
||||
import {
|
||||
NumberWrapper,
|
||||
StringWrapper,
|
||||
ArrayWrapper,
|
||||
} from '../src/core/wrappers';
|
||||
import {strict as assert} from "assert";
|
||||
import {NumberWrapper, StringWrapper, ArrayWrapper} from "../src/core/wrappers";
|
||||
|
||||
// I can't figure out a way to run the test suite while running the bot.
|
||||
describe('Wrappers', () => {
|
||||
describe('NumberWrapper', () => {
|
||||
describe('#pluralise()', () => {
|
||||
it('should return "5 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(5).pluralise('credit', 's'),
|
||||
'5 credits',
|
||||
);
|
||||
});
|
||||
describe("Wrappers", () => {
|
||||
describe("NumberWrapper", () => {
|
||||
describe("#pluralise()", () => {
|
||||
it('should return "5 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(5).pluralise("credit", "s"),
|
||||
"5 credits"
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "1 credit"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise('credit', 's'),
|
||||
'1 credit',
|
||||
);
|
||||
});
|
||||
it('should return "1 credit"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise("credit", "s"),
|
||||
"1 credit"
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "-1 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(-1).pluralise('credit', 's'),
|
||||
'-1 credits',
|
||||
);
|
||||
});
|
||||
it('should return "-1 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(-1).pluralise("credit", "s"),
|
||||
"-1 credits"
|
||||
);
|
||||
});
|
||||
|
||||
it('should be able to work with a plural suffix', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(2).pluralise('part', 'ies', 'y'),
|
||||
'2 parties',
|
||||
);
|
||||
});
|
||||
it("should be able to work with a plural suffix", () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(2).pluralise("part", "ies", "y"),
|
||||
"2 parties"
|
||||
);
|
||||
});
|
||||
|
||||
it('should be able to work with a singular suffix', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise('part', 'ies', 'y'),
|
||||
'1 party',
|
||||
);
|
||||
});
|
||||
it("should be able to work with a singular suffix", () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise("part", "ies", "y"),
|
||||
"1 party"
|
||||
);
|
||||
});
|
||||
|
||||
it('should be able to exclude the number', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise('credit', 's', '', true),
|
||||
'credit',
|
||||
);
|
||||
});
|
||||
it("should be able to exclude the number", () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluralise("credit", "s", "", true),
|
||||
"credit"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#pluraliseSigned()", () => {
|
||||
it('should return "-1 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(-1).pluraliseSigned("credit", "s"),
|
||||
"-1 credits"
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "+0 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(0).pluraliseSigned("credit", "s"),
|
||||
"+0 credits"
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "+1 credit"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluraliseSigned("credit", "s"),
|
||||
"+1 credit"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#pluraliseSigned()', () => {
|
||||
it('should return "-1 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(-1).pluraliseSigned('credit', 's'),
|
||||
'-1 credits',
|
||||
);
|
||||
});
|
||||
describe("StringWrapper", () => {
|
||||
describe("#replaceAll()", () => {
|
||||
it('should convert "test" to "zesz"', () => {
|
||||
assert.strictEqual(
|
||||
new StringWrapper("test").replaceAll("t", "z"),
|
||||
"zesz"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return "+0 credits"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(0).pluraliseSigned('credit', 's'),
|
||||
'+0 credits',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return "+1 credit"', () => {
|
||||
assert.strictEqual(
|
||||
new NumberWrapper(1).pluraliseSigned('credit', 's'),
|
||||
'+1 credit',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('StringWrapper', () => {
|
||||
describe('#replaceAll()', () => {
|
||||
it('should convert "test" to "zesz"', () => {
|
||||
assert.strictEqual(
|
||||
new StringWrapper('test').replaceAll('t', 'z'),
|
||||
'zesz',
|
||||
);
|
||||
});
|
||||
describe("#toTitleCase()", () => {
|
||||
it("should capitalize the first letter of each word", () => {
|
||||
assert.strictEqual(
|
||||
new StringWrapper(
|
||||
"yeetus deletus find salvation from jesus"
|
||||
).toTitleCase(),
|
||||
"Yeetus Deletus Find Salvation From Jesus"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toTitleCase()', () => {
|
||||
it('should capitalize the first letter of each word', () => {
|
||||
assert.strictEqual(
|
||||
new StringWrapper(
|
||||
'yeetus deletus find salvation from jesus',
|
||||
).toTitleCase(),
|
||||
'Yeetus Deletus Find Salvation From Jesus',
|
||||
);
|
||||
});
|
||||
describe("ArrayWrapper", () => {
|
||||
describe("#split()", () => {
|
||||
it("should split [1,2,3,4,5,6,7,8,9,10] into [[1,2,3],[4,5,6],[7,8,9],[10]]", () => {
|
||||
assert.deepStrictEqual(
|
||||
new ArrayWrapper([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).split(3),
|
||||
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArrayWrapper', () => {
|
||||
describe('#split()', () => {
|
||||
it('should split [1,2,3,4,5,6,7,8,9,10] into [[1,2,3],[4,5,6],[7,8,9],[10]]', () => {
|
||||
assert.deepStrictEqual(
|
||||
new ArrayWrapper([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).split(3),
|
||||
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]],
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue