Enable tsc alwaysStrict, strictBindCallApply, noImplicitThis (#9600)
* Enable tsc alwaysStrict * Enable tsc strictBindCallApply * Enable tsc noImplicitThis * Add d.ts * Improve types * Add ? * Increase coverage * Improve coverage
This commit is contained in:
parent
0b54699829
commit
8c0d202df4
23 changed files with 188 additions and 68 deletions
|
@ -131,9 +131,9 @@ describe("ContentMessages", () => {
|
|||
jest.spyOn(document, "createElement").mockImplementation(tagName => {
|
||||
const element = createElement(tagName);
|
||||
if (tagName === "video") {
|
||||
element.load = jest.fn();
|
||||
element.play = () => element.onloadeddata(new Event("loadeddata"));
|
||||
element.pause = jest.fn();
|
||||
(<HTMLVideoElement>element).load = jest.fn();
|
||||
(<HTMLVideoElement>element).play = () => element.onloadeddata(new Event("loadeddata"));
|
||||
(<HTMLVideoElement>element).pause = jest.fn();
|
||||
Object.defineProperty(element, 'videoHeight', {
|
||||
get() { return 600; },
|
||||
});
|
||||
|
|
|
@ -433,4 +433,11 @@ describe("Notifier", () => {
|
|||
expect(Notifier._displayPopupNotification).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("setPromptHidden", () => {
|
||||
it("should persist by default", () => {
|
||||
Notifier.setPromptHidden(true);
|
||||
expect(localStorage.getItem("notifications_hidden")).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -225,4 +225,19 @@ describe('SlashCommands', () => {
|
|||
expect(client.leaveRoomChain).toHaveBeenCalledWith("room-id", expect.anything());
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
"rainbow",
|
||||
"rainbowme",
|
||||
])("/%s", (commandName: string) => {
|
||||
const command = findCommand(commandName);
|
||||
|
||||
it("should return usage if no args", () => {
|
||||
expect(command.run(roomId, null, null).error).toBe(command.getUsage());
|
||||
});
|
||||
|
||||
it("should make things rainbowy", () => {
|
||||
return expect(command.run(roomId, null, "this is a test message").promise).resolves.toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
19
test/__snapshots__/SlashCommands-test.tsx.snap
Normal file
19
test/__snapshots__/SlashCommands-test.tsx.snap
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`SlashCommands /rainbow should make things rainbowy 1`] = `
|
||||
{
|
||||
"body": "this is a test message",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": "<font color="#ff00be">t</font><font color="#ff0080">h</font><font color="#ff0041">i</font><font color="#ff5f00">s</font> <font color="#faa900">i</font><font color="#c3bf00">s</font> <font color="#00d800">a</font> <font color="#00e371">t</font><font color="#00e6b6">e</font><font color="#00e7f8">s</font><font color="#00e7ff">t</font> <font color="#00deff">m</font><font color="#00d2ff">e</font><font color="#00c0ff">s</font><font color="#44a4ff">s</font><font color="#e87dff">a</font><font color="#ff42ff">g</font><font color="#ff00fe">e</font>",
|
||||
"msgtype": "m.text",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`SlashCommands /rainbowme should make things rainbowy 1`] = `
|
||||
{
|
||||
"body": "this is a test message",
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": "<font color="#ff00be">t</font><font color="#ff0080">h</font><font color="#ff0041">i</font><font color="#ff5f00">s</font> <font color="#faa900">i</font><font color="#c3bf00">s</font> <font color="#00d800">a</font> <font color="#00e371">t</font><font color="#00e6b6">e</font><font color="#00e7f8">s</font><font color="#00e7ff">t</font> <font color="#00deff">m</font><font color="#00d2ff">e</font><font color="#00c0ff">s</font><font color="#44a4ff">s</font><font color="#e87dff">a</font><font color="#ff42ff">g</font><font color="#ff00fe">e</font>",
|
||||
"msgtype": "m.emote",
|
||||
}
|
||||
`;
|
31
test/components/views/Validation-test.ts
Normal file
31
test/components/views/Validation-test.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import withValidation from "../../../src/components/views/elements/Validation";
|
||||
|
||||
describe("Validation", () => {
|
||||
it("should handle 0 rules", () => {
|
||||
const handler = withValidation({
|
||||
rules: [],
|
||||
});
|
||||
return expect(handler({
|
||||
value: "value",
|
||||
focused: true,
|
||||
})).resolves.toEqual(expect.objectContaining({
|
||||
valid: true,
|
||||
}));
|
||||
});
|
||||
});
|
|
@ -46,20 +46,20 @@ export const createTestPlayback = (): Playback => {
|
|||
return true;
|
||||
},
|
||||
// EventEmitter
|
||||
on: eventEmitter.on.bind(eventEmitter),
|
||||
once: eventEmitter.once.bind(eventEmitter),
|
||||
off: eventEmitter.off.bind(eventEmitter),
|
||||
addListener: eventEmitter.addListener.bind(eventEmitter),
|
||||
removeListener: eventEmitter.removeListener.bind(eventEmitter),
|
||||
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter),
|
||||
getMaxListeners: eventEmitter.getMaxListeners.bind(eventEmitter),
|
||||
setMaxListeners: eventEmitter.setMaxListeners.bind(eventEmitter),
|
||||
listeners: eventEmitter.listeners.bind(eventEmitter),
|
||||
rawListeners: eventEmitter.rawListeners.bind(eventEmitter),
|
||||
listenerCount: eventEmitter.listenerCount.bind(eventEmitter),
|
||||
eventNames: eventEmitter.eventNames.bind(eventEmitter),
|
||||
prependListener: eventEmitter.prependListener.bind(eventEmitter),
|
||||
prependOnceListener: eventEmitter.prependOnceListener.bind(eventEmitter),
|
||||
on: eventEmitter.on.bind(eventEmitter) as Playback["on"],
|
||||
once: eventEmitter.once.bind(eventEmitter) as Playback["once"],
|
||||
off: eventEmitter.off.bind(eventEmitter) as Playback["off"],
|
||||
addListener: eventEmitter.addListener.bind(eventEmitter) as Playback["addListener"],
|
||||
removeListener: eventEmitter.removeListener.bind(eventEmitter) as Playback["removeListener"],
|
||||
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter) as Playback["removeAllListeners"],
|
||||
getMaxListeners: eventEmitter.getMaxListeners.bind(eventEmitter) as Playback["getMaxListeners"],
|
||||
setMaxListeners: eventEmitter.setMaxListeners.bind(eventEmitter) as Playback["setMaxListeners"],
|
||||
listeners: eventEmitter.listeners.bind(eventEmitter) as Playback["listeners"],
|
||||
rawListeners: eventEmitter.rawListeners.bind(eventEmitter) as Playback["rawListeners"],
|
||||
listenerCount: eventEmitter.listenerCount.bind(eventEmitter) as Playback["listenerCount"],
|
||||
eventNames: eventEmitter.eventNames.bind(eventEmitter) as Playback["eventNames"],
|
||||
prependListener: eventEmitter.prependListener.bind(eventEmitter) as Playback["prependListener"],
|
||||
prependOnceListener: eventEmitter.prependOnceListener.bind(eventEmitter) as Playback["prependOnceListener"],
|
||||
liveData: new SimpleObservable<number[]>(),
|
||||
durationSeconds: 31415,
|
||||
timeSeconds: 3141,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue