mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-28 20:55:52 -05:00
It turns out that when I switched us from `assert` to `assert.strict`,
I didn't actually update any existing tests or tell anyone:
0df0d234f2
So apparently everyone else just kept on using `strictEqual`.
This will be a PR and also throw an error if people continue trying to
use it, which should make it much clearer what PS policy is on this.
A lot of the problem may be that TypeScript marks assert.strict.equal
as deprecated when it's not. This was fixed 4 days ago:
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48452
But this probably hasn't made it to a thing yet. Until then, you'll
have to deal with TS marking your tests as deprecated, but it shouldn't
be too long.
Accidentally using `assert` instead of `assert.strict` should now show
an error. This protects against the probably much worse mistake of
accidentally using `assert.equal` rather than `assert.strict.equal`.
`assert.ok` is also deprecated now.
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
/**
|
|
* Tests for the Repeats chat plugin
|
|
* @author Annika
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const assert = require('assert').strict;
|
|
const Repeats = require('../../../.server-dist/chat-plugins/repeats').Repeats;
|
|
|
|
describe("Repeats plugin", () => {
|
|
before(() => {
|
|
this.room = Rooms.createChatRoom('repeatstest');
|
|
});
|
|
|
|
it('should add repeats correctly', () => {
|
|
assert(!Repeats.repeats.has(this.room));
|
|
|
|
Repeats.addRepeat(this.room, {id: 'happyface', phrase: "^_^", interval: 1});
|
|
|
|
assert(Repeats.repeats.has(this.room));
|
|
|
|
assert(Repeats.repeats.get(this.room).has('happyface'));
|
|
|
|
assert(Repeats.repeats.get(this.room).get('happyface').has("^_^"));
|
|
|
|
assert(this.room.settings.repeats);
|
|
assert(this.room.settings.repeats.some(repeat => repeat.phrase === "^_^"));
|
|
});
|
|
|
|
it('should remove repeats correctly', () => {
|
|
Repeats.addRepeat(this.room, {id: 'weirdface', phrase: "^_-", interval: 1});
|
|
assert(Repeats.repeats.get(this.room).get('weirdface').has("^_-"));
|
|
assert(this.room.settings.repeats.some(repeat => repeat.phrase === "^_-"));
|
|
|
|
Repeats.removeRepeat(this.room, 'weirdface');
|
|
assert.equal(Repeats.repeats.get(this.room).get('weirdface'), undefined);
|
|
assert(!this.room.settings.repeats.some(repeat => repeat.phrase === "^_-"));
|
|
});
|
|
|
|
it('should be able to tell if a repeat exists or not', () => {
|
|
assert(!Repeats.hasRepeat(this.room, 'annoyedface'));
|
|
|
|
Repeats.addRepeat(this.room, {id: 'annoyedface', phrase: "-_-", interval: 1});
|
|
assert(Repeats.hasRepeat(this.room, 'annoyedface'));
|
|
|
|
Repeats.removeRepeat(this.room, 'annoyedface');
|
|
assert(!Repeats.hasRepeat(this.room, 'annoyedface'));
|
|
});
|
|
});
|