mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-27 02:46:15 -04:00
Moved to ts (#6593)
* Moved to ts * Fixed type check * Removed js suffixes * Migrated to ts * Fixed ts. * Fixed type check * Installed missing d ts
This commit is contained in:
parent
5ee2c4e7f8
commit
7e3ad03e2f
81 changed files with 961 additions and 830 deletions
|
@ -2,12 +2,11 @@
|
|||
|
||||
import {MapArrayType} from "../../node/types/MapType";
|
||||
|
||||
const AttributePool = require('../../static/js/AttributePool');
|
||||
const apiHandler = require('../../node/handler/APIHandler');
|
||||
import AttributePool from '../../static/js/AttributePool';
|
||||
const assert = require('assert').strict;
|
||||
const io = require('socket.io-client');
|
||||
const log4js = require('log4js');
|
||||
const {padutils} = require('../../static/js/pad_utils');
|
||||
import padutils from '../../static/js/pad_utils';
|
||||
const process = require('process');
|
||||
const server = require('../../node/server');
|
||||
const setCookieParser = require('set-cookie-parser');
|
||||
|
|
|
@ -8,7 +8,7 @@ const db = require('../../../node/db/DB');
|
|||
const importEtherpad = require('../../../node/utils/ImportEtherpad');
|
||||
const padManager = require('../../../node/db/PadManager');
|
||||
const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||
const {randomString} = require('../../../static/js/pad_utils');
|
||||
import {randomString} from '../../../static/js/pad_utils';
|
||||
|
||||
describe(__filename, function () {
|
||||
let padId: string;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import {MapArrayType} from "../../../node/types/MapType";
|
||||
import {PluginDef} from "../../../node/types/PartType";
|
||||
|
||||
const ChatMessage = require('../../../static/js/ChatMessage');
|
||||
import ChatMessage from '../../../static/js/ChatMessage';
|
||||
const {Pad} = require('../../../node/db/Pad');
|
||||
const assert = require('assert').strict;
|
||||
const common = require('../common');
|
||||
|
@ -103,10 +103,14 @@ describe(__filename, function () {
|
|||
checkHook('chatNewMessage', ({message}) => {
|
||||
assert(message != null);
|
||||
assert(message instanceof ChatMessage);
|
||||
assert.equal(message.authorId, authorId);
|
||||
assert.equal(message.text, this.test!.title);
|
||||
assert(message.time >= start);
|
||||
assert(message.time <= Date.now());
|
||||
// @ts-ignore
|
||||
assert.equal(message!.authorId, authorId);
|
||||
// @ts-ignore
|
||||
assert.equal(message!.text, this.test!.title);
|
||||
// @ts-ignore
|
||||
assert(message!.time >= start);
|
||||
// @ts-ignore
|
||||
assert(message!.time <= Date.now());
|
||||
}),
|
||||
sendChat(socket, {text: this.test!.title}),
|
||||
]);
|
||||
|
@ -153,7 +157,9 @@ describe(__filename, function () {
|
|||
const customMetadata = {foo: this.test!.title};
|
||||
await Promise.all([
|
||||
checkHook('chatNewMessage', ({message}) => {
|
||||
// @ts-ignore
|
||||
message.text = modifiedText;
|
||||
// @ts-ignore
|
||||
message.customMetadata = customMetadata;
|
||||
}),
|
||||
(async () => {
|
||||
|
|
|
@ -11,16 +11,17 @@
|
|||
|
||||
import {APool} from "../../../node/types/PadType";
|
||||
|
||||
const AttributePool = require('../../../static/js/AttributePool');
|
||||
import AttributePool from '../../../static/js/AttributePool';
|
||||
const Changeset = require('../../../static/js/Changeset');
|
||||
const assert = require('assert').strict;
|
||||
const attributes = require('../../../static/js/attributes');
|
||||
import attributes from '../../../static/js/attributes';
|
||||
const contentcollector = require('../../../static/js/contentcollector');
|
||||
const jsdom = require('jsdom');
|
||||
import jsdom from 'jsdom';
|
||||
import {Attribute} from "../../../static/js/types/Attribute";
|
||||
|
||||
// All test case `wantAlines` values must only refer to attributes in this list so that the
|
||||
// attribute numbers do not change due to changes in pool insertion order.
|
||||
const knownAttribs = [
|
||||
const knownAttribs: Attribute[] = [
|
||||
['insertorder', 'first'],
|
||||
['italic', 'true'],
|
||||
['list', 'bullet1'],
|
||||
|
@ -336,7 +337,7 @@ pre
|
|||
describe(__filename, function () {
|
||||
for (const tc of testCases) {
|
||||
describe(tc.description, function () {
|
||||
let apool: APool;
|
||||
let apool: AttributePool;
|
||||
let result: {
|
||||
lines: string[],
|
||||
lineAttribs: string[],
|
||||
|
@ -376,11 +377,12 @@ describe(__filename, function () {
|
|||
for (const aline of result.lineAttribs) {
|
||||
const gotAlineAttribs:string[][] = [];
|
||||
gotAttribs.push(gotAlineAttribs);
|
||||
const wantAlineAttribs:string[] = [];
|
||||
const wantAlineAttribs:Attribute[] = [];
|
||||
wantAttribs.push(wantAlineAttribs);
|
||||
for (const op of Changeset.deserializeOps(aline)) {
|
||||
const gotOpAttribs:string[] = [...attributes.attribsFromString(op.attribs, apool)];
|
||||
const gotOpAttribs = [...attributes.attribsFromString(op.attribs, apool)] as unknown as Attribute;
|
||||
gotAlineAttribs.push(gotOpAttribs);
|
||||
// @ts-ignore
|
||||
wantAlineAttribs.push(attributes.sort([...gotOpAttribs]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue