From 4df3c176928b8c67198bcec72e3a05011111d7f2 Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Thu, 1 Jun 2023 20:32:53 +0800 Subject: [PATCH] Lint test files --- .eslintrc.json | 43 ++++-- package-lock.json | 263 +++++++++++++++++++------------- package.json | 4 +- test/helpers/unit.js | 16 +- test/unit/blots/block-embed.js | 26 ++-- test/unit/blots/block.js | 26 ++-- test/unit/blots/inline.js | 8 +- test/unit/blots/scroll.js | 24 +-- test/unit/core/editor.js | 255 +++++++++++++------------------ test/unit/core/quill.js | 194 +++++++++++------------ test/unit/core/selection.js | 126 +++++++-------- test/unit/formats/align.js | 10 +- test/unit/formats/bold.js | 4 +- test/unit/formats/code.js | 34 ++--- test/unit/formats/color.js | 15 +- test/unit/formats/header.js | 8 +- test/unit/formats/indent.js | 6 +- test/unit/formats/link.js | 12 +- test/unit/formats/list.js | 38 ++--- test/unit/formats/script.js | 8 +- test/unit/formats/table.js | 32 ++-- test/unit/modules/clipboard.js | 116 +++++++------- test/unit/modules/history.js | 60 ++++---- test/unit/modules/keyboard.js | 14 +- test/unit/modules/syntax.js | 42 ++--- test/unit/modules/table.js | 28 ++-- test/unit/modules/toolbar.js | 41 +++-- test/unit/theme/base/tooltip.js | 24 +-- test/unit/ui/picker.js | 30 ++-- 29 files changed, 752 insertions(+), 755 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bc531959a8..070eae1113 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,19 +1,11 @@ { - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json" - }, + "extends": ["eslint:recommended", "plugin:prettier/recommended"], "env": { "browser": true, "commonjs": true, "es6": true }, - "plugins": ["prettier", "@typescript-eslint"], + "parser": "@typescript-eslint/parser", "settings": { "import/resolver": { "webpack": { @@ -21,14 +13,33 @@ } } }, - "ignorePatterns": ["**/*.d.ts", "**/*.js", "website/**/*"], + "ignorePatterns": [ + "website/**/*", + "*.js", + "!test/helpers/**/*.js", + "!test/unit/**/*.js" + ], "rules": { "arrow-parens": ["error", "as-needed"], - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/ban-types": "off", - "@typescript-eslint/no-explicit-any": "off", "no-use-before-define": ["error", { "functions": false, "classes": false }], "prettier/prettier": "error" - } + }, + "overrides": [ + { + "files": ["test/helpers/**/*.js", "test/unit/**/*.js"], + "plugins": ["prettier"] + }, + { + "files": ["**/*.ts"], + "extends": ["plugin:@typescript-eslint/recommended"], + "excludedFiles": "*.d.ts", + "plugins": ["prettier", "@typescript-eslint"], + "rules": { + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/ban-types": "off", + "@typescript-eslint/no-explicit-any": "off" + } + } + ] } diff --git a/package-lock.json b/package-lock.json index 7af8bd61f8..bcf700aed6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,8 +25,8 @@ "@playwright/test": "^1.27.1", "@types/jasmine": "^4.3.0", "@types/lodash.clonedeep": "^4.5.7", - "@typescript-eslint/eslint-plugin": "^5.38.0", - "@typescript-eslint/parser": "^5.38.0", + "@typescript-eslint/eslint-plugin": "^5.59.8", + "@typescript-eslint/parser": "^5.59.8", "babel-loader": "^8.2.5", "babel-plugin-istanbul": "^6.1.1", "css-loader": "^6.7.1", @@ -1930,6 +1930,30 @@ "node": ">=10.0.0" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", + "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -4227,9 +4251,9 @@ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" }, "node_modules/@types/semver": { - "version": "7.3.12", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.12.tgz", - "integrity": "sha512-WwA1MW0++RfXmCr12xeYOOC5baSC9mSb0ZqCquFzKhcoF4TvHu5MKOuXsncgZcpVFhB1pXd5hZmM0ryAoCp12A==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, "node_modules/@types/serve-index": { @@ -4310,17 +4334,19 @@ "integrity": "sha512-S9q47ByT2pPvD65IvrWp7qppVMpk9WGMbVq9wbWZOHg6tnXSD4vyhao6nOSBwwfDdV2p3Kx9evA9vI+XWTfDvw==" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.41.0.tgz", - "integrity": "sha512-DXUS22Y57/LAFSg3x7Vi6RNAuLpTXwxB9S2nIA7msBb/Zt8p7XqMwdpdc1IU7CkOQUPgAqR5fWvxuKCbneKGmA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz", + "integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/type-utils": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/type-utils": "5.59.8", + "@typescript-eslint/utils": "5.59.8", "debug": "^4.3.4", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", - "regexpp": "^3.2.0", + "natural-compare-lite": "^1.4.0", "semver": "^7.3.7", "tsutils": "^3.21.0" }, @@ -4506,14 +4532,14 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/@typescript-eslint/parser": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.41.0.tgz", - "integrity": "sha512-HQVfix4+RL5YRWZboMD1pUfFN8MpRH4laziWkkAzyO1fvNOY/uinZcvo3QiFJVS/siNHupV8E5+xSwQZrl6PZA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz", + "integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/typescript-estree": "5.59.8", "debug": "^4.3.4" }, "engines": { @@ -4533,13 +4559,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.41.0.tgz", - "integrity": "sha512-xOxPJCnuktUkY2xoEZBKXO5DBCugFzjrVndKdUnyQr3+9aDWZReKq9MhaoVnbL+maVwWJu/N0SEtrtEUNb62QQ==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz", + "integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0" + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/visitor-keys": "5.59.8" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -4550,13 +4576,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.41.0.tgz", - "integrity": "sha512-L30HNvIG6A1Q0R58e4hu4h+fZqaO909UcnnPbwKiN6Rc3BUEx6ez2wgN7aC0cBfcAjZfwkzE+E2PQQ9nEuoqfA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz", + "integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/typescript-estree": "5.59.8", + "@typescript-eslint/utils": "5.59.8", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -4577,9 +4603,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.41.0.tgz", - "integrity": "sha512-5BejraMXMC+2UjefDvrH0Fo/eLwZRV6859SXRg+FgbhA0R0l6lDqDGAQYhKbXhPN2ofk2kY5sgGyLNL907UXpA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz", + "integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -4590,13 +4616,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.41.0.tgz", - "integrity": "sha512-SlzFYRwFSvswzDSQ/zPkIWcHv8O5y42YUskko9c4ki+fV6HATsTODUPbRbcGDFYP86gaJL5xohUEytvyNNcXWg==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz", + "integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/visitor-keys": "5.59.8", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4629,9 +4655,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -4650,18 +4676,18 @@ "dev": true }, "node_modules/@typescript-eslint/utils": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.41.0.tgz", - "integrity": "sha512-QlvfwaN9jaMga9EBazQ+5DDx/4sAdqDkcs05AsQHMaopluVCUyu1bTRUVKzXbgjDlrRAQrYVoi/sXJ9fmG+KLQ==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz", + "integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==", "dev": true, "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/typescript-estree": "5.59.8", "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0", "semver": "^7.3.7" }, "engines": { @@ -4688,9 +4714,9 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -4709,12 +4735,12 @@ "dev": true }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.41.0.tgz", - "integrity": "sha512-vilqeHj267v8uzzakbm13HkPMl7cbYpKVjgFWZPIOHIJHZtinvypUhJ5xBXfWYg4eFKqztbMMpOgFpT9Gfx4fw==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz", + "integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.41.0", + "@typescript-eslint/types": "5.59.8", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -17144,6 +17170,12 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -25939,6 +25971,21 @@ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", "dev": true }, + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + } + }, + "@eslint-community/regexpp": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz", + "integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==", + "dev": true + }, "@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -27620,9 +27667,9 @@ "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" }, "@types/semver": { - "version": "7.3.12", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.12.tgz", - "integrity": "sha512-WwA1MW0++RfXmCr12xeYOOC5baSC9mSb0ZqCquFzKhcoF4TvHu5MKOuXsncgZcpVFhB1pXd5hZmM0ryAoCp12A==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", "dev": true }, "@types/serve-index": { @@ -27703,17 +27750,19 @@ "integrity": "sha512-S9q47ByT2pPvD65IvrWp7qppVMpk9WGMbVq9wbWZOHg6tnXSD4vyhao6nOSBwwfDdV2p3Kx9evA9vI+XWTfDvw==" }, "@typescript-eslint/eslint-plugin": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.41.0.tgz", - "integrity": "sha512-DXUS22Y57/LAFSg3x7Vi6RNAuLpTXwxB9S2nIA7msBb/Zt8p7XqMwdpdc1IU7CkOQUPgAqR5fWvxuKCbneKGmA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz", + "integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/type-utils": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/type-utils": "5.59.8", + "@typescript-eslint/utils": "5.59.8", "debug": "^4.3.4", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", - "regexpp": "^3.2.0", + "natural-compare-lite": "^1.4.0", "semver": "^7.3.7", "tsutils": "^3.21.0" }, @@ -27823,53 +27872,53 @@ } }, "@typescript-eslint/parser": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.41.0.tgz", - "integrity": "sha512-HQVfix4+RL5YRWZboMD1pUfFN8MpRH4laziWkkAzyO1fvNOY/uinZcvo3QiFJVS/siNHupV8E5+xSwQZrl6PZA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz", + "integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/typescript-estree": "5.59.8", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.41.0.tgz", - "integrity": "sha512-xOxPJCnuktUkY2xoEZBKXO5DBCugFzjrVndKdUnyQr3+9aDWZReKq9MhaoVnbL+maVwWJu/N0SEtrtEUNb62QQ==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz", + "integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==", "dev": true, "requires": { - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0" + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/visitor-keys": "5.59.8" } }, "@typescript-eslint/type-utils": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.41.0.tgz", - "integrity": "sha512-L30HNvIG6A1Q0R58e4hu4h+fZqaO909UcnnPbwKiN6Rc3BUEx6ez2wgN7aC0cBfcAjZfwkzE+E2PQQ9nEuoqfA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz", + "integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/typescript-estree": "5.59.8", + "@typescript-eslint/utils": "5.59.8", "debug": "^4.3.4", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.41.0.tgz", - "integrity": "sha512-5BejraMXMC+2UjefDvrH0Fo/eLwZRV6859SXRg+FgbhA0R0l6lDqDGAQYhKbXhPN2ofk2kY5sgGyLNL907UXpA==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz", + "integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.41.0.tgz", - "integrity": "sha512-SlzFYRwFSvswzDSQ/zPkIWcHv8O5y42YUskko9c4ki+fV6HATsTODUPbRbcGDFYP86gaJL5xohUEytvyNNcXWg==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz", + "integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==", "dev": true, "requires": { - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/visitor-keys": "5.59.8", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -27887,9 +27936,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -27904,18 +27953,18 @@ } }, "@typescript-eslint/utils": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.41.0.tgz", - "integrity": "sha512-QlvfwaN9jaMga9EBazQ+5DDx/4sAdqDkcs05AsQHMaopluVCUyu1bTRUVKzXbgjDlrRAQrYVoi/sXJ9fmG+KLQ==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz", + "integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==", "dev": true, "requires": { + "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.59.8", + "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/typescript-estree": "5.59.8", "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0", "semver": "^7.3.7" }, "dependencies": { @@ -27929,9 +27978,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -27946,12 +27995,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "5.41.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.41.0.tgz", - "integrity": "sha512-vilqeHj267v8uzzakbm13HkPMl7cbYpKVjgFWZPIOHIJHZtinvypUhJ5xBXfWYg4eFKqztbMMpOgFpT9Gfx4fw==", + "version": "5.59.8", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz", + "integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==", "dev": true, "requires": { - "@typescript-eslint/types": "5.41.0", + "@typescript-eslint/types": "5.59.8", "eslint-visitor-keys": "^3.3.0" } }, @@ -37170,6 +37219,12 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" }, + "natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", diff --git a/package.json b/package.json index 75b08c9f92..6c822a8d2f 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "@playwright/test": "^1.27.1", "@types/jasmine": "^4.3.0", "@types/lodash.clonedeep": "^4.5.7", - "@typescript-eslint/eslint-plugin": "^5.38.0", - "@typescript-eslint/parser": "^5.38.0", + "@typescript-eslint/eslint-plugin": "^5.59.8", + "@typescript-eslint/parser": "^5.59.8", "babel-loader": "^8.2.5", "babel-plugin-istanbul": "^6.1.1", "css-loader": "^6.7.1", diff --git a/test/helpers/unit.js b/test/helpers/unit.js index e87ebcfada..5142850ca5 100644 --- a/test/helpers/unit.js +++ b/test/helpers/unit.js @@ -9,11 +9,11 @@ const div = document.createElement('div'); div.id = 'test-container'; document.body.appendChild(div); -window.onerror = function(msg) { +window.onerror = function (msg) { return msg === 'Script error.'; }; -beforeEach(function() { +beforeEach(function () { jasmine.addMatchers({ toEqualHTML() { return { compare: compareHTML }; @@ -37,7 +37,7 @@ function compareApproximately(actual, expected, tolerance) { } function compareHTML(actual, expected, ignoreClassId, ignoreUI = true) { - const [div1, div2] = [actual, expected].map(function(html) { + const [div1, div2] = [actual, expected].map(function (html) { if (html instanceof HTMLElement) { html = html.innerHTML; } @@ -79,8 +79,8 @@ function compareNodes(node1, node2, ignoredAttributes = []) { if (node1.tagName !== node2.tagName) { return `Expected tagName '${node1.tagName}' to equal '${node2.tagName}'`; } - const [attr1, attr2] = [node1, node2].map(function(node) { - return Array.from(node.attributes || []).reduce(function(attr, elem) { + const [attr1, attr2] = [node1, node2].map(function (node) { + return Array.from(node.attributes || []).reduce(function (attr, elem) { if (ignoredAttributes.indexOf(elem.name) < 0) { attr[elem.name] = elem.name === 'style' ? elem.value.trim() : elem.value; @@ -94,14 +94,12 @@ function compareNodes(node1, node2, ignoredAttributes = []) { )}`; } if (node1.childNodes.length !== node2.childNodes.length) { - return `Expected node childNodes length '${ - node1.childNodes.length - }' to equal '${node2.childNodes.length}'`; + return `Expected node childNodes length '${node1.childNodes.length}' to equal '${node2.childNodes.length}'`; } if (node1.childNodes.length === 0) return null; let message = ''; if ( - Array.from(node1.childNodes).some(function(child1, i) { + Array.from(node1.childNodes).some(function (child1, i) { message = compareNodes(child1, node2.childNodes[i], ignoredAttributes); return message; }) diff --git a/test/unit/blots/block-embed.js b/test/unit/blots/block-embed.js index b6cc570bc7..8bd7fee7eb 100644 --- a/test/unit/blots/block-embed.js +++ b/test/unit/blots/block-embed.js @@ -1,7 +1,7 @@ import Scroll from '../../../blots/scroll'; -describe('Block Embed', function() { - it('insert', function() { +describe('Block Embed', function () { + it('insert', function () { const scroll = this.initialize(Scroll, '

0123

'); scroll.insertAt(2, 'video', '#'); expect(scroll.domNode).toEqualHTML(` @@ -11,7 +11,7 @@ describe('Block Embed', function() { `); }); - it('split newline', function() { + it('split newline', function () { const scroll = this.initialize(Scroll, '

0123

'); scroll.insertAt(4, 'video', '#'); expect(scroll.domNode).toEqualHTML(` @@ -21,7 +21,7 @@ describe('Block Embed', function() { `); }); - it('insert end of document', function() { + it('insert end of document', function () { const scroll = this.initialize(Scroll, '

0123

'); scroll.insertAt(5, 'video', '#'); expect(scroll.domNode).toEqualHTML(` @@ -30,7 +30,7 @@ describe('Block Embed', function() { `); }); - it('insert text before', function() { + it('insert text before', function () { const scroll = this.initialize( Scroll, '', @@ -42,7 +42,7 @@ describe('Block Embed', function() { `); }); - it('insert text after', function() { + it('insert text after', function () { const scroll = this.initialize( Scroll, '', @@ -54,7 +54,7 @@ describe('Block Embed', function() { `); }); - it('insert inline embed before', function() { + it('insert inline embed before', function () { const scroll = this.initialize( Scroll, '', @@ -66,7 +66,7 @@ describe('Block Embed', function() { `); }); - it('insert inline embed after', function() { + it('insert inline embed after', function () { const scroll = this.initialize( Scroll, '', @@ -78,7 +78,7 @@ describe('Block Embed', function() { `); }); - it('insert block embed before', function() { + it('insert block embed before', function () { const scroll = this.initialize( Scroll, '', @@ -90,7 +90,7 @@ describe('Block Embed', function() { `); }); - it('insert block embed after', function() { + it('insert block embed after', function () { const scroll = this.initialize( Scroll, '', @@ -102,7 +102,7 @@ describe('Block Embed', function() { `); }); - it('insert newline before', function() { + it('insert newline before', function () { const scroll = this.initialize( Scroll, '', @@ -115,7 +115,7 @@ describe('Block Embed', function() { `); }); - it('insert newline after', function() { + it('insert newline after', function () { const scroll = this.initialize( Scroll, '', @@ -128,7 +128,7 @@ describe('Block Embed', function() { `); }); - it('delete preceding newline', function() { + it('delete preceding newline', function () { const scroll = this.initialize( Scroll, '

0123

', diff --git a/test/unit/blots/block.js b/test/unit/blots/block.js index eda24bf6d5..240c1a23b0 100644 --- a/test/unit/blots/block.js +++ b/test/unit/blots/block.js @@ -1,21 +1,21 @@ import Scroll from '../../../blots/scroll'; -describe('Block', function() { - it('childless', function() { +describe('Block', function () { + it('childless', function () { const scroll = this.initialize(Scroll, ''); const block = scroll.create('block'); block.optimize(); expect(block.domNode).toEqualHTML('
'); }); - it('insert into empty', function() { + it('insert into empty', function () { const scroll = this.initialize(Scroll, ''); const block = scroll.create('block'); block.insertAt(0, 'Test'); expect(block.domNode).toEqualHTML('Test'); }); - it('insert newlines', function() { + it('insert newlines', function () { const scroll = this.initialize(Scroll, '


'); scroll.insertAt(0, '\n\n\n'); expect(scroll.domNode).toEqualHTML( @@ -23,7 +23,7 @@ describe('Block', function() { ); }); - it('insert multiline', function() { + it('insert multiline', function () { const scroll = this.initialize(Scroll, '

Hello World!

'); scroll.insertAt(6, 'pardon\nthis\n\ninterruption\n'); expect(scroll.domNode).toEqualHTML(` @@ -35,26 +35,26 @@ describe('Block', function() { `); }); - it('insert into formatted', function() { + it('insert into formatted', function () { const scroll = this.initialize(Scroll, '

Welcome

'); scroll.insertAt(3, 'l\n'); expect(scroll.domNode.firstChild.outerHTML).toEqualHTML('

Well

'); expect(scroll.domNode.childNodes[1].outerHTML).toEqualHTML('

come

'); }); - it('delete line contents', function() { + it('delete line contents', function () { const scroll = this.initialize(Scroll, '

Hello

World!

'); scroll.deleteAt(0, 5); expect(scroll.domNode).toEqualHTML('


World!

'); }); - it('join lines', function() { + it('join lines', function () { const scroll = this.initialize(Scroll, '

Hello

World!

'); scroll.deleteAt(5, 1); expect(scroll.domNode).toEqualHTML('

HelloWorld!

'); }); - it('join line with empty', function() { + it('join line with empty', function () { const scroll = this.initialize( Scroll, '

HelloWorld


', @@ -63,25 +63,25 @@ describe('Block', function() { expect(scroll.domNode).toEqualHTML('

HelloWorld

'); }); - it('join empty lines', function() { + it('join empty lines', function () { const scroll = this.initialize(Scroll, '



'); scroll.deleteAt(1, 1); expect(scroll.domNode).toEqualHTML('


'); }); - it('format empty', function() { + it('format empty', function () { const scroll = this.initialize(Scroll, '


'); scroll.formatAt(0, 1, 'header', 1); expect(scroll.domNode).toEqualHTML('


'); }); - it('format newline', function() { + it('format newline', function () { const scroll = this.initialize(Scroll, '

Hello

'); scroll.formatAt(5, 1, 'header', 2); expect(scroll.domNode).toEqualHTML('

Hello

'); }); - it('remove unnecessary break', function() { + it('remove unnecessary break', function () { const scroll = this.initialize(Scroll, '

Test

'); scroll.children.head.domNode.appendChild(document.createElement('br')); scroll.update(); diff --git a/test/unit/blots/inline.js b/test/unit/blots/inline.js index c7a4746071..1ea2e0ca11 100644 --- a/test/unit/blots/inline.js +++ b/test/unit/blots/inline.js @@ -1,7 +1,7 @@ import Scroll from '../../../blots/scroll'; -describe('Inline', function() { - it('format order', function() { +describe('Inline', function () { + it('format order', function () { const scroll = this.initialize(Scroll, '

Hello World!

'); scroll.formatAt(0, 1, 'bold', true); scroll.formatAt(0, 1, 'italic', true); @@ -12,11 +12,11 @@ describe('Inline', function() { ); }); - it('reorder', function() { + it('reorder', function () { const scroll = this.initialize(Scroll, '

0123

'); const p = scroll.domNode.firstChild; const em = document.createElement('em'); - Array.from(p.childNodes).forEach(function(node) { + Array.from(p.childNodes).forEach(function (node) { em.appendChild(node); }); p.appendChild(em); diff --git a/test/unit/blots/scroll.js b/test/unit/blots/scroll.js index 2da672ce4e..2c9582414e 100644 --- a/test/unit/blots/scroll.js +++ b/test/unit/blots/scroll.js @@ -3,13 +3,13 @@ import Selection, { Range } from '../../../core/selection'; import Cursor from '../../../blots/cursor'; import Scroll from '../../../blots/scroll'; -describe('Scroll', function() { - it('initialize empty document', function() { +describe('Scroll', function () { + it('initialize empty document', function () { const scroll = this.initialize(Scroll, ''); expect(scroll.domNode).toEqualHTML('


'); }); - it('api change', function() { + it('api change', function () { const scroll = this.initialize(Scroll, '

Hello World!

'); spyOn(scroll.emitter, 'emit').and.callThrough(); scroll.insertAt(5, '!'); @@ -20,11 +20,11 @@ describe('Scroll', function() { ); }); - it('user change', function(done) { + it('user change', function (done) { const scroll = this.initialize(Scroll, '

Hello World!

'); spyOn(scroll.emitter, 'emit').and.callThrough(); scroll.domNode.firstChild.appendChild(document.createTextNode('!')); - setTimeout(function() { + setTimeout(function () { expect(scroll.emitter.emit).toHaveBeenCalledWith( Emitter.events.SCROLL_OPTIMIZE, jasmine.any(Array), @@ -39,7 +39,7 @@ describe('Scroll', function() { }, 1); }); - it('prevent dragstart', function() { + it('prevent dragstart', function () { const scroll = this.initialize(Scroll, '

Hello World!

'); const dragstart = new Event('dragstart'); spyOn(dragstart, 'preventDefault'); @@ -47,15 +47,15 @@ describe('Scroll', function() { expect(dragstart.preventDefault).toHaveBeenCalled(); }); - describe('leaf()', function() { - it('text', function() { + describe('leaf()', function () { + it('text', function () { const scroll = this.initialize(Scroll, '

Tests

'); const [leaf, offset] = scroll.leaf(2); expect(leaf.value()).toEqual('Tests'); expect(offset).toEqual(2); }); - it('precise', function() { + it('precise', function () { const scroll = this.initialize( Scroll, '

01234

', @@ -65,14 +65,14 @@ describe('Scroll', function() { expect(offset).toEqual(1); }); - it('newline', function() { + it('newline', function () { const scroll = this.initialize(Scroll, '

0123

5678

'); const [leaf, offset] = scroll.leaf(4); expect(leaf.value()).toEqual('0123'); expect(offset).toEqual(4); }); - it('cursor', function() { + it('cursor', function () { const selection = this.initialize(Selection, '

012

'); selection.setRange(new Range(2)); selection.format('strike', true); @@ -81,7 +81,7 @@ describe('Scroll', function() { expect(offset).toEqual(0); }); - it('beyond document', function() { + it('beyond document', function () { const scroll = this.initialize(Scroll, '

Test

'); const [leaf, offset] = scroll.leaf(10); expect(leaf).toEqual(null); diff --git a/test/unit/core/editor.js b/test/unit/core/editor.js index 377419cd7b..162865c63a 100644 --- a/test/unit/core/editor.js +++ b/test/unit/core/editor.js @@ -2,9 +2,9 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; import Selection, { Range } from '../../../core/selection'; -describe('Editor', function() { - describe('insert', function() { - it('text', function() { +describe('Editor', function () { + describe('insert', function () { + it('text', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(2, '!!'); expect(editor.getDelta()).toEqual( @@ -13,7 +13,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

01!!23

'); }); - it('embed', function() { + it('embed', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertEmbed(2, 'image', '/assets/favicon.png'); expect(editor.getDelta()).toEqual( @@ -28,28 +28,28 @@ describe('Editor', function() { ); }); - it('on empty line', function() { + it('on empty line', function () { const editor = this.initialize(Editor, '

0


3

'); editor.insertText(2, '!'); expect(editor.getDelta()).toEqual(new Delta().insert('0\n!\n3\n')); expect(this.container).toEqualHTML('

0

!

3

'); }); - it('end of document', function() { + it('end of document', function () { const editor = this.initialize(Editor, '

Hello

'); editor.insertText(6, 'World!'); expect(editor.getDelta()).toEqual(new Delta().insert('Hello\nWorld!\n')); expect(this.container).toEqualHTML('

Hello

World!

'); }); - it('end of document with newline', function() { + it('end of document with newline', function () { const editor = this.initialize(Editor, '

Hello

'); editor.insertText(6, 'World!\n'); expect(editor.getDelta()).toEqual(new Delta().insert('Hello\nWorld!\n')); expect(this.container).toEqualHTML('

Hello

World!

'); }); - it('embed at end of document with newline', function() { + it('embed at end of document with newline', function () { const editor = this.initialize(Editor, '

Hello

'); editor.insertEmbed(6, 'image', '/assets/favicon.png'); expect(editor.getDelta()).toEqual( @@ -63,7 +63,7 @@ describe('Editor', function() { ); }); - it('newline splitting', function() { + it('newline splitting', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(2, '\n'); expect(editor.getDelta()).toEqual( @@ -78,21 +78,18 @@ describe('Editor', function() {

23

`); }); - it('prepend newline', function() { + it('prepend newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(0, '\n'); expect(editor.getDelta()).toEqual( - new Delta() - .insert('\n') - .insert('0123', { bold: true }) - .insert('\n'), + new Delta().insert('\n').insert('0123', { bold: true }).insert('\n'), ); expect(this.container).toEqualHTML(`


0123

`); }); - it('append newline', function() { + it('append newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(4, '\n'); expect(editor.getDelta()).toEqual( @@ -103,7 +100,7 @@ describe('Editor', function() {


`); }); - it('multiline text', function() { + it('multiline text', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(2, '\n!!\n!!\n'); expect(editor.getDelta()).toEqual( @@ -124,7 +121,7 @@ describe('Editor', function() {

23

`); }); - it('multiple newlines', function() { + it('multiple newlines', function () { const editor = this.initialize(Editor, '

0123

'); editor.insertText(2, '\n\n'); expect(editor.getDelta()).toEqual( @@ -140,7 +137,7 @@ describe('Editor', function() {

23

`); }); - it('text removing formatting', function() { + it('text removing formatting', function () { const editor = this.initialize(Editor, '

01

'); editor.insertText(2, '23', { bold: false, strike: false }); expect(editor.getDelta()).toEqual( @@ -149,8 +146,8 @@ describe('Editor', function() { }); }); - describe('delete', function() { - it('inner node', function() { + describe('delete', function () { + it('inner node', function () { const editor = this.initialize( Editor, '

0123

', @@ -162,7 +159,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

03

'); }); - it('parts of multiple lines', function() { + it('parts of multiple lines', function () { const editor = this.initialize( Editor, '

0123

5678

', @@ -174,7 +171,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

0178

'); }); - it('entire line keeping newline', function() { + it('entire line keeping newline', function () { const editor = this.initialize( Editor, '

0123

', @@ -184,7 +181,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('


'); }); - it('newline', function() { + it('newline', function () { const editor = this.initialize( Editor, '

0123

5678

', @@ -196,7 +193,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

01235678

'); }); - it('entire document', function() { + it('entire document', function () { const editor = this.initialize( Editor, '

0123

', @@ -206,7 +203,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('


'); }); - it('multiple complete lines', function() { + it('multiple complete lines', function () { const editor = this.initialize( Editor, '

012

456

890

', @@ -219,22 +216,22 @@ describe('Editor', function() { }); }); - describe('format', function() { - it('line', function() { + describe('format', function () { + it('line', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatLine(1, 1, { header: 1 }); expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); }); - describe('removeFormat', function() { - it('unwrap', function() { + describe('removeFormat', function () { + it('unwrap', function () { const editor = this.initialize(Editor, '

0123

'); editor.removeFormat(1, 2); expect(this.container).toEqualHTML('

0123

'); }); - it('split inline', function() { + it('split inline', function () { const editor = this.initialize( Editor, '

0123

', @@ -245,7 +242,7 @@ describe('Editor', function() { ); }); - it('partial line', function() { + it('partial line', function () { const editor = this.initialize( Editor, '

01

  1. 34
', @@ -254,7 +251,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

01

34

'); }); - it('remove embed', function() { + it('remove embed', function () { const editor = this.initialize( Editor, '

02

', @@ -263,7 +260,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

02

'); }); - it('combined', function() { + it('combined', function () { const editor = this.initialize( Editor, ` @@ -280,7 +277,7 @@ describe('Editor', function() { `); }); - it('end of document', function() { + it('end of document', function () { const editor = this.initialize( Editor, ` @@ -298,26 +295,26 @@ describe('Editor', function() { }); }); - describe('applyDelta', function() { - it('insert', function() { + describe('applyDelta', function () { + it('insert', function () { const editor = this.initialize(Editor, '

'); editor.applyDelta(new Delta().insert('01')); expect(this.container).toEqualHTML('

01

'); }); - it('attributed insert', function() { + it('attributed insert', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().retain(2).insert('|', { bold: true })); expect(this.container).toEqualHTML('

01|23

'); }); - it('format', function() { + it('format', function () { const editor = this.initialize(Editor, '

01

'); editor.applyDelta(new Delta().retain(2, { bold: true })); expect(this.container).toEqualHTML('

01

'); }); - it('discontinuous formats', function() { + it('discontinuous formats', function () { const editor = this.initialize(Editor, ''); const delta = new Delta() .insert('ab', { bold: true }) @@ -329,25 +326,25 @@ describe('Editor', function() { ); }); - it('unformatted insert', function() { + it('unformatted insert', function () { const editor = this.initialize(Editor, '

01

'); editor.applyDelta(new Delta().retain(1).insert('|')); expect(this.container).toEqualHTML('

0|1

'); }); - it('insert at format boundary', function() { + it('insert at format boundary', function () { const editor = this.initialize(Editor, '

01

'); editor.applyDelta(new Delta().retain(1).insert('|', { strike: true })); expect(this.container).toEqualHTML('

0|1

'); }); - it('unformatted newline', function() { + it('unformatted newline', function () { const editor = this.initialize(Editor, '

01

'); editor.applyDelta(new Delta().retain(2).insert('\n')); expect(this.container).toEqualHTML('

01


'); }); - it('formatted embed', function() { + it('formatted embed', function () { const editor = this.initialize(Editor, ''); editor.applyDelta( new Delta().insert({ image: '/assets/favicon.png' }, { italic: true }), @@ -357,7 +354,7 @@ describe('Editor', function() { ); }); - it('insert text before block embed', function() { + it('insert text before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -368,7 +365,7 @@ describe('Editor', function() { ); }); - it('insert attributed text before block embed', function() { + it('insert attributed text before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -379,7 +376,7 @@ describe('Editor', function() { ); }); - it('insert text with newline before block embed', function() { + it('insert text with newline before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -390,23 +387,20 @@ describe('Editor', function() { ); }); - it('insert attributed text with newline before block embed', function() { + it('insert attributed text with newline before block embed', function () { const editor = this.initialize( Editor, '

0123

', ); editor.applyDelta( - new Delta() - .retain(5) - .insert('5678', { bold: true }) - .insert('\n'), + new Delta().retain(5).insert('5678', { bold: true }).insert('\n'), ); expect(this.container).toEqualHTML( '

0123

5678

', ); }); - it('multiple inserts and deletes', function() { + it('multiple inserts and deletes', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta( new Delta() @@ -420,7 +414,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

0acdefg

'); }); - it('insert text with delete in existing block', function() { + it('insert text with delete in existing block', function () { const editor = this.initialize( Editor, '

0123

', @@ -436,7 +430,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

0123abc

'); }); - it('insert text with delete before block embed', function() { + it('insert text with delete before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -451,7 +445,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

0123

abc

'); }); - it('insert inline embed with delete in existing block', function() { + it('insert inline embed with delete in existing block', function () { const editor = this.initialize( Editor, '

0123

', @@ -469,7 +463,7 @@ describe('Editor', function() { ); }); - it('insert inline embed with delete before block embed', function() { + it('insert inline embed with delete before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -487,7 +481,7 @@ describe('Editor', function() { ); }); - it('insert inline embed with delete before block embed using delete op first', function() { + it('insert inline embed with delete before block embed using delete op first', function () { const editor = this.initialize( Editor, '

0123

', @@ -505,7 +499,7 @@ describe('Editor', function() { ); }); - it('insert inline embed and text with delete before block embed', function() { + it('insert inline embed and text with delete before block embed', function () { const editor = this.initialize( Editor, '

0123

', @@ -523,53 +517,40 @@ describe('Editor', function() { ); }); - it('insert block embed with delete before block embed', function() { + it('insert block embed with delete before block embed', function () { const editor = this.initialize( Editor, '

0123

', ); editor.applyDelta( - new Delta() - .retain(5) - .insert({ video: '#changed' }) - .delete(1), + new Delta().retain(5).insert({ video: '#changed' }).delete(1), ); expect(this.container).toEqualHTML( '

0123

', ); }); - it('deletes block embed and appends text', function() { + it('deletes block embed and appends text', function () { const editor = this.initialize( Editor, `


b

`, ); - editor.applyDelta( - new Delta() - .retain(1) - .insert('a') - .delete(1), - ); + editor.applyDelta(new Delta().retain(1).insert('a').delete(1)); expect(this.container).toEqualHTML('


ab

'); }); - it('multiple delete block embed and append texts', function() { + it('multiple delete block embed and append texts', function () { const editor = this.initialize( Editor, `


b

`, ); editor.applyDelta( - new Delta() - .retain(1) - .insert('a') - .delete(1) - .insert('!') - .delete(1), + new Delta().retain(1).insert('a').delete(1).insert('!').delete(1), ); expect(this.container).toEqualHTML('


a!b

'); }); - it('multiple nonconsecutive delete block embed and append texts', function() { + it('multiple nonconsecutive delete block embed and append texts', function () { const editor = this.initialize( Editor, `


@@ -603,8 +584,8 @@ describe('Editor', function() { ); }); - describe('block embed', function() { - it('improper block embed insert', function() { + describe('block embed', function () { + it('improper block embed insert', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().retain(2).insert({ video: '#' })); expect(this.container).toEqualHTML( @@ -612,8 +593,8 @@ describe('Editor', function() { ); }); - describe('insert and delete', function() { - it('prepend', function() { + describe('insert and delete', function () { + it('prepend', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().insert({ video: '#' }).delete(2)); expect(this.container).toEqualHTML( @@ -621,53 +602,46 @@ describe('Editor', function() { ); }); - - it('insert to the middle of text', function() { + it('insert to the middle of text', function () { const editor = this.initialize(Editor, `

abc

`); editor.applyDelta( - new Delta() - .retain(1) - .insert({ video: '#' }) - .delete(2), + new Delta().retain(1).insert({ video: '#' }).delete(2), ); expect(this.container).toEqualHTML( '

a


', ); }); - it('insert after \\n', function() { + it('insert after \\n', function () { const editor = this.initialize(Editor, `

a

cda

`); editor.applyDelta( - new Delta() - .retain(2) - .insert({ video: '#' }) - .delete(2), + new Delta().retain(2).insert({ video: '#' }).delete(2), ); expect(this.container).toEqualHTML( '

a

a

', ); }); - it('insert after an inline embed', function() { - const editor = this.initialize(Editor, `

abc

`); + it('insert after an inline embed', function () { + const editor = this.initialize( + Editor, + `

abc

`, + ); editor.applyDelta( - new Delta() - .retain(1) - .insert({ video: '#' }) - .delete(2), + new Delta().retain(1).insert({ video: '#' }).delete(2), ); expect(this.container).toEqualHTML( '

bc

', ); }); - it('insert after a block embed', function() { - const editor = this.initialize(Editor, `

abc

`); + it('insert after a block embed', function () { + const editor = this.initialize( + Editor, + `

abc

`, + ); editor.applyDelta( - new Delta() - .retain(1) - .insert({ video: '#' }) - .delete(2), + new Delta().retain(1).insert({ video: '#' }).delete(2), ); expect(this.container).toEqualHTML( '

c

', @@ -675,7 +649,7 @@ describe('Editor', function() { }); }); - it('append formatted block embed', function() { + it('append formatted block embed', function () { const editor = this.initialize(Editor, '

0123


'); editor.applyDelta( new Delta().retain(5).insert({ video: '#' }, { align: 'right' }), @@ -686,36 +660,33 @@ describe('Editor', function() { }); }); - it('append', function() { + it('append', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().retain(5).insert('5678')); expect(this.container).toEqualHTML('

0123

5678

'); }); - it('append newline', function() { + it('append newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().retain(5).insert('\n', { header: 2 })); expect(this.container).toEqualHTML('

0123


'); }); - it('append text with newline', function() { + it('append text with newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta( - new Delta() - .retain(5) - .insert('5678') - .insert('\n', { header: 2 }), + new Delta().retain(5).insert('5678').insert('\n', { header: 2 }), ); expect(this.container).toEqualHTML('

0123

5678

'); }); - it('append non-isolated newline', function() { + it('append non-isolated newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta(new Delta().retain(5).insert('5678\n', { header: 2 })); expect(this.container).toEqualHTML('

0123

5678

'); }); - it('eventual append', function() { + it('eventual append', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta( new Delta() @@ -727,7 +698,7 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

01ab

23

cd

'); }); - it('append text, embed and newline', function() { + it('append text, embed and newline', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta( new Delta() @@ -741,7 +712,7 @@ describe('Editor', function() { ); }); - it('append multiple lines', function() { + it('append multiple lines', function () { const editor = this.initialize(Editor, '

0123

'); editor.applyDelta( new Delta() @@ -754,33 +725,27 @@ describe('Editor', function() { expect(this.container).toEqualHTML('

0123

56

89

'); }); - it('code block', function() { + it('code block', function () { const editor = this.initialize(Editor, { - html: - '

0

1
23


', + html: '

0

1
23


', }); - editor.applyDelta( - new Delta() - .delete(4) - .retain(1) - .delete(2), - ); + editor.applyDelta(new Delta().delete(4).retain(1).delete(2)); expect(editor.scroll.domNode.innerHTML).toEqual('

2

'); }); }); - describe('getFormat()', function() { - it('unformatted', function() { + describe('getFormat()', function () { + it('unformatted', function () { const editor = this.initialize(Editor, '

0123

'); expect(editor.getFormat(1)).toEqual({}); }); - it('formatted', function() { + it('formatted', function () { const editor = this.initialize(Editor, '

0123

'); expect(editor.getFormat(1)).toEqual({ header: 1, italic: true }); }); - it('cursor', function() { + it('cursor', function () { const editor = this.initialize( Editor, '

0123

5678

', @@ -792,7 +757,7 @@ describe('Editor', function() { }); }); - it('cursor with preformat', function() { + it('cursor with preformat', function () { const [editor, selection] = this.initialize( [Editor, Selection], '

0123

', @@ -809,7 +774,7 @@ describe('Editor', function() { }); }); - it('across leaves', function() { + it('across leaves', function () { const editor = this.initialize( Editor, ` @@ -827,7 +792,7 @@ describe('Editor', function() { }); }); - it('across leaves repeated', function() { + it('across leaves repeated', function () { const editor = this.initialize( Editor, ` @@ -846,7 +811,7 @@ describe('Editor', function() { }); }); - it('across lines repeated', function() { + it('across lines repeated', function () { const editor = this.initialize( Editor, ` @@ -862,7 +827,7 @@ describe('Editor', function() { align: ['right', 'center'], }); }); - it('across lines', function() { + it('across lines', function () { const editor = this.initialize( Editor, ` @@ -878,13 +843,13 @@ describe('Editor', function() { }); }); - describe('getHTML', function() { - it('inline', function() { + describe('getHTML', function () { + it('inline', function () { const editor = this.initialize(Editor, '
Test
'); expect(editor.getHTML(1, 2)).toEqual('es'); }); - it('across lines', function() { + it('across lines', function () { const editor = this.initialize( Editor, '

Header

Text

Quote
', @@ -894,7 +859,7 @@ describe('Editor', function() { ); }); - it('mixed list', function() { + it('mixed list', function () { const editor = this.initialize( Editor, ` @@ -918,7 +883,7 @@ describe('Editor', function() { `); }); - it('nested list', function() { + it('nested list', function () { const editor = this.initialize( Editor, ` @@ -950,7 +915,7 @@ describe('Editor', function() { `); }); - it('nested checklist', function() { + it('nested checklist', function () { const editor = this.initialize( Editor, ` @@ -982,7 +947,7 @@ describe('Editor', function() { `); }); - it('partial list', function() { + it('partial list', function () { const editor = this.initialize( Editor, ` @@ -1012,18 +977,18 @@ describe('Editor', function() { `); }); - it('text within tag', function() { + it('text within tag', function () { const editor = this.initialize(Editor, '

a

'); expect(editor.getHTML(0, 1)).toEqual('a'); }); - it('escape html', function() { + it('escape html', function () { const editor = this.initialize(Editor, '


'); editor.insertText(0, 'Test'); expect(editor.getHTML(0, 11)).toEqual('<b>Test</b>'); }); - it('multiline code', function() { + it('multiline code', function () { const editor = this.initialize( Editor, '


0123



4567


', diff --git a/test/unit/core/quill.js b/test/unit/core/quill.js index e18d69c609..803ad21219 100644 --- a/test/unit/core/quill.js +++ b/test/unit/core/quill.js @@ -6,33 +6,33 @@ import Toolbar from '../../../modules/toolbar'; import Snow from '../../../themes/snow'; import { Range } from '../../../core/selection'; -describe('Quill', function() { - it('imports', function() { - Object.keys(Quill.imports).forEach(function(path) { +describe('Quill', function () { + it('imports', function () { + Object.keys(Quill.imports).forEach(function (path) { expect(Quill.import(path)).toBeTruthy(); }); }); - describe('construction', function() { - it('empty', function() { + describe('construction', function () { + it('empty', function () { const quill = this.initialize(Quill, ''); expect(quill.getContents()).toEqual(new Delta().insert('\n')); expect(quill.root).toEqualHTML('


'); }); - it('text', function() { + it('text', function () { const quill = this.initialize(Quill, '0123'); expect(quill.getContents()).toEqual(new Delta().insert('0123\n')); expect(quill.root).toEqualHTML('

0123

'); }); - it('newlines', function() { + it('newlines', function () { const quill = this.initialize(Quill, '




'); expect(quill.getContents()).toEqual(new Delta().insert('\n\n\n')); expect(quill.root).toEqualHTML('




'); }); - it('formatted ending', function() { + it('formatted ending', function () { const quill = this.initialize( Quill, '

Test

', @@ -44,14 +44,14 @@ describe('Quill', function() { }); }); - describe('api', function() { - beforeEach(function() { + describe('api', function () { + beforeEach(function () { this.quill = this.initialize(Quill, '

01234567

'); this.oldDelta = this.quill.getContents(); spyOn(this.quill.emitter, 'emit').and.callThrough(); }); - it('deleteText()', function() { + it('deleteText()', function () { this.quill.deleteText(3, 2); const change = new Delta().retain(3).delete(2); expect(this.quill.root).toEqualHTML('

012567

'); @@ -63,7 +63,7 @@ describe('Quill', function() { ); }); - it('format()', function() { + it('format()', function () { this.quill.setSelection(3, 2); this.quill.format('bold', true); const change = new Delta().retain(3).retain(2, { bold: true }); @@ -79,7 +79,7 @@ describe('Quill', function() { expect(this.quill.getSelection()).toEqual(new Range(3, 2)); }); - it('formatLine()', function() { + it('formatLine()', function () { this.quill.formatLine(1, 1, 'header', 2); const change = new Delta().retain(8).retain(1, { header: 2 }); expect(this.quill.root).toEqualHTML('

01234567

'); @@ -91,7 +91,7 @@ describe('Quill', function() { ); }); - it('formatText()', function() { + it('formatText()', function () { this.quill.formatText(3, 2, 'bold', true); const change = new Delta().retain(3).retain(2, { bold: true }); expect(this.quill.root).toEqualHTML( @@ -105,7 +105,7 @@ describe('Quill', function() { ); }); - it('insertEmbed()', function() { + it('insertEmbed()', function () { this.quill.insertEmbed(5, 'image', '/assets/favicon.png'); const change = new Delta() .retain(5) @@ -121,7 +121,7 @@ describe('Quill', function() { ); }); - it('insertText()', function() { + it('insertText()', function () { this.quill.insertText(5, '|', 'bold', true); const change = new Delta() .retain(5) @@ -137,34 +137,34 @@ describe('Quill', function() { ); }); - it('enable/disable', function() { + it('enable/disable', function () { this.quill.disable(); expect(this.quill.root.getAttribute('contenteditable')).toEqual('false'); this.quill.enable(); expect(this.quill.root.getAttribute('contenteditable')).toBeTruthy(); }); - it('getBounds() index', function() { + it('getBounds() index', function () { expect(this.quill.getBounds(1)).toBeTruthy(); }); - it('getBounds() range', function() { + it('getBounds() range', function () { expect(this.quill.getBounds(new Range(3, 4))).toBeTruthy(); }); - it('getFormat()', function() { + it('getFormat()', function () { const formats = this.quill.getFormat(5); expect(formats).toEqual({ italic: true }); }); - it('getSelection()', function() { + it('getSelection()', function () { expect(this.quill.getSelection()).toEqual(null); const range = new Range(1, 2); this.quill.setSelection(range); expect(this.quill.getSelection()).toEqual(range); }); - it('removeFormat()', function() { + it('removeFormat()', function () { this.quill.removeFormat(5, 1); const change = new Delta().retain(5).retain(1, { italic: null }); expect(this.quill.root).toEqualHTML('

01234567

'); @@ -176,7 +176,7 @@ describe('Quill', function() { ); }); - it('updateContents() delta', function() { + it('updateContents() delta', function () { const delta = new Delta().retain(5).insert('|'); this.quill.updateContents(delta); expect(this.quill.root).toEqualHTML('

01234|567

'); @@ -188,7 +188,7 @@ describe('Quill', function() { ); }); - it('updateContents() ops array', function() { + it('updateContents() ops array', function () { const delta = new Delta().retain(5).insert('|'); this.quill.updateContents(delta.ops); expect(this.quill.root).toEqualHTML('

01234|567

'); @@ -201,15 +201,15 @@ describe('Quill', function() { }); }); - describe('events', function() { - beforeEach(function() { + describe('events', function () { + beforeEach(function () { this.quill = this.initialize(Quill, '

0123

'); this.quill.update(); spyOn(this.quill.emitter, 'emit').and.callThrough(); this.oldDelta = this.quill.getContents(); }); - it('api text insert', function() { + it('api text insert', function () { this.quill.insertText(2, '!'); const delta = new Delta().retain(2).insert('!'); expect(this.quill.emitter.emit).toHaveBeenCalledWith( @@ -220,7 +220,7 @@ describe('Quill', function() { ); }); - it('user text insert', function(done) { + it('user text insert', function (done) { this.container.firstChild.firstChild.firstChild.data = '01!23'; const delta = new Delta().retain(2).insert('!'); setTimeout(() => { @@ -241,7 +241,7 @@ describe('Quill', function() { newSelection, expectedDelta, ) { - return function(done) { + return function (done) { this.quill.setText(`${oldText}\n`); this.quill.setSelection(oldSelection); // number or Range this.quill.update(); @@ -277,7 +277,7 @@ describe('Quill', function() { }; } - describe('insert a in aaaa', function() { + describe('insert a in aaaa', function () { it( 'at index 0', editTest('aaaa', 0, 'aaaaa', 1, new Delta().insert('a')), @@ -296,7 +296,7 @@ describe('Quill', function() { ); }); - describe('insert a in xaa', function() { + describe('insert a in xaa', function () { it( 'at index 1', editTest('xaa', 1, 'xaaa', 2, new Delta().retain(1).insert('a')), @@ -311,7 +311,7 @@ describe('Quill', function() { ); }); - describe('insert aa in ax', function() { + describe('insert aa in ax', function () { it('at index 0', editTest('ax', 0, 'aaax', 2, new Delta().insert('aa'))); it( 'at index 1', @@ -319,7 +319,7 @@ describe('Quill', function() { ); }); - describe('delete a in xaa', function() { + describe('delete a in xaa', function () { it( 'at index 1', editTest('xaa', 2, 'xa', 1, new Delta().retain(1).delete(1)), @@ -330,7 +330,7 @@ describe('Quill', function() { ); }); - describe('forward-delete a in xaa', function() { + describe('forward-delete a in xaa', function () { it( 'at index 1', editTest('xaa', 1, 'xa', 1, new Delta().retain(1).delete(1)), @@ -353,8 +353,8 @@ describe('Quill', function() { ); }); - describe('setContents()', function() { - it('empty', function() { + describe('setContents()', function () { + it('empty', function () { const quill = this.initialize(Quill, ''); const delta = new Delta().insert('\n'); quill.setContents(delta); @@ -362,7 +362,7 @@ describe('Quill', function() { expect(quill.root).toEqualHTML('


'); }); - it('single line', function() { + it('single line', function () { const quill = this.initialize(Quill, ''); const delta = new Delta().insert('Hello World!\n'); quill.setContents(delta); @@ -370,7 +370,7 @@ describe('Quill', function() { expect(quill.root).toEqualHTML('

Hello World!

'); }); - it('multiple lines', function() { + it('multiple lines', function () { const quill = this.initialize(Quill, ''); const delta = new Delta().insert('Hello\n\nWorld!\n'); quill.setContents(delta); @@ -378,7 +378,7 @@ describe('Quill', function() { expect(quill.root).toEqualHTML('

Hello


World!

'); }); - it('basic formats', function() { + it('basic formats', function () { const quill = this.initialize(Quill, ''); const delta = new Delta() .insert('Welcome') @@ -396,7 +396,7 @@ describe('Quill', function() { `); }); - it('array of operations', function() { + it('array of operations', function () { const quill = this.initialize(Quill, ''); const delta = new Delta() .insert('test') @@ -406,20 +406,20 @@ describe('Quill', function() { expect(quill.getContents()).toEqual(delta); }); - it('json', function() { + it('json', function () { const quill = this.initialize(Quill, ''); const delta = { ops: [{ insert: 'test\n' }] }; quill.setContents(delta); expect(quill.getContents()).toEqual(new Delta(delta)); }); - it('no trailing newline', function() { + it('no trailing newline', function () { const quill = this.initialize(Quill, '

Welcome

'); quill.setContents(new Delta().insert('0123')); expect(quill.getContents()).toEqual(new Delta().insert('0123\n')); }); - it('inline formatting', function() { + it('inline formatting', function () { const quill = this.initialize( Quill, '

Bold

Not bold

', @@ -430,7 +430,7 @@ describe('Quill', function() { expect(delta).toEqual(contents.delete(contents.length())); }); - it('block embed', function() { + it('block embed', function () { const quill = this.initialize(Quill, '

Hello World!

'); const contents = new Delta().insert({ video: '#' }); quill.setContents(contents); @@ -438,63 +438,63 @@ describe('Quill', function() { }); }); - describe('getText()', function() { - it('return all text by default', function() { + describe('getText()', function () { + it('return all text by default', function () { const quill = this.initialize(Quill, '

Welcome

'); expect(quill.getText()).toEqualHTML('Welcome'); }); - it('works when only provide index', function() { + it('works when only provide index', function () { const quill = this.initialize(Quill, '

Welcome

'); expect(quill.getText(2)).toEqualHTML('lcome'); }); - it('works with range', function() { + it('works with range', function () { const quill = this.initialize(Quill, '

Welcome

'); expect(quill.getText({ index: 1, length: 2 })).toEqualHTML('el'); }); }); - describe('setText()', function() { - it('overwrite', function() { + describe('setText()', function () { + it('overwrite', function () { const quill = this.initialize(Quill, '

Welcome

'); quill.setText('abc'); expect(quill.root).toEqualHTML('

abc

'); }); - it('set to newline', function() { + it('set to newline', function () { const quill = this.initialize(Quill, '

Welcome

'); quill.setText('\n'); expect(quill.root).toEqualHTML('


'); }); - it('multiple newlines', function() { + it('multiple newlines', function () { const quill = this.initialize(Quill, '

Welcome

'); quill.setText('\n\n'); expect(quill.root).toEqualHTML('



'); }); - it('content with trailing newline', function() { + it('content with trailing newline', function () { const quill = this.initialize(Quill, '

Welcome

'); quill.setText('abc\n'); expect(quill.root).toEqualHTML('

abc

'); }); - it('return carriage', function() { + it('return carriage', function () { const quill = this.initialize(Quill, '

Test

'); quill.setText('\r'); expect(quill.root).toEqualHTML('


'); }); - it('return carriage newline', function() { + it('return carriage newline', function () { const quill = this.initialize(Quill, '

Test

'); quill.setText('\r\n'); expect(quill.root).toEqualHTML('


'); }); }); - describe('expandConfig', function() { - it('user overwrite quill', function() { + describe('expandConfig', function () { + it('user overwrite quill', function () { const config = expandConfig('#test-container', { placeholder: 'Test', readOnly: true, @@ -503,7 +503,7 @@ describe('Quill', function() { expect(config.readOnly).toEqual(true); }); - it('convert css selectors', function() { + it('convert css selectors', function () { const config = expandConfig('#test-container', { bounds: '#test-container', }); @@ -513,7 +513,7 @@ describe('Quill', function() { ); }); - xit('convert module true to {}', function() { + xit('convert module true to {}', function () { Quill.debug(0); const oldModules = Theme.DEFAULTS.modules; Theme.DEFAULTS.modules = { @@ -533,8 +533,8 @@ describe('Quill', function() { Theme.DEFAULTS.modules = oldModules; }); - describe('theme defaults', function() { - it('for Snow', function() { + describe('theme defaults', function () { + it('for Snow', function () { const config = expandConfig('#test-container', { modules: { toolbar: true, @@ -547,21 +547,21 @@ describe('Quill', function() { ); }); - it('for false', function() { + it('for false', function () { const config = expandConfig('#test-container', { theme: false, }); expect(config.theme).toEqual(Theme); }); - it('for undefined', function() { + it('for undefined', function () { const config = expandConfig('#test-container', { theme: undefined, }); expect(config.theme).toEqual(Theme); }); - it('for null', function() { + it('for null', function () { const config = expandConfig('#test-container', { theme: null, }); @@ -569,7 +569,7 @@ describe('Quill', function() { }); }); - it('quill < module < theme < user', function() { + it('quill < module < theme < user', function () { const oldTheme = Theme.DEFAULTS.modules; const oldToolbar = Toolbar.DEFAULTS; Toolbar.DEFAULTS = { @@ -600,7 +600,7 @@ describe('Quill', function() { Toolbar.DEFAULTS = oldToolbar; }); - it('toolbar default', function() { + it('toolbar default', function () { const config = expandConfig('#test-container', { modules: { toolbar: true, @@ -609,7 +609,7 @@ describe('Quill', function() { expect(config.modules.toolbar).toEqual(Toolbar.DEFAULTS); }); - it('toolbar disabled', function() { + it('toolbar disabled', function () { const config = expandConfig('#test-container', { modules: { toolbar: false, @@ -619,7 +619,7 @@ describe('Quill', function() { expect(config.modules.toolbar).toBe(undefined); }); - it('toolbar selector', function() { + it('toolbar selector', function () { const config = expandConfig('#test-container', { modules: { toolbar: { @@ -633,7 +633,7 @@ describe('Quill', function() { }); }); - it('toolbar container shorthand', function() { + it('toolbar container shorthand', function () { const config = expandConfig('#test-container', { modules: { toolbar: document.querySelector('#test-container'), @@ -645,7 +645,7 @@ describe('Quill', function() { }); }); - it('toolbar format array', function() { + it('toolbar format array', function () { const config = expandConfig('#test-container', { modules: { toolbar: ['bold'], @@ -657,8 +657,8 @@ describe('Quill', function() { }); }); - it('toolbar custom handler, default container', function() { - const handler = function() {}; // eslint-disable-line func-style + it('toolbar custom handler, default container', function () { + const handler = function () {}; // eslint-disable-line func-style const config = expandConfig('#test-container', { modules: { toolbar: { @@ -676,8 +676,8 @@ describe('Quill', function() { }); }); - describe('overload', function() { - it('(index:number, length:number)', function() { + describe('overload', function () { + it('(index:number, length:number)', function () { const [index, length, formats, source] = overload(0, 1); expect(index).toBe(0); expect(length).toBe(1); @@ -685,7 +685,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(index:number, length:number, format:string, value:boolean, source:string)', function() { + it('(index:number, length:number, format:string, value:boolean, source:string)', function () { const [index, length, formats, source] = overload( 0, 1, @@ -699,7 +699,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(index:number, length:number, format:string, value:string, source:string)', function() { + it('(index:number, length:number, format:string, value:string, source:string)', function () { const [index, length, formats, source] = overload( 0, 1, @@ -713,7 +713,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(index:number, length:number, format:string, value:string)', function() { + it('(index:number, length:number, format:string, value:string)', function () { const [index, length, formats, source] = overload( 0, 1, @@ -726,7 +726,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(index:number, length:number, format:object)', function() { + it('(index:number, length:number, format:object)', function () { const [index, length, formats, source] = overload(0, 1, { bold: true }); expect(index).toBe(0); expect(length).toBe(1); @@ -734,7 +734,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(index:number, length:number, format:object, source:string)', function() { + it('(index:number, length:number, format:object, source:string)', function () { const [index, length, formats, source] = overload( 0, 1, @@ -747,7 +747,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(index:number, length:number, source:string)', function() { + it('(index:number, length:number, source:string)', function () { const [index, length, formats, source] = overload( 0, 1, @@ -759,7 +759,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(index:number, source:string)', function() { + it('(index:number, source:string)', function () { const [index, length, formats, source] = overload(0, Quill.sources.USER); expect(index).toBe(0); expect(length).toBe(0); @@ -767,7 +767,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(range:range)', function() { + it('(range:range)', function () { const [index, length, formats, source] = overload(new Range(0, 1)); expect(index).toBe(0); expect(length).toBe(1); @@ -775,7 +775,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, format:string, value:boolean, source:string)', function() { + it('(range:range, format:string, value:boolean, source:string)', function () { const [index, length, formats, source] = overload( new Range(0, 1), 'bold', @@ -788,7 +788,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(range:range, format:string, value:string, source:string)', function() { + it('(range:range, format:string, value:string, source:string)', function () { const [index, length, formats, source] = overload( new Range(0, 1), 'color', @@ -801,7 +801,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(range:range, format:string, value:string)', function() { + it('(range:range, format:string, value:string)', function () { const [index, length, formats, source] = overload( new Range(0, 1), 'color', @@ -813,7 +813,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, format:object)', function() { + it('(range:range, format:object)', function () { const [index, length, formats, source] = overload(new Range(0, 1), { bold: true, }); @@ -823,7 +823,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, format:object, source:string)', function() { + it('(range:range, format:object, source:string)', function () { const [index, length, formats, source] = overload( new Range(0, 1), { bold: true }, @@ -835,7 +835,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(range:range, source:string)', function() { + it('(range:range, source:string)', function () { const [index, length, formats, source] = overload( new Range(0, 1), Quill.sources.USER, @@ -846,7 +846,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.USER); }); - it('(range:range)', function() { + it('(range:range)', function () { const [index, length, formats, source] = overload(new Range(0, 1)); expect(index).toBe(0); expect(length).toBe(1); @@ -854,7 +854,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, dummy:number)', function() { + it('(range:range, dummy:number)', function () { const [index, length, formats, source] = overload(new Range(10, 1), 0); expect(index).toBe(10); expect(length).toBe(1); @@ -862,7 +862,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, dummy:number, format:string, value:boolean)', function() { + it('(range:range, dummy:number, format:string, value:boolean)', function () { const [index, length, formats, source] = overload( new Range(10, 1), 0, @@ -875,7 +875,7 @@ describe('Quill', function() { expect(source).toBe(Quill.sources.API); }); - it('(range:range, dummy:number, format:object, source:string)', function() { + it('(range:range, dummy:number, format:object, source:string)', function () { const [index, length, formats, source] = overload( new Range(10, 1), 0, @@ -889,8 +889,8 @@ describe('Quill', function() { }); }); - describe('placeholder', function() { - beforeEach(function() { + describe('placeholder', function () { + beforeEach(function () { this.initialize(HTMLElement, '

'); this.quill = new Quill(this.container.firstChild, { placeholder: 'a great day to be a placeholder', @@ -898,19 +898,19 @@ describe('Quill', function() { this.original = this.quill.getContents(); }); - it('blank editor', function() { + it('blank editor', function () { expect(this.quill.root.dataset.placeholder).toEqual( 'a great day to be a placeholder', ); expect(this.quill.root.classList).toContain('ql-blank'); }); - it('with text', function() { + it('with text', function () { this.quill.setText('test'); expect(this.quill.root.classList).not.toContain('ql-blank'); }); - it('formatted line', function() { + it('formatted line', function () { this.quill.formatLine(0, 1, 'list', 'ordered'); expect(this.quill.root.classList).not.toContain('ql-blank'); }); diff --git a/test/unit/core/selection.js b/test/unit/core/selection.js index 1d40b9d1cc..d09ec459d1 100644 --- a/test/unit/core/selection.js +++ b/test/unit/core/selection.js @@ -2,16 +2,16 @@ import Selection, { Range } from '../../../core/selection'; import Cursor from '../../../blots/cursor'; import Emitter from '../../../core/emitter'; -describe('Selection', function() { - beforeEach(function() { +describe('Selection', function () { + beforeEach(function () { this.setup = (html, index) => { this.selection = this.initialize(Selection, html); this.selection.setRange(new Range(index)); }; }); - describe('focus()', function() { - beforeEach(function() { + describe('focus()', function () { + beforeEach(function () { this.initialize(HTMLElement, '
'); this.selection = this.initialize( Selection, @@ -23,13 +23,13 @@ describe('Selection', function() { this.textarea.select(); }); - it('initial focus', function() { + it('initial focus', function () { expect(this.selection.hasFocus()).toBe(false); this.selection.focus(); expect(this.selection.hasFocus()).toBe(true); }); - it('restore last range', function() { + it('restore last range', function () { const range = new Range(1, 2); this.selection.setRange(range); this.textarea.focus(); @@ -41,8 +41,8 @@ describe('Selection', function() { }); }); - describe('getRange()', function() { - it('empty document', function() { + describe('getRange()', function () { + it('empty document', function () { const selection = this.initialize(Selection, ''); selection.setNativeRange(this.container.querySelector('br'), 0); const [range] = selection.getRange(); @@ -50,7 +50,7 @@ describe('Selection', function() { expect(range.length).toEqual(0); }); - it('empty line', function() { + it('empty line', function () { const selection = this.initialize( Selection, '

0


3

', @@ -61,7 +61,7 @@ describe('Selection', function() { expect(range.length).toEqual(0); }); - it('end of line', function() { + it('end of line', function () { const selection = this.initialize(Selection, '

0

'); selection.setNativeRange(this.container.firstChild.firstChild, 1); const [range] = selection.getRange(); @@ -69,7 +69,7 @@ describe('Selection', function() { expect(range.length).toEqual(0); }); - it('text node', function() { + it('text node', function () { const selection = this.initialize(Selection, '

0123

'); selection.setNativeRange(this.container.firstChild.firstChild, 1); const [range] = selection.getRange(); @@ -77,7 +77,7 @@ describe('Selection', function() { expect(range.length).toEqual(0); }); - it('line boundaries', function() { + it('line boundaries', function () { const selection = this.initialize(Selection, '


12

'); selection.setNativeRange( this.container.firstChild, @@ -90,7 +90,7 @@ describe('Selection', function() { expect(range.length).toEqual(3); }); - it('nested text node', function() { + it('nested text node', function () { const selection = this.initialize( Selection, ` @@ -110,7 +110,7 @@ describe('Selection', function() { expect(range.length).toEqual(3); }); - it('between embed across lines', function() { + it('between embed across lines', function () { const selection = this.initialize( Selection, ` @@ -134,7 +134,7 @@ describe('Selection', function() { expect(range.length).toEqual(3); }); - it('between embed across list', function() { + it('between embed across list', function () { const selection = this.initialize( Selection, ` @@ -160,7 +160,7 @@ describe('Selection', function() { expect(range.length).toEqual(3); }); - it('between inlines', function() { + it('between inlines', function () { const selection = this.initialize( Selection, '

012345

', @@ -176,7 +176,7 @@ describe('Selection', function() { expect(range.length).toEqual(2); }); - it('between blocks', function() { + it('between blocks', function () { const selection = this.initialize( Selection, ` @@ -193,7 +193,7 @@ describe('Selection', function() { expect(range.length).toEqual(4); }); - it('wrong input', function() { + it('wrong input', function () { const container = this.initialize( HTMLElement, ` @@ -211,8 +211,8 @@ describe('Selection', function() { }); }); - describe('setRange()', function() { - it('empty document', function() { + describe('setRange()', function () { + it('empty document', function () { const selection = this.initialize(Selection, ''); const expected = new Range(0); selection.setRange(expected); @@ -221,7 +221,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('empty lines', function() { + it('empty lines', function () { const selection = this.initialize( Selection, ` @@ -237,7 +237,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('nested text node', function() { + it('nested text node', function () { const selection = this.initialize( Selection, ` @@ -253,7 +253,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('between inlines', function() { + it('between inlines', function () { const selection = this.initialize( Selection, '

012345

', @@ -265,7 +265,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('single embed', function() { + it('single embed', function () { const selection = this.initialize( Selection, `

`, @@ -277,7 +277,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('between embeds', function() { + it('between embeds', function () { const selection = this.initialize( Selection, ` @@ -299,7 +299,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(true); }); - it('null', function() { + it('null', function () { const selection = this.initialize(Selection, '

0123

'); selection.setRange(new Range(1)); let [range] = selection.getRange(); @@ -310,7 +310,7 @@ describe('Selection', function() { expect(selection.hasFocus()).toBe(false); }); - it('after format', function(done) { + it('after format', function (done) { const selection = this.initialize(Selection, '

0123 567 9012

'); selection.setRange(new Range(5)); selection.format('bold', true); @@ -324,56 +324,48 @@ describe('Selection', function() { }); }); - describe('format()', function() { - it('trailing', function() { + describe('format()', function () { + it('trailing', function () { this.setup(`

0123

`, 4); this.selection.format('bold', true); expect(this.selection.getRange()[0].index).toEqual(4); expect(this.container).toEqualHTML(` -

0123${ - Cursor.CONTENTS - }

+

0123${Cursor.CONTENTS}

`); }); - it('split nodes', function() { + it('split nodes', function () { this.setup(`

0123

`, 2); this.selection.format('bold', true); expect(this.selection.getRange()[0].index).toEqual(2); expect(this.container).toEqualHTML(`

01 - ${ - Cursor.CONTENTS - } + ${Cursor.CONTENTS} 23

`); }); - it('between characters', function() { + it('between characters', function () { this.setup(`

01

`, 1); this.selection.format('underline', true); expect(this.selection.getRange()[0].index).toEqual(1); expect(this.container).toEqualHTML(` -

0${ - Cursor.CONTENTS - }1

+

0${Cursor.CONTENTS}1

`); }); - it('empty line', function() { + it('empty line', function () { this.setup(`


`, 0); this.selection.format('bold', true); expect(this.selection.getRange()[0].index).toEqual(0); expect(this.container).toEqualHTML(` -

${ - Cursor.CONTENTS - }

+

${Cursor.CONTENTS}

`); }); - it('cursor interference', function() { + it('cursor interference', function () { this.setup(`

0123

`, 2); this.selection.format('underline', true); this.selection.scroll.update(); @@ -381,7 +373,7 @@ describe('Selection', function() { expect(native.start.node).toEqual(this.selection.cursor.textNode); }); - it('multiple', function() { + it('multiple', function () { this.setup(`

0123

`, 2); this.selection.format('color', 'red'); this.selection.format('italic', true); @@ -399,7 +391,7 @@ describe('Selection', function() { `); }); - it('remove format', function() { + it('remove format', function () { this.setup(`

0123

`, 2); this.selection.format('italic', true); this.selection.format('underline', true); @@ -414,7 +406,7 @@ describe('Selection', function() { `); }); - it('selection change cleanup', function() { + it('selection change cleanup', function () { this.setup(`

0123

`, 2); this.selection.format('italic', true); this.selection.setRange(new Range(0, 0)); @@ -422,7 +414,7 @@ describe('Selection', function() { expect(this.container).toEqualHTML('

0123

'); }); - it('text change cleanup', function() { + it('text change cleanup', function () { this.setup(`

0123

`, 2); this.selection.format('italic', true); this.selection.cursor.textNode.data = `${Cursor.CONTENTS}|`; @@ -431,7 +423,7 @@ describe('Selection', function() { expect(this.container).toEqualHTML('

01|23

'); }); - it('no cleanup', function() { + it('no cleanup', function () { this.setup('

0123


', 2); this.selection.format('italic', true); this.container.removeChild(this.container.lastChild); @@ -442,10 +434,10 @@ describe('Selection', function() { `); }); - describe('unlink cursor', function() { + describe('unlink cursor', function () { const cursorHTML = `${Cursor.CONTENTS}`; - it('one level', function() { + it('one level', function () { this.setup( '

link


', 4, @@ -456,7 +448,7 @@ describe('Selection', function() { `); }); - it('nested formats', function() { + it('nested formats', function () { this.setup( '

bold


', 4, @@ -467,7 +459,7 @@ describe('Selection', function() { `); }); - it('ignore link format', function() { + it('ignore link format', function () { this.setup('

bold


', 4); this.selection.format('link', 'https://example.com'); expect(this.container).toEqualHTML(` @@ -477,8 +469,8 @@ describe('Selection', function() { }); }); - describe('getBounds()', function() { - beforeEach(function() { + describe('getBounds()', function () { + beforeEach(function () { this.container.classList.add('ql-editor'); this.container.style.fontFamily = 'monospace'; this.container.style.lineHeight = /Trident/i.test(navigator.userAgent) @@ -506,13 +498,13 @@ describe('Selection', function() { this.initialize(HTMLElement, '', this.div); }); - afterEach(function() { + afterEach(function () { this.float.style.left = `${this.bounds.left}px`; this.float.style.top = `${this.bounds.top}px`; this.float.style.height = `${this.bounds.height}px`; }); - it('empty document', function() { + it('empty document', function () { const selection = this.initialize(Selection, '


', this.div); this.bounds = selection.getBounds(0); if (/Android/i.test(navigator.userAgent)) return; // false positive on emulators atm @@ -521,7 +513,7 @@ describe('Selection', function() { expect(this.bounds.top).toBeApproximately(this.reference.top, 1); }); - it('empty line', function() { + it('empty line', function () { const selection = this.initialize( Selection, ` @@ -540,7 +532,7 @@ describe('Selection', function() { ); }); - it('plain text', function() { + it('plain text', function () { const selection = this.initialize(Selection, '

0123

', this.div); this.bounds = selection.getBounds(2); expect(this.bounds.left).toBeApproximately( @@ -551,7 +543,7 @@ describe('Selection', function() { expect(this.bounds.top).toBeApproximately(this.reference.top, 1); }); - it('multiple characters', function() { + it('multiple characters', function () { const selection = this.initialize(Selection, '

0123

', this.div); this.bounds = selection.getBounds(1, 2); expect(this.bounds.left).toBeApproximately( @@ -563,7 +555,7 @@ describe('Selection', function() { expect(this.bounds.width).toBeApproximately(this.reference.width * 2, 2); }); - it('start of line', function() { + it('start of line', function () { const selection = this.initialize( Selection, ` @@ -580,7 +572,7 @@ describe('Selection', function() { ); }); - it('end of line', function() { + it('end of line', function () { const selection = this.initialize( Selection, ` @@ -601,7 +593,7 @@ describe('Selection', function() { ); }); - it('multiple lines', function() { + it('multiple lines', function () { const selection = this.initialize( Selection, ` @@ -620,7 +612,7 @@ describe('Selection', function() { expect(this.bounds.width).toBeGreaterThan(3 * this.reference.width); }); - it('large text', function() { + it('large text', function () { const selection = this.initialize( Selection, '

0000

', @@ -639,7 +631,7 @@ describe('Selection', function() { expect(this.bounds.top).toBeApproximately(this.reference.top, 1); }); - it('image', function() { + it('image', function () { const selection = this.initialize( Selection, ` @@ -655,7 +647,7 @@ describe('Selection', function() { expect(this.bounds.top).toBeApproximately(this.reference.top, 1); }); - it('beyond document', function() { + it('beyond document', function () { const selection = this.initialize(Selection, '

0123

'); expect(() => { this.bounds = selection.getBounds(10, 0); diff --git a/test/unit/formats/align.js b/test/unit/formats/align.js index 0571ea402d..8e298a0d6b 100644 --- a/test/unit/formats/align.js +++ b/test/unit/formats/align.js @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('Align', function() { - it('add', function() { +describe('Align', function () { + it('add', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(4, 1, { align: 'center' }); expect(editor.getDelta()).toEqual( @@ -13,7 +13,7 @@ describe('Align', function() { ); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize( Editor, '

0123

', @@ -23,7 +23,7 @@ describe('Align', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('whitelist', function() { + it('whitelist', function () { const editor = this.initialize( Editor, '

0123

', @@ -36,7 +36,7 @@ describe('Align', function() { expect(editor.scroll.domNode).toEqualHTML(initial); }); - it('invalid scope', function() { + it('invalid scope', function () { const editor = this.initialize(Editor, '

0123

'); const initial = editor.scroll.domNode.innerHTML; editor.formatText(1, 2, { align: 'center' }); diff --git a/test/unit/formats/bold.js b/test/unit/formats/bold.js index f8f0bd88c9..ad3648f0cd 100644 --- a/test/unit/formats/bold.js +++ b/test/unit/formats/bold.js @@ -1,7 +1,7 @@ import Scroll from '../../../blots/scroll'; -describe('Bold', function() { - it('optimize and merge', function() { +describe('Bold', function () { + it('optimize and merge', function () { const scroll = this.initialize( Scroll, '

abc

', diff --git a/test/unit/formats/code.js b/test/unit/formats/code.js index 2497bb7f83..39de6f5006 100644 --- a/test/unit/formats/code.js +++ b/test/unit/formats/code.js @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('Code', function() { - it('format newline', function() { +describe('Code', function () { + it('format newline', function () { const editor = this.initialize(Editor, '


'); editor.formatLine(0, 1, { 'code-block': true }); expect(editor.scroll.domNode).toEqualHTML( @@ -12,7 +12,7 @@ describe('Code', function() { ); }); - it('format lines', function() { + it('format lines', function () { const editor = this.initialize(Editor, '

0123

5678

'); editor.formatLine(2, 5, { 'code-block': true }); expect(editor.getDelta()).toEqual( @@ -30,7 +30,7 @@ describe('Code', function() { ); }); - it('remove format', function() { + it('remove format', function () { const editor = this.initialize( Editor, '
0123
', @@ -40,7 +40,7 @@ describe('Code', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('delete last', function() { + it('delete last', function () { const editor = this.initialize( Editor, '

0123


5678

', @@ -57,7 +57,7 @@ describe('Code', function() { ); }); - it('delete merge before', function() { + it('delete merge before', function () { const editor = this.initialize( Editor, '

0123

4567
', @@ -71,7 +71,7 @@ describe('Code', function() { ); }); - it('delete merge after', function() { + it('delete merge after', function () { const editor = this.initialize( Editor, '
0123

4567

', @@ -83,7 +83,7 @@ describe('Code', function() { expect(editor.scroll.domNode).toEqualHTML('

01234567

'); }); - it('delete across before partial merge', function() { + it('delete across before partial merge', function () { const editor = this.initialize( Editor, `
@@ -112,7 +112,7 @@ describe('Code', function() { ); }); - it('delete across before no merge', function() { + it('delete across before no merge', function () { const editor = this.initialize( Editor, `
@@ -134,7 +134,7 @@ describe('Code', function() { ); }); - it('delete across after', function() { + it('delete across after', function () { const editor = this.initialize( Editor, `

0123

@@ -159,7 +159,7 @@ describe('Code', function() { `); }); - it('replace', function() { + it('replace', function () { const editor = this.initialize( Editor, '
0123
', @@ -171,7 +171,7 @@ describe('Code', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('replace multiple', function() { + it('replace multiple', function () { const editor = this.initialize( Editor, ` @@ -192,7 +192,7 @@ describe('Code', function() { expect(editor.scroll.domNode).toEqualHTML('

01

23

'); }); - it('format imprecise bounds', function() { + it('format imprecise bounds', function () { const editor = this.initialize( Editor, ` @@ -218,7 +218,7 @@ describe('Code', function() { ); }); - it('format without newline', function() { + it('format without newline', function () { const editor = this.initialize( Editor, ` @@ -248,7 +248,7 @@ describe('Code', function() { `); }); - it('format line', function() { + it('format line', function () { const editor = this.initialize( Editor, ` @@ -280,7 +280,7 @@ describe('Code', function() { `); }); - it('ignore formatAt', function() { + it('ignore formatAt', function () { const editor = this.initialize( Editor, '
0123
', @@ -294,7 +294,7 @@ describe('Code', function() { ); }); - it('partial block modification applyDelta', function() { + it('partial block modification applyDelta', function () { const editor = this.initialize( Editor, `
diff --git a/test/unit/formats/color.js b/test/unit/formats/color.js index 9d50cd41fe..2e8c38e92e 100644 --- a/test/unit/formats/color.js +++ b/test/unit/formats/color.js @@ -1,22 +1,19 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('Color', function() { - it('add', function() { +describe('Color', function () { + it('add', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { color: 'red' }); expect(editor.getDelta()).toEqual( - new Delta() - .insert('0') - .insert('12', { color: 'red' }) - .insert('3\n'), + new Delta().insert('0').insert('12', { color: 'red' }).insert('3\n'), ); expect(editor.scroll.domNode).toEqualHTML( '

0123

', ); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize( Editor, '

0123

', @@ -30,7 +27,7 @@ describe('Color', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('remove unwrap', function() { + it('remove unwrap', function () { const editor = this.initialize( Editor, '

0123

', @@ -40,7 +37,7 @@ describe('Color', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('invalid scope', function() { + it('invalid scope', function () { const editor = this.initialize(Editor, '

0123

'); const initial = editor.scroll.domNode.innerHTML; editor.formatText(4, 1, { color: 'red' }); diff --git a/test/unit/formats/header.js b/test/unit/formats/header.js index 43dbc8917e..af64a09162 100644 --- a/test/unit/formats/header.js +++ b/test/unit/formats/header.js @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('Header', function() { - it('add', function() { +describe('Header', function () { + it('add', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(4, 1, { header: 1 }); expect(editor.getDelta()).toEqual( @@ -11,7 +11,7 @@ describe('Header', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(4, 1, { header: false }); expect(editor.getDelta()).toEqual( @@ -20,7 +20,7 @@ describe('Header', function() { expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); - it('change', function() { + it('change', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(4, 1, { header: 2 }); expect(editor.getDelta()).toEqual( diff --git a/test/unit/formats/indent.js b/test/unit/formats/indent.js index c38a0d2c6d..d7c30d338e 100644 --- a/test/unit/formats/indent.js +++ b/test/unit/formats/indent.js @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('Indent', function() { - it('+1', function() { +describe('Indent', function () { + it('+1', function () { const editor = this.initialize( Editor, '
  1. 0123
', @@ -16,7 +16,7 @@ describe('Indent', function() { ); }); - it('-1', function() { + it('-1', function () { const editor = this.initialize( Editor, '
  1. 0123
', diff --git a/test/unit/formats/link.js b/test/unit/formats/link.js index 4197d1b9a0..a2f70fa4ea 100644 --- a/test/unit/formats/link.js +++ b/test/unit/formats/link.js @@ -2,8 +2,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; import Link from '../../../formats/link'; -describe('Link', function() { - it('add', function() { +describe('Link', function () { + it('add', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { link: 'https://quilljs.com' }); expect(editor.getDelta()).toEqual( @@ -17,7 +17,7 @@ describe('Link', function() { ); }); - it('add invalid', function() { + it('add invalid', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { link: 'javascript:alert(0);' }); // eslint-disable-line no-script-url expect(editor.getDelta()).toEqual( @@ -28,7 +28,7 @@ describe('Link', function() { ); }); - it('add non-whitelisted protocol', function() { + it('add non-whitelisted protocol', function () { const editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { link: 'gopher://quilljs.com' }); expect(editor.getDelta()).toEqual( @@ -42,7 +42,7 @@ describe('Link', function() { ); }); - it('change', function() { + it('change', function () { const editor = this.initialize( Editor, '

0123

', @@ -59,7 +59,7 @@ describe('Link', function() { ); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize( Editor, '

0123

', diff --git a/test/unit/formats/list.js b/test/unit/formats/list.js index d0b9f24127..29f9c450e9 100644 --- a/test/unit/formats/list.js +++ b/test/unit/formats/list.js @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; import Editor from '../../../core/editor'; -describe('List', function() { - it('add', function() { +describe('List', function () { + it('add', function () { const editor = this.initialize( Editor, ` @@ -24,7 +24,7 @@ describe('List', function() { `); }); - it('checklist', function() { + it('checklist', function () { const editor = this.initialize( Editor, ` @@ -53,7 +53,7 @@ describe('List', function() { `); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize( Editor, ` @@ -71,7 +71,7 @@ describe('List', function() { `); }); - it('replace', function() { + it('replace', function () { const editor = this.initialize( Editor, ` @@ -94,7 +94,7 @@ describe('List', function() { `); }); - it('replace checklist with bullet', function() { + it('replace checklist with bullet', function () { const editor = this.initialize( Editor, ` @@ -112,7 +112,7 @@ describe('List', function() { `); }); - it('replace with attributes', function() { + it('replace with attributes', function () { const editor = this.initialize( Editor, '
  1. 0123
', @@ -128,7 +128,7 @@ describe('List', function() { ); }); - it('format merge', function() { + it('format merge', function () { const editor = this.initialize( Editor, ` @@ -155,7 +155,7 @@ describe('List', function() { `); }); - it('delete merge', function() { + it('delete merge', function () { const editor = this.initialize( Editor, ` @@ -178,7 +178,7 @@ describe('List', function() { `); }); - it('merge checklist', function() { + it('merge checklist', function () { const editor = this.initialize( Editor, ` @@ -205,7 +205,7 @@ describe('List', function() { `); }); - it('empty line interop', function() { + it('empty line interop', function () { const editor = this.initialize( Editor, '

', @@ -220,7 +220,7 @@ describe('List', function() { ); }); - it('delete multiple items', function() { + it('delete multiple items', function () { const editor = this.initialize( Editor, ` @@ -238,7 +238,7 @@ describe('List', function() { `); }); - it('delete across last item', function() { + it('delete across last item', function () { const editor = this.initialize( Editor, ` @@ -249,7 +249,7 @@ describe('List', function() { expect(this.container).toEqualHTML('

0178

'); }); - it('delete partial', function() { + it('delete partial', function () { const editor = this.initialize( Editor, '

0123

  1. 5678
', @@ -260,7 +260,7 @@ describe('List', function() { ); }); - it('nested list replacement', function() { + it('nested list replacement', function () { const editor = this.initialize( Editor, ` @@ -281,7 +281,7 @@ describe('List', function() { `); }); - it('copy atttributes', function() { + it('copy atttributes', function () { const editor = this.initialize( Editor, '

Test

', @@ -292,7 +292,7 @@ describe('List', function() { ); }); - it('insert block embed', function() { + it('insert block embed', function () { const editor = this.initialize( Editor, '
  1. Test
', @@ -309,7 +309,7 @@ describe('List', function() { `); }); - it('insert block embed at beginning', function() { + it('insert block embed at beginning', function () { const editor = this.initialize( Editor, '
  1. Test
', @@ -325,7 +325,7 @@ describe('List', function() { `); }); - it('insert block embed at end', function() { + it('insert block embed at end', function () { const editor = this.initialize( Editor, '
  1. Test
', diff --git a/test/unit/formats/script.js b/test/unit/formats/script.js index 320ed047b9..0d1d9496da 100644 --- a/test/unit/formats/script.js +++ b/test/unit/formats/script.js @@ -1,7 +1,7 @@ import Editor from '../../../core/editor'; -describe('Script', function() { - it('add', function() { +describe('Script', function () { + it('add', function () { const editor = this.initialize( Editor, '

a2 + b2 = c2

', @@ -12,7 +12,7 @@ describe('Script', function() { ); }); - it('remove', function() { + it('remove', function () { const editor = this.initialize( Editor, '

a2 + b2

', @@ -21,7 +21,7 @@ describe('Script', function() { expect(editor.scroll.domNode).toEqualHTML('

a2 + b2

'); }); - it('replace', function() { + it('replace', function () { const editor = this.initialize( Editor, '

a2 + b2

', diff --git a/test/unit/formats/table.js b/test/unit/formats/table.js index e3a299dbee..7b2671509b 100644 --- a/test/unit/formats/table.js +++ b/test/unit/formats/table.js @@ -42,20 +42,20 @@ const tableHTML = ` `; -describe('Table', function() { - it('initialize', function() { +describe('Table', function () { + it('initialize', function () { const editor = this.initialize(Editor, tableHTML); expect(editor.getDelta()).toEqual(tableDelta); expect(this.container).toEqualHTML(tableHTML); }); - it('add', function() { + it('add', function () { const editor = this.initialize(Editor, ''); editor.applyDelta(new Delta([...tableDelta.ops]).delete(1)); expect(this.container).toEqualHTML(tableHTML); }); - it('add format plaintext', function() { + it('add format plaintext', function () { const editor = this.initialize(Editor, '

Test

'); editor.formatLine(0, 5, { table: 'a' }); expect(this.container).toEqualHTML( @@ -63,7 +63,7 @@ describe('Table', function() { ); }); - it('add format replace', function() { + it('add format replace', function () { const editor = this.initialize(Editor, '

Test

'); editor.formatLine(0, 5, { table: 'a' }); expect(this.container).toEqualHTML( @@ -71,7 +71,7 @@ describe('Table', function() { ); }); - it('remove format plaintext', function() { + it('remove format plaintext', function () { const editor = this.initialize( Editor, '
Test
', @@ -80,7 +80,7 @@ describe('Table', function() { expect(this.container).toEqualHTML('

Test

'); }); - it('remove format replace', function() { + it('remove format replace', function () { const editor = this.initialize( Editor, '
Test
', @@ -89,7 +89,7 @@ describe('Table', function() { expect(this.container).toEqualHTML('

Test

'); }); - it('group rows', function() { + it('group rows', function () { const editor = this.initialize( Editor, ` @@ -111,7 +111,7 @@ describe('Table', function() { `); }); - it('split rows', function() { + it('split rows', function () { const editor = this.initialize( Editor, ` @@ -133,7 +133,7 @@ describe('Table', function() { `); }); - it('group and split rows', function() { + it('group and split rows', function () { const editor = this.initialize( Editor, ` @@ -156,7 +156,7 @@ describe('Table', function() { `); }); - xit('group and split multiple rows', function() { + xit('group and split multiple rows', function () { const editor = this.initialize( Editor, ` @@ -184,7 +184,7 @@ describe('Table', function() { `); }); - it('balance cells', function() { + it('balance cells', function () { const editor = this.initialize( Editor, ` @@ -228,7 +228,7 @@ describe('Table', function() { ); }); - it('format', function() { + it('format', function () { const editor = this.initialize(Editor, '

a

b

1

2

'); editor.formatLine(0, 4, { table: 'a' }); editor.formatLine(4, 4, { table: 'b' }); @@ -248,7 +248,7 @@ describe('Table', function() { ); }); - it('applyDelta', function() { + it('applyDelta', function () { const editor = this.initialize(Editor, '


'); editor.applyDelta( new Delta().insert('\n\n', { table: 'a' }).insert('\n\n', { table: 'b' }), @@ -270,7 +270,7 @@ describe('Table', function() { ); }); - it('unbalanced table applyDelta', function() { + it('unbalanced table applyDelta', function () { const editor = this.initialize(Editor, '


'); editor.applyDelta( new Delta() @@ -301,7 +301,7 @@ describe('Table', function() { ); }); - it('existing table applyDelta', function() { + it('existing table applyDelta', function () { const editor = this.initialize( Editor, ` diff --git a/test/unit/modules/clipboard.js b/test/unit/modules/clipboard.js index 3b30bbbd77..5467cf0797 100644 --- a/test/unit/modules/clipboard.js +++ b/test/unit/modules/clipboard.js @@ -2,15 +2,15 @@ import Delta from 'quill-delta'; import { Range } from '../../../core/selection'; import Quill from '../../../core'; -describe('Clipboard', function() { - describe('events', function() { - beforeEach(function() { +describe('Clipboard', function () { + describe('events', function () { + beforeEach(function () { this.quill = this.initialize(Quill, '

0123

5678

'); this.quill.setSelection(2, 5); }); - describe('paste', function() { - beforeAll(function() { + describe('paste', function () { + beforeAll(function () { this.clipboardEvent = { clipboardData: { getData: type => @@ -20,7 +20,7 @@ describe('Clipboard', function() { }; }); - it('pastes html data', function(done) { + it('pastes html data', function (done) { this.quill.clipboard.onCapturePaste(this.clipboardEvent); setTimeout(() => { expect(this.quill.root).toEqualHTML( @@ -32,7 +32,7 @@ describe('Clipboard', function() { }); // Copying from Word includes both html and files - it('pastes html data if present with file', function(done) { + it('pastes html data if present with file', function (done) { const upload = spyOn(this.quill.uploader, 'upload'); this.quill.clipboard.onCapturePaste({ ...this.clipboardEvent, @@ -51,7 +51,7 @@ describe('Clipboard', function() { }, 2); }); - it('pastes image file if present with image only html', function(done) { + it('pastes image file if present with image only html', function (done) { const upload = spyOn(this.quill.uploader, 'upload'); this.quill.clipboard.onCapturePaste({ ...this.clipboardEvent, @@ -69,11 +69,11 @@ describe('Clipboard', function() { }, 2); }); - it('does not fire selection-change', function(done) { + it('does not fire selection-change', function (done) { const change = jasmine.createSpy('change'); this.quill.on('selection-change', change); this.quill.clipboard.onCapturePaste(this.clipboardEvent); - setTimeout(function() { + setTimeout(function () { expect(change).not.toHaveBeenCalled(); done(); }, 2); @@ -81,7 +81,7 @@ describe('Clipboard', function() { }); describe('cut', () => { - beforeEach(function() { + beforeEach(function () { this.clipboardData = {}; this.clipboardEvent = { clipboardData: { @@ -93,7 +93,7 @@ describe('Clipboard', function() { }; }); - it('keeps formats of first line', function(done) { + it('keeps formats of first line', function (done) { this.quill.clipboard.onCaptureCopy(this.clipboardEvent, true); setTimeout(() => { expect(this.quill.root).toEqualHTML('

0178

'); @@ -107,14 +107,14 @@ describe('Clipboard', function() { }); }); - it('dangerouslyPasteHTML(html)', function() { + it('dangerouslyPasteHTML(html)', function () { this.quill.clipboard.dangerouslyPasteHTML('abcd'); expect(this.quill.root).toEqualHTML( '

abcd

', ); }); - it('dangerouslyPasteHTML(index, html)', function() { + it('dangerouslyPasteHTML(index, html)', function () { this.quill.clipboard.dangerouslyPasteHTML(2, 'ab'); expect(this.quill.root).toEqualHTML( '

01ab23

5678

', @@ -122,18 +122,18 @@ describe('Clipboard', function() { }); }); - describe('convert', function() { - beforeEach(function() { + describe('convert', function () { + beforeEach(function () { const quill = this.initialize(Quill, ''); this.clipboard = quill.clipboard; }); - it('plain text', function() { + it('plain text', function () { const delta = this.clipboard.convert({ html: 'simple plain text' }); expect(delta).toEqual(new Delta().insert('simple plain text')); }); - it('whitespace', function() { + it('whitespace', function () { const html = '
0
1 2 3 4
' + '
5 6 7 8
'; @@ -141,18 +141,15 @@ describe('Clipboard', function() { expect(delta).toEqual(new Delta().insert('0\n1 2 3 4\n5 6 7 8')); }); - it('inline whitespace', function() { + it('inline whitespace', function () { const html = '

0 1 2

'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( - new Delta() - .insert('0 ') - .insert('1', { bold: true }) - .insert(' 2'), + new Delta().insert('0 ').insert('1', { bold: true }).insert(' 2'), ); }); - it('intentional whitespace', function() { + it('intentional whitespace', function () { const html = '1 2'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( @@ -163,7 +160,7 @@ describe('Clipboard', function() { ); }); - it('consecutive intentional whitespace', function() { + it('consecutive intentional whitespace', function () { const html = '  1  '; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( @@ -171,14 +168,14 @@ describe('Clipboard', function() { ); }); - it('break', function() { + it('break', function () { const html = '
0
1
2
3

4

5
'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual(new Delta().insert('0\n1\n2\n3\n\n4\n\n5')); }); - it('empty block', function() { + it('empty block', function () { const html = '

Test

Body

'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( @@ -189,14 +186,14 @@ describe('Clipboard', function() { ); }); - it('mixed inline and block', function() { + it('mixed inline and block', function () { const delta = this.clipboard.convert({ html: '
One
Two
', }); expect(delta).toEqual(new Delta().insert('One\nTwo')); }); - it('alias', function() { + it('alias', function () { const delta = this.clipboard.convert({ html: 'BoldItalic', }); @@ -207,7 +204,7 @@ describe('Clipboard', function() { ); }); - it('pre', function() { + it('pre', function () { const html = '
 01 \n 23 
'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( @@ -215,7 +212,7 @@ describe('Clipboard', function() { ); }); - it('pre with \\n node', function() { + it('pre with \\n node', function () { const html = '
 01 \n 23 
'; const delta = this.clipboard.convert({ html }); expect(delta).toEqual( @@ -223,7 +220,7 @@ describe('Clipboard', function() { ); }); - it('nested list', function() { + it('nested list', function () { const delta = this.clipboard.convert({ html: '
  1. One
  2. Alpha
', }); @@ -234,10 +231,9 @@ describe('Clipboard', function() { ); }); - it('html nested list', function() { + it('html nested list', function () { const delta = this.clipboard.convert({ - html: - '
  1. One
    1. Alpha
    2. Beta
      1. I
', + html: '
  1. One
    1. Alpha
    2. Beta
      1. I
', }); expect(delta).toEqual( new Delta() @@ -247,10 +243,9 @@ describe('Clipboard', function() { ); }); - it('html nested bullet', function() { + it('html nested bullet', function () { const delta = this.clipboard.convert({ - html: - '
  • One
    • Alpha
    • Beta
      • I
', + html: '
  • One
    • Alpha
    • Beta
      • I
', }); expect(delta).toEqual( new Delta() @@ -260,7 +255,7 @@ describe('Clipboard', function() { ); }); - it('html nested checklist', function() { + it('html nested checklist', function () { const delta = this.clipboard.convert({ html: '
  • One
    • Alpha
    • Beta' + @@ -274,10 +269,9 @@ describe('Clipboard', function() { ); }); - it('html partial list', function() { + it('html partial list', function () { const delta = this.clipboard.convert({ - html: - '
          1. iiii
        1. bbbb
      1. 2222
      ', + html: '
          1. iiii
        1. bbbb
      1. 2222
      ', }); expect(delta).toEqual( new Delta() @@ -287,7 +281,7 @@ describe('Clipboard', function() { ); }); - it('html table', function() { + it('html table', function () { const delta = this.clipboard.convert({ html: '
' + @@ -302,10 +296,9 @@ describe('Clipboard', function() { ); }); - it('embeds', function() { + it('embeds', function () { const delta = this.clipboard.convert({ - html: - '
0134
', + html: '
0134
', }); const expected = new Delta() .insert('01') @@ -317,19 +310,16 @@ describe('Clipboard', function() { expect(delta).toEqual(expected); }); - it('block embed', function() { + it('block embed', function () { const delta = this.clipboard.convert({ html: '

01

34

', }); expect(delta).toEqual( - new Delta() - .insert('01\n') - .insert({ video: '#' }) - .insert('34'), + new Delta().insert('01\n').insert({ video: '#' }).insert('34'), ); }); - it('block embeds within blocks', function() { + it('block embeds within blocks', function () { const delta = this.clipboard.convert({ html: '

0134

67

', }); @@ -342,7 +332,7 @@ describe('Clipboard', function() { ); }); - it('wrapped block embed', function() { + it('wrapped block embed', function () { const delta = this.clipboard.convert({ html: '

0134

67

', }); @@ -355,10 +345,9 @@ describe('Clipboard', function() { ); }); - it('wrapped block embed with siblings', function() { + it('wrapped block embed with siblings', function () { const delta = this.clipboard.convert({ - html: - '

01ab34

67

', + html: '

01ab34

67

', }); expect(delta).toEqual( new Delta() @@ -371,23 +360,22 @@ describe('Clipboard', function() { ); }); - it('attributor and style match', function() { + it('attributor and style match', function () { const delta = this.clipboard.convert({ html: '

Test

', }); expect(delta).toEqual(new Delta().insert('Test\n', { direction: 'rtl' })); }); - it('nested styles', function() { + it('nested styles', function () { const delta = this.clipboard.convert({ - html: - 'Test', + html: 'Test', }); expect(delta).toEqual(new Delta().insert('Test', { color: 'blue' })); }); - it('custom matcher', function() { - this.clipboard.addMatcher(Node.TEXT_NODE, function(node, delta) { + it('custom matcher', function () { + this.clipboard.addMatcher(Node.TEXT_NODE, function (node, delta) { let index = 0; const regex = /https?:\/\/[^\s]+/g; let match = null; @@ -410,7 +398,7 @@ describe('Clipboard', function() { expect(delta).toEqual(expected); }); - it('does not execute javascript', function() { + it('does not execute javascript', function () { window.unsafeFunction = jasmine.createSpy('unsafeFunction'); const html = ""; @@ -419,7 +407,7 @@ describe('Clipboard', function() { delete window.unsafeFunction; }); - it('xss', function() { + it('xss', function () { const delta = this.clipboard.convert({ html: '', }); diff --git a/test/unit/modules/history.js b/test/unit/modules/history.js index a176f93234..11e9d676de 100644 --- a/test/unit/modules/history.js +++ b/test/unit/modules/history.js @@ -3,69 +3,63 @@ import Quill from '../../../core'; import { globalRegistry } from '../../../core/quill'; import { getLastChangeIndex } from '../../../modules/history'; -describe('History', function() { - describe('getLastChangeIndex', function() { - it('delete', function() { +describe('History', function () { + describe('getLastChangeIndex', function () { + it('delete', function () { const delta = new Delta().retain(4).delete(2); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(4); }); - it('delete with inserts', function() { - const delta = new Delta() - .retain(4) - .insert('test') - .delete(2); + it('delete with inserts', function () { + const delta = new Delta().retain(4).insert('test').delete(2); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(8); }); - it('insert text', function() { + it('insert text', function () { const delta = new Delta().retain(4).insert('testing'); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(11); }); - it('insert embed', function() { + it('insert embed', function () { const delta = new Delta().retain(4).insert({ image: true }); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(5); }); - it('insert with deletes', function() { - const delta = new Delta() - .retain(4) - .delete(3) - .insert('!'); + it('insert with deletes', function () { + const delta = new Delta().retain(4).delete(3).insert('!'); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(5); }); - it('format', function() { + it('format', function () { const delta = new Delta().retain(4).retain(3, { bold: true }); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(7); }); - it('format newline', function() { + it('format newline', function () { const delta = new Delta().retain(4).retain(1, { align: 'left' }); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(4); }); - it('format mixed', function() { + it('format mixed', function () { const delta = new Delta() .retain(4) .retain(1, { align: 'left', bold: true }); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(4); }); - it('insert newline', function() { + it('insert newline', function () { const delta = new Delta().retain(4).insert('a\n'); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(5); }); - it('mutliple newline inserts', function() { + it('mutliple newline inserts', function () { const delta = new Delta().retain(4).insert('ab\n\n'); expect(getLastChangeIndex(globalRegistry, delta)).toEqual(7); }); }); - describe('undo/redo', function() { - beforeEach(function() { + describe('undo/redo', function () { + beforeEach(function () { this.initialize(HTMLElement, '

The lazy fox

'); this.quill = new Quill(this.container.firstChild, { modules: { @@ -75,19 +69,19 @@ describe('History', function() { this.original = this.quill.getContents(); }); - it('limits undo stack size', function() { + it('limits undo stack size', function () { const quill = new Quill(this.container.firstChild, { modules: { history: { delay: 0, maxStack: 2 }, }, }); - ['A', 'B', 'C'].forEach(function(text) { + ['A', 'B', 'C'].forEach(function (text) { quill.insertText(0, text); }); expect(quill.history.stack.undo.length).toEqual(2); }); - it('user change', function() { + it('user change', function () { this.quill.root.firstChild.innerHTML = 'The lazy foxes'; this.quill.update(); const changed = this.quill.getContents(); @@ -98,7 +92,7 @@ describe('History', function() { expect(this.quill.getContents()).toEqual(changed); }); - it('merge changes', function() { + it('merge changes', function () { expect(this.quill.history.stack.undo.length).toEqual(0); this.quill.updateContents(new Delta().retain(12).insert('e')); expect(this.quill.history.stack.undo.length).toEqual(1); @@ -109,7 +103,7 @@ describe('History', function() { expect(this.quill.history.stack.undo.length).toEqual(0); }); - it('dont merge changes', function(done) { + it('dont merge changes', function (done) { expect(this.quill.history.stack.undo.length).toEqual(0); this.quill.updateContents(new Delta().retain(12).insert('e')); expect(this.quill.history.stack.undo.length).toEqual(1); @@ -120,7 +114,7 @@ describe('History', function() { }, this.quill.history.options.delay * 1.25); }); - it('multiple undos', function(done) { + it('multiple undos', function (done) { expect(this.quill.history.stack.undo.length).toEqual(0); this.quill.updateContents(new Delta().retain(12).insert('e')); const contents = this.quill.getContents(); @@ -134,7 +128,7 @@ describe('History', function() { }, this.quill.history.options.delay * 1.25); }); - it('transform api change', function() { + it('transform api change', function () { this.quill.history.options.userOnly = true; this.quill.updateContents( new Delta().retain(12).insert('es'), @@ -165,7 +159,7 @@ describe('History', function() { ); }); - it('transform preserve intention', function() { + it('transform preserve intention', function () { const url = 'https://www.google.com/'; this.quill.history.options.userOnly = true; this.quill.updateContents( @@ -196,7 +190,7 @@ describe('History', function() { ); }); - it('ignore remote changes', function() { + it('ignore remote changes', function () { this.quill.history.options.delay = 0; this.quill.history.options.userOnly = true; this.quill.setText('\n'); @@ -215,7 +209,7 @@ describe('History', function() { expect(this.quill.getText()).toEqual('abcd\n'); }); - it('correctly transform against remote changes', function() { + it('correctly transform against remote changes', function () { this.quill.history.options.delay = 0; this.quill.history.options.userOnly = true; this.quill.setText('b\n'); @@ -233,7 +227,7 @@ describe('History', function() { expect(this.quill.getText()).toEqual('abcd\n'); }); - it('correctly transform against remote changes breaking up an insert', function() { + it('correctly transform against remote changes breaking up an insert', function () { this.quill.history.options.delay = 0; this.quill.history.options.userOnly = true; this.quill.setText('\n'); diff --git a/test/unit/modules/keyboard.js b/test/unit/modules/keyboard.js index 56dd840d91..90424509f0 100644 --- a/test/unit/modules/keyboard.js +++ b/test/unit/modules/keyboard.js @@ -1,8 +1,8 @@ import Keyboard, { SHORTKEY, normalize } from '../../../modules/keyboard'; -describe('Keyboard', function() { - describe('match', function() { - it('no modifiers', function() { +describe('Keyboard', function () { + describe('match', function () { + it('no modifiers', function () { const binding = normalize({ key: 'a', }); @@ -32,7 +32,7 @@ describe('Keyboard', function() { ).toBe(false); }); - it('simple modifier', function() { + it('simple modifier', function () { const binding = normalize({ key: 'a', altKey: true, @@ -63,7 +63,7 @@ describe('Keyboard', function() { ).toBe(true); }); - it('optional modifier', function() { + it('optional modifier', function () { const binding = normalize({ key: 'a', altKey: null, @@ -94,7 +94,7 @@ describe('Keyboard', function() { ).toBe(true); }); - it('shortkey modifier', function() { + it('shortkey modifier', function () { const binding = normalize({ key: 'a', shortKey: true, @@ -126,7 +126,7 @@ describe('Keyboard', function() { ).toBe(true); }); - it('native shortkey modifier', function() { + it('native shortkey modifier', function () { const binding = normalize({ key: 'a', [SHORTKEY]: true, diff --git a/test/unit/modules/syntax.js b/test/unit/modules/syntax.js index 828e955989..2303b50395 100644 --- a/test/unit/modules/syntax.js +++ b/test/unit/modules/syntax.js @@ -7,8 +7,8 @@ import Syntax, { CodeBlock as SyntaxCodeBlock } from '../../../modules/syntax'; const HIGHLIGHT_INTERVAL = 10; -describe('Syntax', function() { - beforeAll(function() { +describe('Syntax', function () { + beforeAll(function () { Syntax.register(); Syntax.DEFAULTS.languages = [ { key: 'javascript', label: 'Javascript' }, @@ -16,7 +16,7 @@ describe('Syntax', function() { ]; }); - beforeEach(function() { + beforeEach(function () { const container = this.initialize( HTMLElement, `
var test = 1;
var bugz = 0;
@@ -32,13 +32,13 @@ describe('Syntax', function() { }); }); - afterAll(function() { + afterAll(function () { Quill.register(CodeBlock, true); Quill.register(CodeBlockContainer, true); }); - describe('highlighting', function() { - it('initialize', function() { + describe('highlighting', function () { + it('initialize', function () { expect(this.quill.root).toEqualHTML( `
var test = 1;
@@ -56,7 +56,7 @@ describe('Syntax', function() { ); }); - it('adds token', function(done) { + it('adds token', function (done) { setTimeout(() => { expect(this.quill.root).toEqualHTML( `
@@ -77,7 +77,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('tokens do not escape', function(done) { + it('tokens do not escape', function (done) { this.quill.deleteText(22, 6); setTimeout(() => { expect(this.quill.root).toEqualHTML(` @@ -95,7 +95,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('change language', function(done) { + it('change language', function (done) { this.quill.formatLine(0, 20, 'code-block', 'ruby'); setTimeout(() => { expect(this.quill.root).toEqualHTML(` @@ -116,7 +116,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('invalid language', function(done) { + it('invalid language', function (done) { this.quill.formatLine(0, 20, 'code-block', 'invalid'); setTimeout(() => { expect(this.quill.root).toEqualHTML(` @@ -137,7 +137,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('unformat first line', function(done) { + it('unformat first line', function (done) { this.quill.formatLine(0, 1, 'code-block', false); setTimeout(() => { expect(this.quill.root).toEqualHTML(` @@ -156,7 +156,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('split container', function(done) { + it('split container', function (done) { this.quill.updateContents(new Delta().retain(14).insert('\n')); setTimeout(() => { expect(this.quill.root).toEqualHTML( @@ -192,7 +192,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('merge containers', function(done) { + it('merge containers', function (done) { this.quill.updateContents(new Delta().retain(14).insert('\n')); setTimeout(() => { this.quill.deleteText(14, 1); @@ -224,16 +224,16 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - describe('allowedChildren', function() { - beforeAll(function() { + describe('allowedChildren', function () { + beforeAll(function () { SyntaxCodeBlock.allowedChildren.push(BoldBlot); }); - afterAll(function() { + afterAll(function () { SyntaxCodeBlock.allowedChildren.pop(); }); - it('modification', function(done) { + it('modification', function (done) { this.quill.formatText(2, 3, 'bold', true); setTimeout(() => { expect(this.quill.root).toEqualHTML(` @@ -256,7 +256,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('removal', function(done) { + it('removal', function (done) { this.quill.formatText(2, 3, 'bold', true); setTimeout(() => { this.quill.formatLine(0, 15, 'code-block', false); @@ -273,7 +273,7 @@ describe('Syntax', function() { }, HIGHLIGHT_INTERVAL + 1); }); - it('addition', function(done) { + it('addition', function (done) { this.quill.setText('var test = 1;\n'); this.quill.formatText(2, 3, 'bold', true); this.quill.formatLine(0, 1, 'code-block', 'javascript'); @@ -295,8 +295,8 @@ describe('Syntax', function() { }); }); - describe('html', function() { - it('code language', function() { + describe('html', function () { + it('code language', function () { expect(this.quill.getSemanticHTML()).toContain( 'data-language="javascript"', ); diff --git a/test/unit/modules/table.js b/test/unit/modules/table.js index bb9d8015c1..67d795f6b0 100644 --- a/test/unit/modules/table.js +++ b/test/unit/modules/table.js @@ -1,9 +1,9 @@ import Delta from 'quill-delta'; import Quill from '../../../core/quill'; -describe('Table Module', function() { - describe('insert table', function() { - it('empty', function() { +describe('Table Module', function () { + describe('insert table', function () { + it('empty', function () { const quill = this.initialize(Quill, '


', this.container, { modules: { table: true, @@ -23,7 +23,7 @@ describe('Table Module', function() { `); }); - it('split', function() { + it('split', function () { const quill = this.initialize(Quill, '

0123

', this.container, { modules: { table: true, @@ -44,8 +44,8 @@ describe('Table Module', function() { }); }); - describe('modify table', function() { - beforeEach(function() { + describe('modify table', function () { + beforeEach(function () { const tableHTML = `
@@ -62,7 +62,7 @@ describe('Table Module', function() { this.table = this.quill.getModule('table'); }); - it('insertRowAbove', function() { + it('insertRowAbove', function () { this.quill.setSelection(0); this.table.insertRowAbove(); expect(this.quill.root).toEqualHTML(` @@ -76,7 +76,7 @@ describe('Table Module', function() { `); }); - it('insertRowBelow', function() { + it('insertRowBelow', function () { this.quill.setSelection(0); this.table.insertRowBelow(); expect(this.quill.root).toEqualHTML(` @@ -90,7 +90,7 @@ describe('Table Module', function() { `); }); - it('insertColumnLeft', function() { + it('insertColumnLeft', function () { this.quill.setSelection(0); this.table.insertColumnLeft(); expect(this.quill.root).toEqualHTML(` @@ -103,7 +103,7 @@ describe('Table Module', function() { `); }); - it('insertColumnRight', function() { + it('insertColumnRight', function () { this.quill.setSelection(0); this.table.insertColumnRight(); expect(this.quill.root).toEqualHTML(` @@ -116,7 +116,7 @@ describe('Table Module', function() { `); }); - it('deleteRow', function() { + it('deleteRow', function () { this.quill.setSelection(0); this.table.deleteRow(); expect(this.quill.root).toEqualHTML(` @@ -128,7 +128,7 @@ describe('Table Module', function() { `); }); - it('deleteColumn', function() { + it('deleteColumn', function () { this.quill.setSelection(0); this.table.deleteColumn(); expect(this.quill.root).toEqualHTML(` @@ -141,7 +141,7 @@ describe('Table Module', function() { `); }); - it('insertText before', function() { + it('insertText before', function () { this.quill.updateContents(new Delta().insert('\n')); expect(this.quill.root).toEqualHTML(`


@@ -154,7 +154,7 @@ describe('Table Module', function() { `); }); - it('insertText after', function() { + it('insertText after', function () { this.quill.updateContents(new Delta().retain(18).insert('\n')); expect(this.quill.root).toEqualHTML(`
diff --git a/test/unit/modules/toolbar.js b/test/unit/modules/toolbar.js index 7e04fc911d..29c0a03e15 100644 --- a/test/unit/modules/toolbar.js +++ b/test/unit/modules/toolbar.js @@ -1,9 +1,9 @@ import Quill from '../../../core/quill'; import { addControls } from '../../../modules/toolbar'; -describe('Toolbar', function() { - describe('add controls', function() { - it('single level', function() { +describe('Toolbar', function () { + describe('add controls', function () { + it('single level', function () { addControls(this.container, ['bold', 'italic']); expect(this.container).toEqualHTML(` @@ -13,7 +13,7 @@ describe('Toolbar', function() { `); }); - it('nested group', function() { + it('nested group', function () { addControls(this.container, [ ['bold', 'italic'], ['underline', 'strike'], @@ -30,7 +30,7 @@ describe('Toolbar', function() { `); }); - it('button value', function() { + it('button value', function () { addControls(this.container, ['bold', { header: '2' }]); expect(this.container).toEqualHTML(` @@ -40,7 +40,7 @@ describe('Toolbar', function() { `); }); - it('select', function() { + it('select', function () { addControls(this.container, [{ size: ['10px', false, '18px', '32px'] }]); expect(this.container).toEqualHTML(` @@ -54,7 +54,7 @@ describe('Toolbar', function() { `); }); - it('everything', function() { + it('everything', function () { addControls(this.container, [ [ { font: [false, 'sans-serif', 'monospace'] }, @@ -106,8 +106,8 @@ describe('Toolbar', function() { }); }); - describe('active', function() { - beforeEach(function() { + describe('active', function () { + beforeEach(function () { const container = this.initialize( HTMLElement, ` @@ -130,30 +130,27 @@ describe('Toolbar', function() { }); }); - it('toggle button', function() { - const boldButton = this.container.parentNode.querySelector( - 'button.ql-bold', - ); + it('toggle button', function () { + const boldButton = + this.container.parentNode.querySelector('button.ql-bold'); this.quill.setSelection(7); expect(boldButton.classList.contains('ql-active')).toBe(true); this.quill.setSelection(2); expect(boldButton.classList.contains('ql-active')).toBe(false); }); - it('link', function() { - const linkButton = this.container.parentNode.querySelector( - 'button.ql-link', - ); + it('link', function () { + const linkButton = + this.container.parentNode.querySelector('button.ql-link'); this.quill.setSelection(12); expect(linkButton.classList.contains('ql-active')).toBe(true); this.quill.setSelection(2); expect(linkButton.classList.contains('ql-active')).toBe(false); }); - it('dropdown', function() { - const sizeSelect = this.container.parentNode.querySelector( - 'select.ql-size', - ); + it('dropdown', function () { + const sizeSelect = + this.container.parentNode.querySelector('select.ql-size'); this.quill.setSelection(21); expect(sizeSelect.selectedIndex).toEqual(0); this.quill.setSelection(23); @@ -164,7 +161,7 @@ describe('Toolbar', function() { expect(sizeSelect.selectedIndex).toEqual(1); }); - it('custom button', function() { + it('custom button', function () { const centerButton = this.container.parentNode.querySelector( 'button.ql-align[value="center"]', ); diff --git a/test/unit/theme/base/tooltip.js b/test/unit/theme/base/tooltip.js index b76e5380f1..3e71a0b581 100644 --- a/test/unit/theme/base/tooltip.js +++ b/test/unit/theme/base/tooltip.js @@ -5,70 +5,70 @@ class Tooltip extends BaseTooltip {} Tooltip.TEMPLATE = ''; -describe('BaseTooltip', function() { - describe('save', function() { - beforeEach(function() { +describe('BaseTooltip', function () { + describe('save', function () { + beforeEach(function () { this.quill = this.initialize(Quill, ''); this.tooltip = new Tooltip(this.quill); }); - it('converts youtube video url to embedded', function() { + it('converts youtube video url to embedded', function () { insertVideo(this.tooltip, 'http://youtube.com/watch?v=QHH3iSeDBLo'); expect(this.container.querySelector('.ql-video').src).toContain( 'http://www.youtube.com/embed/QHH3iSeDBLo', ); }); - it('converts www.youtube video url to embedded', function() { + it('converts www.youtube video url to embedded', function () { insertVideo(this.tooltip, 'http://www.youtube.com/watch?v=QHH3iSeDBLo'); expect(this.container.querySelector('.ql-video').src).toContain( 'http://www.youtube.com/embed/QHH3iSeDBLo', ); }); - it('converts m.youtube video url to embedded', function() { + it('converts m.youtube video url to embedded', function () { insertVideo(this.tooltip, 'http://m.youtube.com/watch?v=QHH3iSeDBLo'); expect(this.container.querySelector('.ql-video').src).toContain( 'http://www.youtube.com/embed/QHH3iSeDBLo', ); }); - it('preserves youtube video url protocol', function() { + it('preserves youtube video url protocol', function () { insertVideo(this.tooltip, 'https://m.youtube.com/watch?v=QHH3iSeDBLo'); expect(this.container.querySelector('.ql-video').src).toContain( 'https://www.youtube.com/embed/QHH3iSeDBLo', ); }); - it('uses https as default youtube video url protocol', function() { + it('uses https as default youtube video url protocol', function () { insertVideo(this.tooltip, 'youtube.com/watch?v=QHH3iSeDBLo'); expect(this.container.querySelector('.ql-video').src).toContain( 'https://www.youtube.com/embed/QHH3iSeDBLo', ); }); - it('converts vimeo video url to embedded', function() { + it('converts vimeo video url to embedded', function () { insertVideo(this.tooltip, 'http://vimeo.com/47762693'); expect(this.container.querySelector('.ql-video').src).toContain( 'http://player.vimeo.com/video/47762693/', ); }); - it('converts www.vimeo video url to embedded', function() { + it('converts www.vimeo video url to embedded', function () { insertVideo(this.tooltip, 'http://www.vimeo.com/47762693'); expect(this.container.querySelector('.ql-video').src).toContain( 'http://player.vimeo.com/video/47762693/', ); }); - it('preserves vimeo video url protocol', function() { + it('preserves vimeo video url protocol', function () { insertVideo(this.tooltip, 'https://www.vimeo.com/47762693'); expect(this.container.querySelector('.ql-video').src).toContain( 'https://player.vimeo.com/video/47762693/', ); }); - it('uses https as default vimeo video url protocol', function() { + it('uses https as default vimeo video url protocol', function () { insertVideo(this.tooltip, 'vimeo.com/47762693'); expect(this.container.querySelector('.ql-video').src).toContain( 'https://player.vimeo.com/video/47762693/', diff --git a/test/unit/ui/picker.js b/test/unit/ui/picker.js index 986a72eee1..0218495d36 100644 --- a/test/unit/ui/picker.js +++ b/test/unit/ui/picker.js @@ -1,14 +1,14 @@ import Picker from '../../../ui/picker'; -describe('Picker', function() { - beforeEach(function() { +describe('Picker', function () { + beforeEach(function () { this.container.innerHTML = ''; this.pickerSelectorInstance = new Picker(this.container.firstChild); this.pickerSelector = this.container.querySelector('.ql-picker'); }); - it('initialization', function() { + it('initialization', function () { expect(this.container.querySelector('.ql-picker')).toBeTruthy(); expect(this.container.querySelector('.ql-active')).toBeFalsy(); expect( @@ -24,7 +24,7 @@ describe('Picker', function() { ); }); - it('escape charcters', function() { + it('escape charcters', function () { const select = document.createElement('select'); const option = document.createElement('option'); this.container.appendChild(select); @@ -35,14 +35,14 @@ describe('Picker', function() { expect(select.querySelector(`option[value="${value}"]`)).toEqual(option); }); - it('label is initialized with the correct aria attributes', function() { + it('label is initialized with the correct aria attributes', function () { expect( this.pickerSelector .querySelector('.ql-picker-label') .getAttribute('aria-expanded'), ).toEqual('false'); - const optionsId = this.pickerSelector.querySelector('.ql-picker-options') - .id; + const optionsId = + this.pickerSelector.querySelector('.ql-picker-options').id; expect( this.pickerSelector .querySelector('.ql-picker-label') @@ -50,7 +50,7 @@ describe('Picker', function() { ).toEqual(optionsId); }); - it('options container is initialized with the correct aria attributes', function() { + it('options container is initialized with the correct aria attributes', function () { expect( this.pickerSelector .querySelector('.ql-picker-options') @@ -68,7 +68,7 @@ describe('Picker', function() { ).toEqual(-1); }); - it('aria attributes toggle correctly when the picker is opened via enter key', function() { + it('aria attributes toggle correctly when the picker is opened via enter key', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' })); expect(pickerLabel.getAttribute('aria-expanded')).toEqual('true'); @@ -79,7 +79,7 @@ describe('Picker', function() { ).toEqual('false'); }); - it('aria attributes toggle correctly when the picker is opened via mousedown', function() { + it('aria attributes toggle correctly when the picker is opened via mousedown', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.dispatchEvent( new Event('mousedown', { @@ -96,7 +96,7 @@ describe('Picker', function() { ).toEqual('false'); }); - it('aria attributes toggle correctly when an item is selected via click', function() { + it('aria attributes toggle correctly when an item is selected via click', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.click(); @@ -114,7 +114,7 @@ describe('Picker', function() { ); }); - it('aria attributes toggle correctly when an item is selected via enter', function() { + it('aria attributes toggle correctly when an item is selected via enter', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.click(); const pickerItem = this.pickerSelector.querySelector('.ql-picker-item'); @@ -130,7 +130,7 @@ describe('Picker', function() { ); }); - it('aria attributes toggle correctly when the picker is closed via clicking on the label again', function() { + it('aria attributes toggle correctly when the picker is closed via clicking on the label again', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.click(); pickerLabel.click(); @@ -142,7 +142,7 @@ describe('Picker', function() { ).toEqual('true'); }); - it('aria attributes toggle correctly when the picker is closed via escaping out of it', function() { + it('aria attributes toggle correctly when the picker is closed via escaping out of it', function () { const pickerLabel = this.pickerSelector.querySelector('.ql-picker-label'); pickerLabel.click(); pickerLabel.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })); @@ -154,7 +154,7 @@ describe('Picker', function() { ).toEqual('true'); }); - afterEach(function() { + afterEach(function () { this.pickerSelectorInstance = null; }); });