From 7d3f9a0630e1be01df84b57a5c720033007f720f Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 21:59:09 +0100 Subject: [PATCH 1/8] Fix eslint config for typescript --- pnpm-lock.yaml | 213 +++++++++++++++++++++++++++++++++++++++--- test-app/.eslintrc.js | 15 ++- test-app/package.json | 2 + 3 files changed, 211 insertions(+), 19 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 939ea943..7c24b851 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,6 +106,8 @@ importers: '@types/jquery': ^3.3.31 '@types/qunit': ^2.11.1 '@types/rsvp': ^4.0.3 + '@typescript-eslint/eslint-plugin': ^6.18.1 + '@typescript-eslint/parser': ^6.18.1 broccoli-asset-rev: ^3.0.0 coveralls: ^3.0.0 ember-auto-import: ^2.4.1 @@ -176,6 +178,8 @@ importers: '@types/jquery': 3.5.16 '@types/qunit': 2.19.4 '@types/rsvp': 4.0.4 + '@typescript-eslint/eslint-plugin': 6.18.1_l5rnfrnsogonklwz3mvufhz6r4 + '@typescript-eslint/parser': 6.18.1_vgl77cfdswitgr47lm5swmv43m broccoli-asset-rev: 3.0.0 coveralls: 3.1.1 ember-auto-import: 2.6.1_webpack@5.76.3 @@ -1591,7 +1595,7 @@ packages: js-string-escape: 1.0.1 lodash: 4.17.21 resolve-package-path: 4.0.3 - semver: 7.3.8 + semver: 7.5.4 typescript-memoize: 1.1.1 dev: true @@ -1605,7 +1609,7 @@ packages: js-string-escape: 1.0.1 lodash: 4.17.21 resolve-package-path: 4.0.3 - semver: 7.3.8 + semver: 7.5.4 typescript-memoize: 1.1.1 /@embroider/test-setup/1.8.3: @@ -1643,6 +1647,11 @@ packages: eslint-visitor-keys: 3.3.0 dev: true + /@eslint-community/regexpp/4.10.0: + resolution: {integrity: sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: true + /@eslint-community/regexpp/4.4.1: resolution: {integrity: sha512-BISJ6ZE4xQsuL/FmsyRaiffpq977bMlsKfGHTQrOGFErfByxIe6iZTxPf/00Zon9b9a7iUykfQwejN3s2ZW/Bw==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} @@ -2392,7 +2401,7 @@ packages: resolution: {integrity: sha512-fa7GkppZVEByMWGbTtE5MbmXWJTVbrjjaS8K6uQj+XtuuUv1fsuPAxhygfqLmsb/Ufb3CV8deFCpiMfAgi00Sw==} dependencies: '@types/estree': 0.0.51 - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.15 dev: true /@types/estree/0.0.39: @@ -2470,8 +2479,8 @@ packages: dependencies: '@types/sizzle': 2.3.3 - /@types/json-schema/7.0.11: - resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} + /@types/json-schema/7.0.15: + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true /@types/keyv/3.1.4: @@ -2521,6 +2530,10 @@ packages: resolution: {integrity: sha512-J3Ol++HCC7/hwZhanDvggFYU/GtxHxE/e7cGRWxR04BF7Tt3TqJZ84BkzQgDxmX0uu8IagiyfmfoUlBACh2Ilg==} dev: true + /@types/semver/7.5.6: + resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} + dev: true + /@types/serve-static/1.15.1: resolution: {integrity: sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==} dependencies: @@ -2552,6 +2565,138 @@ packages: '@types/yargs-parser': 21.0.0 dev: true + /@typescript-eslint/eslint-plugin/6.18.1_l5rnfrnsogonklwz3mvufhz6r4: + resolution: {integrity: sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@eslint-community/regexpp': 4.10.0 + '@typescript-eslint/parser': 6.18.1_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/scope-manager': 6.18.1 + '@typescript-eslint/type-utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/visitor-keys': 6.18.1 + debug: 4.3.4 + eslint: 8.36.0 + graphemer: 1.4.0 + ignore: 5.2.4 + natural-compare: 1.4.0 + semver: 7.5.4 + ts-api-utils: 1.0.3_typescript@4.9.5 + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/parser/6.18.1_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/scope-manager': 6.18.1 + '@typescript-eslint/types': 6.18.1 + '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 + '@typescript-eslint/visitor-keys': 6.18.1 + debug: 4.3.4 + eslint: 8.36.0 + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/scope-manager/6.18.1: + resolution: {integrity: sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==} + engines: {node: ^16.0.0 || >=18.0.0} + dependencies: + '@typescript-eslint/types': 6.18.1 + '@typescript-eslint/visitor-keys': 6.18.1 + dev: true + + /@typescript-eslint/type-utils/6.18.1_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 + '@typescript-eslint/utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m + debug: 4.3.4 + eslint: 8.36.0 + ts-api-utils: 1.0.3_typescript@4.9.5 + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/types/6.18.1: + resolution: {integrity: sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==} + engines: {node: ^16.0.0 || >=18.0.0} + dev: true + + /@typescript-eslint/typescript-estree/6.18.1_typescript@4.9.5: + resolution: {integrity: sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 6.18.1 + '@typescript-eslint/visitor-keys': 6.18.1 + debug: 4.3.4 + globby: 11.1.0 + is-glob: 4.0.3 + minimatch: 9.0.3 + semver: 7.5.4 + ts-api-utils: 1.0.3_typescript@4.9.5 + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/utils/6.18.1_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==} + engines: {node: ^16.0.0 || >=18.0.0} + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0_eslint@8.36.0 + '@types/json-schema': 7.0.15 + '@types/semver': 7.5.6 + '@typescript-eslint/scope-manager': 6.18.1 + '@typescript-eslint/types': 6.18.1 + '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 + eslint: 8.36.0 + semver: 7.5.4 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + + /@typescript-eslint/visitor-keys/6.18.1: + resolution: {integrity: sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==} + engines: {node: ^16.0.0 || >=18.0.0} + dependencies: + '@typescript-eslint/types': 6.18.1 + eslint-visitor-keys: 3.4.3 + dev: true + /@webassemblyjs/ast/1.11.1: resolution: {integrity: sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==} dependencies: @@ -4472,6 +4617,12 @@ packages: balanced-match: 1.0.2 concat-map: 0.0.1 + /brace-expansion/2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: true + /braces/1.8.5: resolution: {integrity: sha512-xU7bpz2ytJl1bH9cgIurjpg/n8Gohy9GTw81heDYLJQ4RU60dlyJsa+atVF2pI0yMMvKxI9HkKwjePCj5XI1hw==} engines: {node: '>=0.10.0'} @@ -6153,7 +6304,7 @@ packages: postcss-modules-values: 4.0.0_postcss@8.4.21 postcss-value-parser: 4.2.0 schema-utils: 3.1.1 - semver: 7.3.8 + semver: 7.5.4 webpack: 5.76.3 dev: true @@ -6680,7 +6831,7 @@ packages: mkdirp: 0.5.6 resolve-package-path: 3.1.0 rimraf: 2.7.1 - semver: 7.3.8 + semver: 7.5.4 symlink-or-copy: 1.3.1 typescript-memoize: 1.1.1 walk-sync: 0.3.4 @@ -7467,7 +7618,7 @@ packages: lodash: 4.17.21 package-json: 6.5.0 remote-git-tags: 3.0.0 - semver: 7.3.8 + semver: 7.5.4 transitivePeerDependencies: - encoding dev: true @@ -7835,6 +7986,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /eslint-visitor-keys/3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + /eslint/8.36.0: resolution: {integrity: sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -7895,7 +8051,7 @@ packages: dependencies: acorn: 8.8.2 acorn-jsx: 5.3.2_acorn@8.8.2 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /esprima/3.0.0: @@ -9204,6 +9360,10 @@ packages: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} dev: true + /graphemer/1.4.0: + resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + dev: true + /growl/1.10.3: resolution: {integrity: sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==} engines: {node: '>=4.x'} @@ -11835,6 +11995,13 @@ packages: dependencies: brace-expansion: 1.1.11 + /minimatch/9.0.3: + resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimist/0.0.8: resolution: {integrity: sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q==} dev: true @@ -12109,7 +12276,7 @@ packages: dependencies: growly: 1.3.0 is-wsl: 2.2.0 - semver: 7.3.8 + semver: 7.5.4 shellwords: 0.1.1 uuid: 8.3.2 which: 2.0.2 @@ -12197,7 +12364,7 @@ packages: engines: {node: '>=10'} dependencies: hosted-git-info: 4.1.0 - semver: 7.3.8 + semver: 7.5.4 validate-npm-package-name: 3.0.0 dev: true @@ -14098,7 +14265,7 @@ packages: resolution: {integrity: sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==} engines: {node: '>= 8.9.0'} dependencies: - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.15 ajv: 6.12.6 ajv-keywords: 3.5.2_ajv@6.12.6 dev: true @@ -14107,7 +14274,7 @@ packages: resolution: {integrity: sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==} engines: {node: '>= 10.13.0'} dependencies: - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.15 ajv: 6.12.6 ajv-keywords: 3.5.2_ajv@6.12.6 dev: true @@ -14116,7 +14283,7 @@ packages: resolution: {integrity: sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg==} engines: {node: '>= 12.13.0'} dependencies: - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.15 ajv: 8.12.0 ajv-formats: 2.1.1_ajv@8.12.0 ajv-keywords: 5.1.0_ajv@8.12.0 @@ -14137,6 +14304,13 @@ packages: dependencies: lru-cache: 6.0.0 + /semver/7.5.4: + resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + /send/0.18.0: resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} engines: {node: '>= 0.8.0'} @@ -15428,6 +15602,15 @@ packages: resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} dev: true + /ts-api-utils/1.0.3_typescript@4.9.5: + resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} + engines: {node: '>=16.13.0'} + peerDependencies: + typescript: '>=4.2.0' + dependencies: + typescript: 4.9.5 + dev: true + /tslib/1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true @@ -15838,7 +16021,7 @@ packages: resolution: {integrity: sha512-nd2HUpKc6RWblPZQ2GDuI65sxJ2n/UqZwSBVtj64xlWjMx0m7ZB2m9b2JS3v1f+n9VWH/dd1CMhkHfP6pIdckA==} dependencies: resolve-package-path: 3.1.0 - semver: 7.3.8 + semver: 7.5.4 dev: true /value-or-function/3.0.0: diff --git a/test-app/.eslintrc.js b/test-app/.eslintrc.js index f3cbd56d..9385fd44 100644 --- a/test-app/.eslintrc.js +++ b/test-app/.eslintrc.js @@ -2,7 +2,7 @@ module.exports = { root: true, - parser: '@babel/eslint-parser', + parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2021, sourceType: 'module', @@ -10,9 +10,6 @@ module.exports = { legacyDecorators: true, }, requireConfigFile: false, - babelOptions: { - plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]], - }, }, plugins: ['ember'], extends: [ @@ -28,6 +25,16 @@ module.exports = { 'no-console': ['error', { allow: ['warn', 'error'] }], }, overrides: [ + { + files: ['**/*.ts', '**/*.gts'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + // Add any custom rules here + }, + }, // node files { files: [ diff --git a/test-app/package.json b/test-app/package.json index bc3f5b25..f62f52b5 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -61,6 +61,8 @@ "@types/jquery": "^3.3.31", "@types/qunit": "^2.11.1", "@types/rsvp": "^4.0.3", + "@typescript-eslint/eslint-plugin": "^6.18.1", + "@typescript-eslint/parser": "^6.18.1", "broccoli-asset-rev": "^3.0.0", "coveralls": "^3.0.0", "ember-auto-import": "^2.4.1", From 78c418e92de74e6456260fe283c9d64d3a24871e Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:00:32 +0100 Subject: [PATCH 2/8] lint:js:fix --- test-app/tests/acceptance/composition-test.ts | 6 +- .../tests/acceptance/rfc268-actions-test.ts | 6 +- .../rfc268-default-properties-test.ts | 24 +- .../rfc268-extension-helpers-test.ts | 15 +- test-app/tests/acceptance/rfc268-test.ts | 2 +- test-app/tests/helpers/index.ts | 22 +- test-app/tests/integration/actions-test.ts | 186 ++++++----- .../comma-separated-selector-test.ts | 8 +- .../integration/default-properties-test.ts | 29 +- .../tests/unit/-private/composition-test.ts | 77 ++--- .../unit/-private/properties/alias-test.ts | 143 ++++----- .../-private/properties/attribute-test.ts | 37 +-- .../-private/properties/blurrable-test.ts | 124 ++++---- .../-private/properties/click-on-text-test.ts | 104 ++++--- .../-private/properties/clickable-test.ts | 116 ++++--- .../-private/properties/collection-test.ts | 294 +++++++++--------- .../unit/-private/properties/contains-test.ts | 101 +++--- .../unit/-private/properties/count-test.ts | 52 ++-- .../unit/-private/properties/create-test.ts | 14 +- .../unit/-private/properties/dsl-test.ts | 44 +-- .../unit/-private/properties/fillable-test.ts | 174 ++++++----- .../-private/properties/focusable-test.ts | 110 ++++--- .../unit/-private/properties/getter-test.ts | 58 ++-- .../-private/properties/has-class-test.ts | 92 +++--- .../-private/properties/is-hidden-test.ts | 76 ++--- .../-private/properties/is-present-test.ts | 77 ++--- .../-private/properties/is-visible-test.ts | 77 ++--- .../-private/properties/native-getter-test.ts | 14 +- .../-private/properties/not-has-class-test.ts | 84 ++--- .../unit/-private/properties/property-test.ts | 96 +++--- .../unit/-private/properties/text-test.ts | 130 ++++---- .../-private/properties/triggerable-test.ts | 120 ++++--- .../unit/-private/properties/value-test.ts | 92 +++--- .../-private/properties/visitable-test.ts | 71 +++-- test-app/tests/unit/adapters/helpers.ts | 12 +- test-app/tests/unit/adapters/rfc268-test.ts | 53 ++-- .../tests/unit/extend/find-element-test.ts | 80 +++-- .../extend/find-element-with-assert-test.ts | 99 +++--- test-app/tests/unit/extend/find-many-test.ts | 83 +++-- test-app/tests/unit/extend/find-one-test.ts | 93 +++--- test-app/types/dummy/index.d.ts | 1 - test-app/types/loader.js/require.d.ts | 3 +- 42 files changed, 1683 insertions(+), 1416 deletions(-) diff --git a/test-app/tests/acceptance/composition-test.ts b/test-app/tests/acceptance/composition-test.ts index 0a94a70b..b257ef7c 100644 --- a/test-app/tests/acceptance/composition-test.ts +++ b/test-app/tests/acceptance/composition-test.ts @@ -12,7 +12,7 @@ import { clickOnText, } from 'ember-cli-page-object'; -let keyboard = create({ +const keyboard = create({ scope: '.keyboard', numbers: collection('.numbers button', { text: text(), @@ -26,11 +26,11 @@ let keyboard = create({ equal: clickable('button', { scope: '.operators', at: 2 }), }); -let screenPage = create({ +const screenPage = create({ value: value('.screen input'), fillValue: fillable('.screen input'), }); -let page = create({ +const page = create({ visit: visitable('/calculator'), keys: keyboard, screen: screenPage, diff --git a/test-app/tests/acceptance/rfc268-actions-test.ts b/test-app/tests/acceptance/rfc268-actions-test.ts index 01f25744..e2aeb4c0 100644 --- a/test-app/tests/acceptance/rfc268-actions-test.ts +++ b/test-app/tests/acceptance/rfc268-actions-test.ts @@ -18,7 +18,7 @@ import { settled, waitUntil } from '@ember/test-helpers'; module('Acceptance | actions [rfc268]', function (hooks) { setupApplicationTest(hooks); - let page = create({ + const page = create({ visit: visitable('/calculator'), keys: { clickOn: clickOnText('.numbers'), @@ -116,7 +116,7 @@ module('Acceptance | actions [rfc268]', function (hooks) { await page.keys.clickOn('2'); await page.keys.sum(); await page.keys.clickOn('3'); - let promise = page.keys.asyncEqual(); + const promise = page.keys.asyncEqual(); await waitUntil(() => page.isLoading); @@ -155,7 +155,7 @@ module('Acceptance | actions [rfc268]', function (hooks) { }); test('fill in by attribute', async function (assert) { - let page = create({ + const page = create({ visit: visitable('/inputs'), fillIn: fillable(), }); diff --git a/test-app/tests/acceptance/rfc268-default-properties-test.ts b/test-app/tests/acceptance/rfc268-default-properties-test.ts index 281c43b3..c1000de0 100644 --- a/test-app/tests/acceptance/rfc268-default-properties-test.ts +++ b/test-app/tests/acceptance/rfc268-default-properties-test.ts @@ -2,28 +2,28 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from '../helpers'; import PageObject from 'ember-cli-page-object'; -module('Acceptance | default properties [rfc268]', function(hooks) { +module('Acceptance | default properties [rfc268]', function (hooks) { setupApplicationTest(hooks); - test('Adds default properties', async function(assert) { - let page = PageObject.create({ + test('Adds default properties', async function (assert) { + const page = PageObject.create({ visit: PageObject.visitable('/calculator'), one: { - scope: '.numbers button:nth-of-type(1)' + scope: '.numbers button:nth-of-type(1)', }, screen: { scope: '.screen', expression: { - scope: 'input' + scope: 'input', }, result: { - scope: '.result' - } - } + scope: '.result', + }, + }, }); await page.visit(); @@ -39,8 +39,8 @@ module('Acceptance | default properties [rfc268]', function(hooks) { assert.ok(!page.screen.isHidden, 'isHidden'); }); - test('Overrides default properties', async function(assert) { - let page = PageObject.create({ + test('Overrides default properties', async function (assert) { + const page = PageObject.create({ dummy: { click() { return 'click'; @@ -62,8 +62,8 @@ module('Acceptance | default properties [rfc268]', function(hooks) { }, text() { return 'text'; - } - } + }, + }, }); assert.equal(page.dummy.click(), 'click'); diff --git a/test-app/tests/acceptance/rfc268-extension-helpers-test.ts b/test-app/tests/acceptance/rfc268-extension-helpers-test.ts index d99ad5f2..5b987395 100644 --- a/test-app/tests/acceptance/rfc268-extension-helpers-test.ts +++ b/test-app/tests/acceptance/rfc268-extension-helpers-test.ts @@ -1,18 +1,15 @@ import { module, test } from 'qunit'; import { setupApplicationTest } from '../helpers'; -import { - create, - visitable, -} from 'ember-cli-page-object'; +import { create, visitable } from 'ember-cli-page-object'; import { findElement, - findElementWithAssert + findElementWithAssert, } from 'ember-cli-page-object/extend'; -module('Acceptance | extends [rfc268]', function(hooks) { +module('Acceptance | extends [rfc268]', function (hooks) { setupApplicationTest(hooks); - let page = create({ + const page = create({ visit: visitable('/calculator'), findElement(this: any, selector: string) { @@ -21,10 +18,10 @@ module('Acceptance | extends [rfc268]', function(hooks) { findElementWithAssert(this: any, selector: string) { return findElementWithAssert(this, selector); - } + }, }); - test('finds an element in the DOM', async function(assert) { + test('finds an element in the DOM', async function (assert) { await page.visit(); let element = page.findElement('.screen'); diff --git a/test-app/tests/acceptance/rfc268-test.ts b/test-app/tests/acceptance/rfc268-test.ts index 06916c53..c20b593e 100644 --- a/test-app/tests/acceptance/rfc268-test.ts +++ b/test-app/tests/acceptance/rfc268-test.ts @@ -5,7 +5,7 @@ import { setupApplicationTest } from '../helpers'; module('Acceptance | rfc268', function (hooks) { setupApplicationTest(hooks); - let page = create({ + const page = create({ visit: visitable('/calculator'), screen: value('.screen input'), }); diff --git a/test-app/tests/helpers/index.ts b/test-app/tests/helpers/index.ts index 93e1c3f7..5ad5eeba 100644 --- a/test-app/tests/helpers/index.ts +++ b/test-app/tests/helpers/index.ts @@ -13,9 +13,9 @@ export interface TestContext extends DefaultTestContext { createTemplate( template: string, options?: { - useAlternateContainer?: boolean + useAlternateContainer?: boolean; } - ): Promise + ): Promise; findExternal(selector: string): T | null; } @@ -32,18 +32,18 @@ function getAlternateContainer() { export function setupApplicationTest(hooks: NestedHooks) { upstreamSetupApplicationTest(hooks); - hooks.afterEach(function() { + hooks.afterEach(function () { getAlternateContainer().innerHTML = ''; - }) + }); } export function setupRenderingTest(hooks: NestedHooks) { upstreamSetupRenderingTest(hooks); - hooks.beforeEach(function(this: TestContext) { + hooks.beforeEach(function (this: TestContext) { const testContext = this; - this.createTemplate = function(template, options): Promise { + this.createTemplate = function (template, options): Promise { if (options && options.useAlternateContainer) { // The idea is to render the HTML outside the testing container so we // render an empty component @@ -54,16 +54,16 @@ export function setupRenderingTest(hooks: NestedHooks) { } return render(hbs`{{html-render html=this.raw}}`); - } + }; - this.findExternal = function(selector: string) { + this.findExternal = function (selector: string) { return getAlternateContainer().querySelector(selector); - } + }; }); - hooks.afterEach(function() { + hooks.afterEach(function () { getAlternateContainer().innerHTML = ''; - }) + }); } export { setupTest } from 'ember-qunit'; diff --git a/test-app/tests/integration/actions-test.ts b/test-app/tests/integration/actions-test.ts index 2815a7da..8961c76e 100644 --- a/test-app/tests/integration/actions-test.ts +++ b/test-app/tests/integration/actions-test.ts @@ -2,12 +2,9 @@ import 'qunit-dom'; import { run } from '@ember/runloop'; import { module, test } from 'qunit'; -import { render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { setupRenderingTest } from '../helpers'; -import { - createCalculatorTemplate, - createInputsTemplate -} from './test-helper'; +import { createCalculatorTemplate, createInputsTemplate } from './test-helper'; import { create, @@ -24,24 +21,24 @@ import { count, isHidden, isPresent, - isVisible + isVisible, } from 'ember-cli-page-object'; import { alias } from 'ember-cli-page-object/macros'; -const button = function(scope: string) { +const button = function (scope: string) { return { scope, click: clickable(), - text: text() + text: text(), }; }; const page = create({ numbers: collection('.numbers button', { click: clickable(), - text: text() + text: text(), }), clickOnNumber: clickOnText('.numbers'), @@ -51,11 +48,11 @@ const page = create({ plus: button('button:nth-of-type(1)'), minus: button('button:nth-of-type(2)'), - equals: button('button:nth-of-type(3)') + equals: button('button:nth-of-type(3)'), }, screen: { - text: text('.screen') + text: text('.screen'), }, clickOn: clickOnText('', { scope: '.calculator' }), @@ -63,7 +60,7 @@ const page = create({ calculator: { scope: '.calculator', - clickOn: clickOnText() + clickOn: clickOnText(), }, clickOnAlias: alias('clickOn', { chainable: true }), @@ -88,43 +85,37 @@ const page = create({ count: count(), isHidden: isHidden(), isPresent: isPresent(), - isVisible: isVisible() - } + isVisible: isVisible(), + }, }); -module('Integration | actions', function(hooks) { +module('Integration | actions', function (hooks) { setupRenderingTest(hooks); - test('Actions work when defined inside collections', async function(assert) { - let template = createCalculatorTemplate(); + test('Actions work when defined inside collections', async function (assert) { + const template = createCalculatorTemplate(); await render(template); - await page - .numbers - .objectAt(0) - .click(); + await page.numbers.objectAt(0).click(); assert.equal(page.screen.text, '1'); }); - test('Chaining of custom actions works', async function(assert) { - let template = createCalculatorTemplate(); + test('Chaining of custom actions works', async function (assert) { + const template = createCalculatorTemplate(); await render(template); - await page - .clickOnNumber('1') - .clickOnNumber('2') - .clickOnNumber('3'); + await page.clickOnNumber('1').clickOnNumber('2').clickOnNumber('3'); assert.equal(page.screen.text, '123'); }); - test('Chaining of actions on the root works', async function(assert) { - let template = createCalculatorTemplate(); + test('Chaining of actions on the root works', async function (assert) { + const template = createCalculatorTemplate(); - await render(template) + await render(template); await page .clickOn('1') @@ -132,20 +123,17 @@ module('Integration | actions', function(hooks) { .clickOn('4') .clickOn('-') .clickOn('2') - .operators - .equals - .click(); + .operators.equals.click(); assert.equal(page.screen.text, '3'); }); - test('Chaining of actions on a component works', async function(assert) { - let template = createCalculatorTemplate(); + test('Chaining of actions on a component works', async function (assert) { + const template = createCalculatorTemplate(); - await render(template) + await render(template); - await page - .calculator + await page.calculator .clickOn('1') .clickOn('+') .clickOn('5') @@ -156,34 +144,28 @@ module('Integration | actions', function(hooks) { assert.equal(page.screen.text, '2'); }); - test('Chaining of aliased root actions works', async function(assert) { - let template = createCalculatorTemplate(); + test('Chaining of aliased root actions works', async function (assert) { + const template = createCalculatorTemplate(); - await render(template) + await render(template); - await page - .clickOnAlias('1') - .clickOnAlias('4'); + await page.clickOnAlias('1').clickOnAlias('4'); assert.equal(page.screen.text, '14'); }); - test('Chaining of aliased component actions works', async function(assert) { - let template = createCalculatorTemplate(); + test('Chaining of aliased component actions works', async function (assert) { + const template = createCalculatorTemplate(); - await render(template) + await render(template); - await page - .clickOn('1') - .clickPlusAlias() - .clickOn('4') - .clickEqualsAlias(); + await page.clickOn('1').clickPlusAlias().clickOn('4').clickEqualsAlias(); assert.equal(page.screen.text, '5'); }); - test('fill in by attribute', async function(assert) { - let template = createInputsTemplate(); + test('fill in by attribute', async function (assert) { + const template = createInputsTemplate(); await render(template); @@ -240,40 +222,76 @@ module('Integration | actions', function(hooks) { assert.dom('.select5-value').hasValue('select 5 option 2'); }); - test('Queries and actions handle non-existant elements correctly', async function(assert) { + test('Queries and actions handle non-existant elements correctly', async function (assert) { assert.expect(13); - let message = /Element not found./; - let template = createCalculatorTemplate(); + const message = /Element not found./; + const template = createCalculatorTemplate(); await render(template); run(() => { - assert.throws(() => page.nonExistant.attribute, message, 'attribute query did not throw an error'); + assert.throws( + () => page.nonExistant.attribute, + message, + 'attribute query did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.clickOnText('qux'), message, 'clickOnText action did not throw an error'); + assert.throws( + () => page.nonExistant.clickOnText('qux'), + message, + 'clickOnText action did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.clickable(), message, 'clickable action did not throw an error'); + assert.throws( + () => page.nonExistant.clickable(), + message, + 'clickable action did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.contains('something'), message, 'contains action did not throw an error'); + assert.throws( + () => page.nonExistant.contains('something'), + message, + 'contains action did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.fillable('baz'), message, 'fillable action did not throw an error'); + assert.throws( + () => page.nonExistant.fillable('baz'), + message, + 'fillable action did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.hasClass, message, 'hasClass query did not throw an error'); + assert.throws( + () => page.nonExistant.hasClass, + message, + 'hasClass query did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.notHasClass, message, 'notHasClass query did not throw an error'); + assert.throws( + () => page.nonExistant.notHasClass, + message, + 'notHasClass query did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.text, message, 'text query did not throw an error'); + assert.throws( + () => page.nonExistant.text, + message, + 'text query did not throw an error' + ); }); run(() => { - assert.throws(() => page.nonExistant.value, message, 'value query did not throw an error'); + assert.throws( + () => page.nonExistant.value, + message, + 'value query did not throw an error' + ); }); assert.equal(page.nonExistant.count, 0); @@ -283,17 +301,17 @@ module('Integration | actions', function(hooks) { }); }); -module('Integration | actions', function(hooks) { +module('Integration | actions', function (hooks) { setupRenderingTest(hooks); - hooks.afterEach(function() { + hooks.afterEach(function () { const element = document.getElementById('alternate-ember-testing'); if (element) { element.innerHTML = ''; } }); - test('looks for elements outside the testing container', async function(assert) { + test('looks for elements outside the testing container', async function (assert) { assert.expect(0); const element = document.getElementById('alternate-ember-testing'); @@ -301,19 +319,22 @@ module('Integration | actions', function(hooks) { element.innerHTML = ''; } - let page = create({ - clickOnText: clickOnText('button', { testContainer: '#alternate-ember-testing' }), - clickable: clickable('button', { testContainer: '#alternate-ember-testing' }), - fillable: fillable('input', { testContainer: '#alternate-ember-testing' }) + const page = create({ + clickOnText: clickOnText('button', { + testContainer: '#alternate-ember-testing', + }), + clickable: clickable('button', { + testContainer: '#alternate-ember-testing', + }), + fillable: fillable('input', { + testContainer: '#alternate-ember-testing', + }), }); - await page - .clickOnText('lorem') - .clickable() - .fillable('foo'); + await page.clickOnText('lorem').clickable().fillable('foo'); }); - test('looks for elements within test container specified at node level', async function(assert) { + test('looks for elements within test container specified at node level', async function (assert) { assert.expect(0); const element = document.getElementById('alternate-ember-testing'); @@ -321,16 +342,13 @@ module('Integration | actions', function(hooks) { element.innerHTML = ''; } - let page = create({ + const page = create({ testContainer: '#alternate-ember-testing', clickOnText: clickOnText('button'), clickable: clickable('button'), - fillable: fillable('input') + fillable: fillable('input'), }); - await page - .clickOnText('lorem') - .clickable() - .fillable('foo'); + await page.clickOnText('lorem').clickable().fillable('foo'); }); }); diff --git a/test-app/tests/integration/comma-separated-selector-test.ts b/test-app/tests/integration/comma-separated-selector-test.ts index 26e1d477..97887d18 100644 --- a/test-app/tests/integration/comma-separated-selector-test.ts +++ b/test-app/tests/integration/comma-separated-selector-test.ts @@ -8,7 +8,7 @@ module('comma separated selectors', function (hooks) { setupRenderingTest(hooks); test('usage in `definition scope` leads to error', async function (assert) { - let page = create({ + const page = create({ scope: '.A, .B', }); @@ -23,7 +23,7 @@ module('comma separated selectors', function (hooks) { }); test('usage in a `property scope` leads to error', async function (assert) { - let page = create({ + const page = create({ text: text('.A, .B'), }); @@ -38,7 +38,7 @@ module('comma separated selectors', function (hooks) { }); test('usage in `property custom scope` leads to error', async function (assert) { - let page = create({ + const page = create({ text: text('.root', { scope: '.A, .B', }), @@ -57,7 +57,7 @@ module('comma separated selectors', function (hooks) { }); test("doesn't error when the selector contains text with comma", async function (assert) { - let page = create({ + const page = create({ clickOnButton: clickOnText('button'), }); diff --git a/test-app/tests/integration/default-properties-test.ts b/test-app/tests/integration/default-properties-test.ts index 644d0dab..a5587f2d 100644 --- a/test-app/tests/integration/default-properties-test.ts +++ b/test-app/tests/integration/default-properties-test.ts @@ -4,26 +4,23 @@ import { setupRenderingTest } from '../helpers'; import { createCalculatorTemplate } from './test-helper'; import { create } from 'ember-cli-page-object'; -module('Integration | default properties', function(hooks) { +module('Integration | default properties', function (hooks) { setupRenderingTest(hooks); - test('Adds default properties', async function(assert) { - let page = create({ + test('Adds default properties', async function (assert) { + const page = create({ one: { - scope: '.numbers button:nth-of-type(1)' + scope: '.numbers button:nth-of-type(1)', }, screen: { - scope: '.screen' - } + scope: '.screen', + }, }); await render(createCalculatorTemplate()); - await page - .clickOn('9') - .one - .click(); + await page.clickOn('9').one.click(); assert.equal(page.screen.text, '91', 'text'); assert.ok(page.screen.contains('91'), 'contains'); @@ -33,8 +30,8 @@ module('Integration | default properties', function(hooks) { assert.notOk(page.screen.isHidden, 'isHidden'); }); - test('Overrides default properties', function(assert) { - let page = create({ + test('Overrides default properties', function (assert) { + const page = create({ dummy: { click() { return 'click'; @@ -56,8 +53,8 @@ module('Integration | default properties', function(hooks) { }, text() { return 'text'; - } - } + }, + }, }); assert.equal(page.dummy.click(), 'click'); @@ -69,8 +66,8 @@ module('Integration | default properties', function(hooks) { assert.equal(page.dummy.text(), 'text'); }); - test('allows empty create', async function(assert) { - let page = create(); + test('allows empty create', async function (assert) { + const page = create(); await render(createCalculatorTemplate()); diff --git a/test-app/tests/unit/-private/composition-test.ts b/test-app/tests/unit/-private/composition-test.ts index 399b6609..ecbe8d3c 100644 --- a/test-app/tests/unit/-private/composition-test.ts +++ b/test-app/tests/unit/-private/composition-test.ts @@ -3,7 +3,7 @@ import { test, module } from 'qunit'; import { isPageObject, getPageObjectDefinition, -// @ts-expect-error no types for import path are provided + // @ts-expect-error no types for import path are provided } from 'ember-cli-page-object/-private/meta'; import { render, find } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; @@ -20,63 +20,63 @@ import { alias, getter } from 'ember-cli-page-object/macros'; module('Unit | composition', function () { test('each page object node stores its definition', function (assert) { - let definition = { + const definition = { foo: { bar: { get baz() { - return 'prop' - }, + return 'prop'; + }, }, }, }; - let page = create(definition); - let storedDef = getPageObjectDefinition(page); + const page = create(definition); + const storedDef = getPageObjectDefinition(page); assert.ok(storedDef); assert.deepEqual(storedDef, definition); - let fooDef = getPageObjectDefinition(page.foo); + const fooDef = getPageObjectDefinition(page.foo); assert.ok(fooDef); assert.deepEqual(fooDef, definition.foo); - let barDef = getPageObjectDefinition(page.foo.bar); + const barDef = getPageObjectDefinition(page.foo.bar); assert.ok(barDef); assert.deepEqual(barDef, definition.foo.bar); }); test('page objects can be composed from other page objects', function (assert) { - let definition = { + const definition = { foo: { bar: { - baz: 1 + baz: 1, }, }, }; - let page = create(definition); - let pageComposer = create({ + const page = create(definition); + const pageComposer = create({ somePage: page, }); assert.ok(pageComposer); assert.ok(pageComposer.somePage); - let pageComposerDef = getPageObjectDefinition(pageComposer); + const pageComposerDef = getPageObjectDefinition(pageComposer); assert.ok(pageComposerDef); assert.ok(isPageObject(pageComposerDef.somePage)); // we cant deep equal the definition since it contains a page object so we check the keys instead assert.deepEqual(Object.keys(pageComposerDef), ['somePage']); - let somePageStoredDef = getPageObjectDefinition(pageComposerDef.somePage); + const somePageStoredDef = getPageObjectDefinition(pageComposerDef.somePage); assert.deepEqual(somePageStoredDef, definition); }); test('page objects can be used as the definition to create', function (assert) { - let definition = { + const definition = { foo: 1, }; - let page = create(definition); + const page = create(definition); - let pageComposer = create(page); + const pageComposer = create(page); assert.ok(pageComposer); assert.ok(pageComposer.foo); @@ -84,19 +84,19 @@ module('Unit | composition', function () { }); test('page object composition supports many levels deep', function (assert) { - let definition = { + const definition = { foo: { bar: { get baz() { return 'prop'; - } + }, }, }, }; - let page = create(definition); + const page = create(definition); - let pageComposer = create({ + const pageComposer = create({ bar: { baz: page, }, @@ -105,14 +105,14 @@ module('Unit | composition', function () { assert.ok(pageComposer.bar.baz); // test that the definition is stored "as is" - let pageComposerDef = getPageObjectDefinition(pageComposer); + const pageComposerDef = getPageObjectDefinition(pageComposer); assert.ok(pageComposerDef); assert.ok(pageComposerDef.bar); assert.notOk(isPageObject(pageComposerDef.bar)); assert.ok(pageComposer.bar.baz); assert.ok(isPageObject(pageComposerDef.bar.baz)); - let bazDefiniton = getPageObjectDefinition(pageComposerDef.bar.baz); + const bazDefiniton = getPageObjectDefinition(pageComposerDef.bar.baz); assert.ok(bazDefiniton); pageComposerDef.bar.baz = bazDefiniton; // cant do a true deep equal without firing of page object selectors @@ -137,12 +137,12 @@ module('Unit | composition', function () { const bar = create({ foo }); assert.ok(bar); - let barDefinition = getPageObjectDefinition(bar); + const barDefinition = getPageObjectDefinition(bar); assert.ok(barDefinition); assert.ok(barDefinition.foo); assert.ok(isPageObject(barDefinition.foo)); - let fooDefFromBar = getPageObjectDefinition(bar.foo); + const fooDefFromBar = getPageObjectDefinition(bar.foo); assert.ok(fooDefFromBar); // cannot do a true deep equal since foo is a page object @@ -157,7 +157,10 @@ module('Unit | composition', function () { getPageObjectDefinition({}); assert.true(false); } catch (e) { - assert.strictEqual(e?.toString(), 'Error: cannot get the page object definition from a node that is not a page object'); + assert.strictEqual( + e?.toString(), + 'Error: cannot get the page object definition from a node that is not a page object' + ); } }); @@ -172,7 +175,7 @@ module('Unit | composition', function () { aliasedIsButtonVisible: alias('isButtonVisible'), }); - let page = create({ + const page = create({ scope: '.container', aliasPage: aliasPage, }); @@ -184,13 +187,13 @@ module('Unit | composition', function () { }); test('new pages can be composed from pages containing collections', async function (assert) { - let collectionPage = create({ + const collectionPage = create({ foo: collection('span', { text: text(), }), }); - let page = create({ + const page = create({ scope: '.container', collectionPage: collectionPage, }); @@ -208,7 +211,7 @@ module('Unit | composition', function () { const textPage = create({ spanText: text('span'), }); - let page = create({ + const page = create({ scope: '.container', collection: collection('li', textPage), }); @@ -228,7 +231,7 @@ module('Unit | composition', function () { const textPage = create({ spanText: text('span'), }); - let page = create({ + const page = create({ scope: '.container', collection: collection('li', { textPage: textPage, @@ -248,12 +251,12 @@ module('Unit | composition', function () { test("the composition of pages containing 'action' based descriptors is supported", async function (assert) { assert.expect(1); - let expectedSelector = 'input'; - let triggerPage = create({ + const expectedSelector = 'input'; + const triggerPage = create({ foo: triggerable('focus', expectedSelector), }); - let page = create({ + const page = create({ scope: '.container', triggerPage: triggerPage, }); @@ -277,7 +280,7 @@ module('Unit | composition', function () { return 'ipsum'; }), }); - let page = create({ + const page = create({ scope: '.container', getterPage: getterPage, }); @@ -286,11 +289,11 @@ module('Unit | composition', function () { }); test('the composition of pages containing a getter based attribute is supported', async function (assert) { - let inputPage = create({ + const inputPage = create({ foo: value('input'), }); - let page = create({ + const page = create({ scope: '.container', input: inputPage, }); diff --git a/test-app/tests/unit/-private/properties/alias-test.ts b/test-app/tests/unit/-private/properties/alias-test.ts index 3674762f..a381dc16 100644 --- a/test-app/tests/unit/-private/properties/alias-test.ts +++ b/test-app/tests/unit/-private/properties/alias-test.ts @@ -4,25 +4,22 @@ import { clickable, collection, isVisible, - text + text, } from 'ember-cli-page-object'; -import { - alias, - getter, -} from 'ember-cli-page-object/macros'; +import { alias, getter } from 'ember-cli-page-object/macros'; import { render, find, settled } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { module, test } from 'qunit'; -module('alias', function(hooks) { +module('alias', function (hooks) { setupRenderingTest(hooks); - test('can alias a top-level property', async function(assert) { + test('can alias a top-level property', async function (assert) { assert.expect(1); const page = create({ isButtonVisible: isVisible('button'), - aliasedIsButtonVisible: alias('isButtonVisible') + aliasedIsButtonVisible: alias('isButtonVisible'), }); await render(hbs``); @@ -30,18 +27,18 @@ module('alias', function(hooks) { assert.ok(page.aliasedIsButtonVisible); }); - test('can alias a top-level method', async function(assert) { + test('can alias a top-level method', async function (assert) { assert.expect(1); const expectedSelector = 'button'; const page = create({ clickButton: clickable(expectedSelector), - aliasedClickButton: alias('clickButton') + aliasedClickButton: alias('clickButton'), }); await render(hbs``); - find('button')!.addEventListener('click', function() { + find('button')!.addEventListener('click', function () { assert.ok(true); }); @@ -50,26 +47,26 @@ module('alias', function(hooks) { await settled(); }); - test('returns chainable object from top-level method', async function(assert) { + test('returns chainable object from top-level method', async function (assert) { assert.expect(1); const page = create({ clickButton: clickable('button'), - aliasedClickButton: alias('clickButton', { chainable: true }) + aliasedClickButton: alias('clickButton', { chainable: true }), }); await render(hbs``); - let ret = page.aliasedClickButton(); + const ret = page.aliasedClickButton(); assert.ok(ret.clickButton); - await settled() + await settled(); }); - test('can alias a top-level collection', async function(assert) { + test('can alias a top-level collection', async function (assert) { const page = create({ buttons: collection('button'), - aliasedButtons: alias('buttons') + aliasedButtons: alias('buttons'), }); await render(hbs` @@ -80,16 +77,16 @@ module('alias', function(hooks) { assert.equal(page.aliasedButtons.length, 2); }); - test('can alias a nested property', async function(assert) { + test('can alias a nested property', async function (assert) { assert.expect(1); const page = create({ form: { button: { - scope: 'button' - } + scope: 'button', + }, }, - aliasedIsButtonVisible: alias('form.button.isVisible') + aliasedIsButtonVisible: alias('form.button.isVisible'), }); await render(hbs``); @@ -97,56 +94,56 @@ module('alias', function(hooks) { assert.ok(page.aliasedIsButtonVisible); }); - test('can alias a nested method', async function(assert) { + test('can alias a nested method', async function (assert) { assert.expect(1); const expectedSelector = 'button'; const page = create({ form: { button: { - scope: expectedSelector - } + scope: expectedSelector, + }, }, - aliasedClickButton: alias('form.button.click') + aliasedClickButton: alias('form.button.click'), }); await render(hbs``); - find('button')?.addEventListener('click', function() { + find('button')?.addEventListener('click', function () { assert.ok(true); }); await page.aliasedClickButton(); }); - test('returns chainable object from nested method', async function(assert) { + test('returns chainable object from nested method', async function (assert) { assert.expect(1); const page = create({ form: { button: { - scope: 'button' - } + scope: 'button', + }, }, - aliasedClickButton: alias('form.button.click', { chainable: true }) + aliasedClickButton: alias('form.button.click', { chainable: true }), }); await render(hbs``); - let ret = page.aliasedClickButton(); + const ret = page.aliasedClickButton(); assert.ok(ret.form.button); - await settled() + await settled(); }); - test('can alias a nested collection', async function(assert) { + test('can alias a nested collection', async function (assert) { assert.expect(1); const page = create({ form: { - buttons: collection('button') + buttons: collection('button'), }, - aliasedButtons: alias('form.buttons') + aliasedButtons: alias('form.buttons'), }); await render(hbs``); @@ -154,17 +151,17 @@ module('alias', function(hooks) { assert.equal(page.aliasedButtons.length, 2); }); - test('can alias an aliased property', async function(assert) { + test('can alias an aliased property', async function (assert) { assert.expect(1); const page = create({ form: { button: { - scope: 'button' + scope: 'button', }, - isButtonVisible: alias('button.isVisible') + isButtonVisible: alias('button.isVisible'), }, - aliasedIsButtonVisible: alias('form.isButtonVisible') + aliasedIsButtonVisible: alias('form.isButtonVisible'), }); await render(hbs``); @@ -172,61 +169,61 @@ module('alias', function(hooks) { assert.ok(page.aliasedIsButtonVisible); }); - test('can alias an aliased method', async function(assert) { + test('can alias an aliased method', async function (assert) { assert.expect(1); const expectedSelector = 'button'; const page = create({ form: { button: { - scope: expectedSelector + scope: expectedSelector, }, - clickButton: alias('button.click') + clickButton: alias('button.click'), }, - aliasedClickButton: alias('form.clickButton') + aliasedClickButton: alias('form.clickButton'), }); await render(hbs``); - find('button')!.addEventListener('click', function() { + find('button')!.addEventListener('click', function () { assert.ok(true); }); await page.aliasedClickButton(); }); - test('returns chainable object from aliased method', async function(assert) { + test('returns chainable object from aliased method', async function (assert) { assert.expect(1); const page = create({ form: { button: { - scope: 'button' + scope: 'button', }, - clickButton: alias('button.click') + clickButton: alias('button.click'), }, - aliasedClickButton: alias('form.clickButton', { chainable: true }) + aliasedClickButton: alias('form.clickButton', { chainable: true }), }); await render(hbs``); - let ret = page.aliasedClickButton(); + const ret = page.aliasedClickButton(); assert.ok(ret.form.button); await settled(); }); - test('can alias an aliased collection', async function(assert) { + test('can alias an aliased collection', async function (assert) { assert.expect(1); const page = create({ form: { controls: { - buttons: collection('button') + buttons: collection('button'), }, - buttons: alias('controls.buttons') + buttons: alias('controls.buttons'), }, - aliasedButtons: alias('form.buttons') + aliasedButtons: alias('form.buttons'), }); await render(hbs``); @@ -234,26 +231,28 @@ module('alias', function(hooks) { assert.equal(page.aliasedButtons.length, 2); }); - test('can alias a property created with the `getter` macro', async function(assert) { + test('can alias a property created with the `getter` macro', async function (assert) { assert.expect(1); type Getter = ReturnType, T>>; type Form = { - buttonText: Getter, - isButtonReady: Getter - } + buttonText: Getter; + isButtonReady: Getter; + }; const form: Form = { buttonText: text('button'), - isButtonReady: getter
(function() { + isButtonReady: getter(function () { return this.buttonText === 'Ready to Submit!'; }), }; const page = create({ form, - aliasedIsButtonReady: alias('form.isButtonReady') as Form['isButtonReady'] + aliasedIsButtonReady: alias( + 'form.isButtonReady' + ) as Form['isButtonReady'], }); await render(hbs``); @@ -261,40 +260,44 @@ module('alias', function(hooks) { assert.ok(page.aliasedIsButtonReady); }); - test('throws error if alias targets nonexistent top-level property', function(assert) { + test('throws error if alias targets nonexistent top-level property', function (assert) { assert.expect(1); const page = create({ - fooAlias: alias('foo') + fooAlias: alias('foo'), }); assert.throws( - function() { return page.fooAlias; }, + function () { + return page.fooAlias; + }, /PageObject does not contain aliased property `foo`/, 'Aliased property not found' ); }); - test('throws error if alias targets nonexistent nested property', function(assert) { + test('throws error if alias targets nonexistent nested property', function (assert) { assert.expect(1); const page = create({ - fooBarAlias: alias('foo.bar') + fooBarAlias: alias('foo.bar'), }); assert.throws( - function() { return page.fooBarAlias; }, + function () { + return page.fooBarAlias; + }, /PageObject does not contain aliased property `foo.bar`/, 'Aliased property not found' ); }); - test('does not throw error if alias targets top-level property with falsy value', async function(assert) { + test('does not throw error if alias targets top-level property with falsy value', async function (assert) { assert.expect(1); const page = create({ isButtonVisible: isVisible('button'), - aliasedIsButtonVisible: alias('isButtonVisible') + aliasedIsButtonVisible: alias('isButtonVisible'), }); await render(hbs`No button here`); @@ -302,14 +305,14 @@ module('alias', function(hooks) { assert.equal(page.aliasedIsButtonVisible, false); }); - test('does not throw error if alias targets nested property with falsy value', async function(assert) { + test('does not throw error if alias targets nested property with falsy value', async function (assert) { assert.expect(1); const page = create({ button: { - scope: 'button' + scope: 'button', }, - aliasedIsButtonVisible: alias('button.isVisible') + aliasedIsButtonVisible: alias('button.isVisible'), }); await render(hbs`No button here`); diff --git a/test-app/tests/unit/-private/properties/attribute-test.ts b/test-app/tests/unit/-private/properties/attribute-test.ts index 961e40e6..d6ba0649 100644 --- a/test-app/tests/unit/-private/properties/attribute-test.ts +++ b/test-app/tests/unit/-private/properties/attribute-test.ts @@ -8,7 +8,7 @@ module('attribute', function (hooks) { setupRenderingTest(hooks); test('returns attribute value', async function (assert) { - let page = create({ + const page = create({ foo: attribute('placeholder', ':input'), }); @@ -18,7 +18,7 @@ module('attribute', function (hooks) { }); test("returns null when attribute doesn't exist", async function (assert) { - let page = create({ + const page = create({ placeholder: attribute('placeholder', ':input'), disabled: attribute('placeholder', ':input'), }); @@ -30,7 +30,7 @@ module('attribute', function (hooks) { }); test("raises an error when the element doesn't exist", async function (assert) { - let page = create({ + const page = create({ foo: { bar: { baz: { @@ -46,7 +46,7 @@ module('attribute', function (hooks) { }); test('looks for elements inside the scope', async function (assert) { - let page = create({ + const page = create({ foo: attribute('placeholder', ':input', { scope: '.scope' }), }); @@ -60,7 +60,7 @@ module('attribute', function (hooks) { }); test("looks for elements inside page's scope", async function (assert) { - let page = create({ + const page = create({ scope: '.scope', foo: attribute('placeholder', ':input'), @@ -76,7 +76,7 @@ module('attribute', function (hooks) { }); test('resets scope', async function (assert) { - let page = create({ + const page = create({ scope: '.scope', foo: attribute('placeholder', ':input', { resetScope: true }), @@ -91,7 +91,7 @@ module('attribute', function (hooks) { }); test('throws error if selector matches more than one element', async function (assert) { - let page = create({ + const page = create({ foo: attribute('placeholder', ':input'), }); @@ -107,7 +107,7 @@ module('attribute', function (hooks) { }); test('finds element by index', async function (assert) { - let page = create({ + const page = create({ foo: attribute('placeholder', ':input', { at: 1 }), }); @@ -120,7 +120,7 @@ module('attribute', function (hooks) { }); test('looks for elements outside the testing container', async function (assert) { - let page = create({ + const page = create({ foo: attribute('placeholder', ':input', { testContainer: '#alternate-ember-testing', }), @@ -128,14 +128,15 @@ module('attribute', function (hooks) { await render(hbs``); - (document.getElementById('alternate-ember-testing') as HTMLElement) - .innerHTML = ``; + ( + document.getElementById('alternate-ember-testing') as HTMLElement + ).innerHTML = ``; assert.strictEqual(page.foo, 'a value'); }); test('no value attributes', async function (assert) { - let page = create({ + const page = create({ scope: 'span', disabled: attribute('disabled'), datatest: attribute('data-test'), @@ -148,10 +149,10 @@ module('attribute', function (hooks) { }); test('uppercase', async function (assert) { - let page = create({ + const page = create({ scope: 'span', disabled: attribute('DISABLED'), - withValueSpecified: attribute('DATA-TEST') + withValueSpecified: attribute('DATA-TEST'), }); await render(hbs``); @@ -162,7 +163,7 @@ module('attribute', function (hooks) { module('tabindex', function () { test('no value', async function (assert) { - let page = create({ + const page = create({ scope: 'span', tabindex: attribute('tabindex'), }); @@ -173,7 +174,7 @@ module('attribute', function (hooks) { }); test('with value', async function (assert) { - let page = create({ + const page = create({ scope: 'span', tabindex: attribute('tabindex'), }); @@ -184,7 +185,7 @@ module('attribute', function (hooks) { }); test('uppercase', async function (assert) { - let page = create({ + const page = create({ scope: 'span', tabindex: attribute('TABINDEX'), }); @@ -193,5 +194,5 @@ module('attribute', function (hooks) { assert.strictEqual(page.tabindex, ''); }); - }) + }); }); diff --git a/test-app/tests/unit/-private/properties/blurrable-test.ts b/test-app/tests/unit/-private/properties/blurrable-test.ts index c3237a86..b9cba806 100644 --- a/test-app/tests/unit/-private/properties/blurrable-test.ts +++ b/test-app/tests/unit/-private/properties/blurrable-test.ts @@ -4,20 +4,20 @@ import { find, render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { module, test } from 'qunit'; -module('blurrable', function(hooks) { +module('blurrable', function (hooks) { setupRenderingTest(hooks); - test('calls blur with proper args', async function(assert) { + test('calls blur with proper args', async function (assert) { assert.expect(1); - let expectedSelector = 'input'; - let page = create({ - foo: blurrable(expectedSelector) + const expectedSelector = 'input'; + const page = create({ + foo: blurrable(expectedSelector), }); await render(hbs``); - const element = (find(expectedSelector) as HTMLElement) + const element = find(expectedSelector) as HTMLElement; element.focus(); element.addEventListener('blur', () => { assert.ok(1); @@ -26,17 +26,17 @@ module('blurrable', function(hooks) { await page.foo(); }); - test('actually blurs the element', async function(assert) { + test('actually blurs the element', async function (assert) { assert.expect(2); - let expectedSelector = 'input'; - let page = create({ - foo: blurrable(expectedSelector) + const expectedSelector = 'input'; + const page = create({ + foo: blurrable(expectedSelector), }); await render(hbs``); - const element = (find(expectedSelector) as HTMLElement) + const element = find(expectedSelector) as HTMLElement; element.focus(); element.addEventListener('blur', () => { assert.ok(1, 'blurred'); @@ -46,149 +46,151 @@ module('blurrable', function(hooks) { await page.foo(); }); - test('looks for elements inside the scope', async function(assert) { + test('looks for elements inside the scope', async function (assert) { assert.expect(1); - let page = create({ - foo: blurrable('input', { scope: '.scope' }) + const page = create({ + foo: blurrable('input', { scope: '.scope' }), }); await render(hbs`
`); - const element = (find('.scope input') as HTMLElement) + const element = find('.scope input') as HTMLElement; element.focus(); element.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.foo(); }); - test("looks for elements inside page's scope", async function(assert) { + test("looks for elements inside page's scope", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: blurrable('input') + foo: blurrable('input'), }); await render(hbs`
`); - const element = (find('.scope input') as HTMLElement) + const element = find('.scope input') as HTMLElement; element.focus(); element.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.foo(); }); - test('resets scope', async function(assert) { + test('resets scope', async function (assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: blurrable('input', { resetScope: true }) + foo: blurrable('input', { resetScope: true }), }); await render(hbs``); - const element = (find('input') as HTMLElement) + const element = find('input') as HTMLElement; element.focus(); element.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.foo(); }); - test('returns chainable object', async function(assert) { + test('returns chainable object', async function (assert) { assert.expect(1); - let page = create({ - foo: blurrable('input') + const page = create({ + foo: blurrable('input'), }); await render(hbs``); - const element = (find('input') as HTMLElement) + const element = find('input') as HTMLElement; element.focus(); assert.ok(page.foo); }); - test('finds element by index', async function(assert) { + test('finds element by index', async function (assert) { assert.expect(1); - let page = create({ + const page = create({ blur: blurrable('input', { at: 3 }), - focus: focusable('input', { at: 3 }) + focus: focusable('input', { at: 3 }), }); await render(hbs``); - await page.focus() + await page.focus(); - const element = (find('input:nth-of-type(4)') as HTMLElement) + const element = find('input:nth-of-type(4)') as HTMLElement; element.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.blur(); }); - test('looks for elements outside the testing container', async function(assert) { + test('looks for elements outside the testing container', async function (assert) { assert.expect(1); - let expectedContextId = 'alternate-ember-testing'; - let page = create({ - foo: blurrable('input', { testContainer: `#${expectedContextId}` }) + const expectedContextId = 'alternate-ember-testing'; + const page = create({ + foo: blurrable('input', { testContainer: `#${expectedContextId}` }), }); const expectedContext = document.getElementById(expectedContextId)!; expectedContext.innerHTML = ``; - const input = (expectedContext.querySelector('input') as HTMLElement) + const input = expectedContext.querySelector('input') as HTMLElement; input.focus(); input.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.foo(); }); - test('looks for elements within test container specified at node level', async function(assert) { + test('looks for elements within test container specified at node level', async function (assert) { assert.expect(1); - let expectedContext = '#alternate-ember-testing'; - let page = create({ + const expectedContext = '#alternate-ember-testing'; + const page = create({ testContainer: expectedContext, - foo: blurrable('input') + foo: blurrable('input'), }); - const alternatveContainer = document.getElementById('alternate-ember-testing')!; + const alternatveContainer = document.getElementById( + 'alternate-ember-testing' + )!; alternatveContainer.innerHTML = ``; const element = alternatveContainer?.querySelector('input') as HTMLElement; element.focus(); element.addEventListener('blur', () => { - assert.ok(1) + assert.ok(1); }); await page.foo(); }); - test("raises an error when the element doesn't exist", async function(assert) { + test("raises an error when the element doesn't exist", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: blurrable('button') - } - } - } + qux: blurrable('button'), + }, + }, + }, }); await render(hbs``); @@ -201,16 +203,16 @@ module('blurrable', function(hooks) { ); }); - test('raises an error when the element is not focusable', async function(assert) { - let page = create({ + test('raises an error when the element is not focusable', async function (assert) { + const page = create({ foo: { bar: { baz: blurrable('span'), qux: blurrable('input'), quux: blurrable('button'), - quuz: blurrable('[contenteditable]') - } - } + quuz: blurrable('[contenteditable]'), + }, + }, }); await render(hbs` @@ -222,8 +224,8 @@ module('blurrable', function(hooks) { await assert.rejects( page.foo.bar.baz() as unknown as Promise, - /page\.foo\.bar\.baz/, - 'Element is not focusable because it is not a link' + /page\.foo\.bar\.baz/, + 'Element is not focusable because it is not a link' ); await assert.rejects( diff --git a/test-app/tests/unit/-private/properties/click-on-text-test.ts b/test-app/tests/unit/-private/properties/click-on-text-test.ts index cde41582..dc75a4ed 100644 --- a/test-app/tests/unit/-private/properties/click-on-text-test.ts +++ b/test-app/tests/unit/-private/properties/click-on-text-test.ts @@ -4,15 +4,15 @@ import { render, find, findAll } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { module, test } from 'qunit'; -module('clickOnText', function(hooks) { +module('clickOnText', function (hooks) { setupRenderingTest(hooks); - test('calls click helper', async function(assert) { + test('calls click helper', async function (assert) { assert.expect(2); - let page = create({ + const page = create({ foo: clickOnText('fieldset'), - bar: clickOnText('button') + bar: clickOnText('button'), }); await render(hbs` @@ -35,12 +35,12 @@ module('clickOnText', function(hooks) { await page.bar('Lorem'); }); - test('looks for elements inside the scope', async function(assert) { + test('looks for elements inside the scope', async function (assert) { assert.expect(2); - let page = create({ + const page = create({ foo: clickOnText('fieldset', { scope: '.scope' }), - bar: clickOnText('button', { scope: '.scope' }) + bar: clickOnText('button', { scope: '.scope' }), }); await render(hbs` @@ -65,13 +65,13 @@ module('clickOnText', function(hooks) { await page.bar('Lorem'); }); - test("looks for elements inside page's scope", async function(assert) { + test("looks for elements inside page's scope", async function (assert) { assert.expect(2); - let page = create({ + const page = create({ scope: '.scope', foo: clickOnText('fieldset'), - bar: clickOnText('button') + bar: clickOnText('button'), }); await render(hbs` @@ -96,13 +96,13 @@ module('clickOnText', function(hooks) { await page.bar('Lorem'); }); - test('resets scope', async function(assert) { + test('resets scope', async function (assert) { assert.expect(2); - let page = create({ + const page = create({ scope: '.scope', foo: clickOnText('fieldset', { resetScope: true }), - bar: clickOnText('button', { resetScope: true }) + bar: clickOnText('button', { resetScope: true }), }); await render(hbs` @@ -125,26 +125,26 @@ module('clickOnText', function(hooks) { await page.bar('Lorem'); }); - test('returns chainable object', async function(assert) { + test('returns chainable object', async function (assert) { assert.expect(1); - let page = create({ - foo: clickOnText() + const page = create({ + foo: clickOnText(), }); await render(hbs``); - let ret = page.foo('dummy text'); + const ret = page.foo('dummy text'); assert.ok(ret.foo); await ret; }); - test('finds element by index', async function(assert) { + test('finds element by index', async function (assert) { assert.expect(2); - let page = create({ + const page = create({ foo: clickOnText('fieldset', { at: 2 }), - bar: clickOnText('button', { at: 2 }) + bar: clickOnText('button', { at: 2 }), }); await render(hbs` @@ -164,40 +164,41 @@ module('clickOnText', function(hooks) { otherElement.addEventListener('click', () => { assert.ok(false); }); - }) + }); await page.foo('Lorem'); await page.bar('Lorem'); }); - test('looks for elements outside the testing container', async function(assert) { + test('looks for elements outside the testing container', async function (assert) { assert.expect(1); - let expectedContext = '#alternate-ember-testing'; + const expectedContext = '#alternate-ember-testing'; let page; page = create({ - foo: clickOnText('button', { testContainer: expectedContext }) + foo: clickOnText('button', { testContainer: expectedContext }), }); document.getElementById( 'alternate-ember-testing' )!.innerHTML = ``; - document.querySelector('#alternate-ember-testing button')! + document + .querySelector('#alternate-ember-testing button')! .addEventListener('click', () => assert.ok(1)); await page.foo('Lorem'); }); - test('looks for elements within test container specified at node level', async function(assert) { + test('looks for elements within test container specified at node level', async function (assert) { assert.expect(1); - let expectedContext = '#alternate-ember-testing'; - let page = create({ + const expectedContext = '#alternate-ember-testing'; + const page = create({ testContainer: expectedContext, - foo: clickOnText('button') + foo: clickOnText('button'), }); document.getElementById( @@ -206,54 +207,63 @@ module('clickOnText', function(hooks) { await render(hbs``); - document.querySelector('#alternate-ember-testing button')! + document + .querySelector('#alternate-ember-testing button')! .addEventListener('click', () => assert.ok(1)); await page.foo('Lorem'); }); - test("raises an error when the element doesn't exist", async function(assert) { + test("raises an error when the element doesn't exist", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: clickOnText('button') - } - } - } + qux: clickOnText('button'), + }, + }, + }, }); await render(hbs``); - assert.throws(() => { - return page.foo.bar.baz.qux('Lorem'); - }, /page\.foo\.bar\.baz\.qux/, 'Element not found'); + assert.throws( + () => { + return page.foo.bar.baz.qux('Lorem'); + }, + /page\.foo\.bar\.baz\.qux/, + 'Element not found' + ); }); - test("doesn't raise an error when the element is not visible and `visible` is not set", async function(assert) { + test("doesn't raise an error when the element is not visible and `visible` is not set", async function (assert) { assert.expect(1); - let page = create({ - foo: clickOnText('button') + const page = create({ + foo: clickOnText('button'), }); - await render(hbs``); + await render( + hbs`` + ); find('button')!.addEventListener('click', () => assert.ok(1)); await page.foo('Click me'); }); - test('raises an error when the element is not visible and `visible` is true', async function(assert) { + test('raises an error when the element is not visible and `visible` is true', async function (assert) { assert.expect(1); - let page = create({ - foo: clickOnText('button', { visible: true }) + const page = create({ + foo: clickOnText('button', { visible: true }), }); - await render(hbs``); + await render( + hbs`` + ); await assert.throws( () => page.foo('Click me'), diff --git a/test-app/tests/unit/-private/properties/clickable-test.ts b/test-app/tests/unit/-private/properties/clickable-test.ts index dbd2bcfe..77e2099f 100644 --- a/test-app/tests/unit/-private/properties/clickable-test.ts +++ b/test-app/tests/unit/-private/properties/clickable-test.ts @@ -4,51 +4,55 @@ import { render, find } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { module, test } from 'qunit'; -module('clickable', function(hooks) { +module('clickable', function (hooks) { setupRenderingTest(hooks); - test('calls click helper', async function(assert) { + test('calls click helper', async function (assert) { assert.expect(1); - let expectedSelector = 'button'; - let page = create({ - foo: clickable(expectedSelector) + const expectedSelector = 'button'; + const page = create({ + foo: clickable(expectedSelector), }); await render(hbs``); - find(expectedSelector)!.addEventListener('click', () => assert.ok(1), { once: true }); + find(expectedSelector)!.addEventListener('click', () => assert.ok(1), { + once: true, + }); await page.foo(); }); - test('looks for elements inside the scope', async function(assert) { + test('looks for elements inside the scope', async function (assert) { assert.expect(1); - let expectedSelector = '.scope span'; + const expectedSelector = '.scope span'; let page; page = create({ - foo: clickable('span', { scope: '.scope' }) + foo: clickable('span', { scope: '.scope' }), }); await render(hbs`
Click me
`); - find(expectedSelector)?.addEventListener('click', () => assert.ok(1), { once: true}); + find(expectedSelector)?.addEventListener('click', () => assert.ok(1), { + once: true, + }); await page.foo(); }); - test("looks for elements inside page's scope", async function(assert) { + test("looks for elements inside page's scope", async function (assert) { assert.expect(1); - let expectedSelector = '.scope span'; + const expectedSelector = '.scope span'; let page; page = create({ scope: '.scope', - foo: clickable('span') + foo: clickable('span'), }); await render(hbs`
Click me
`); @@ -58,15 +62,15 @@ module('clickable', function(hooks) { await page.foo(); }); - test('resets scope', async function(assert) { + test('resets scope', async function (assert) { assert.expect(1); - let expectedSelector = 'span'; + const expectedSelector = 'span'; let page; page = create({ scope: '.scope', - foo: clickable('span', { resetScope: true }) + foo: clickable('span', { resetScope: true }), }); await render(hbs`Click me`); @@ -76,100 +80,108 @@ module('clickable', function(hooks) { await page.foo(); }); - test('returns chainable object', async function(assert) { + test('returns chainable object', async function (assert) { assert.expect(1); - let page = create({ - foo: clickable('span') + const page = create({ + foo: clickable('span'), }); await render(hbs`Click me`); - let ret = page.foo(); + const ret = page.foo(); assert.ok(ret.foo); await ret; }); - test('finds element by index', async function(assert) { + test('finds element by index', async function (assert) { assert.expect(1); - let page = create({ - foo: clickable('span', { at: 3 }) + const page = create({ + foo: clickable('span', { at: 3 }), }); - await render(hbs`Click me`); + await render( + hbs`Click me` + ); find('span:nth-of-type(4)')!.addEventListener('click', () => assert.ok(1)); await page.foo(); }); - test('looks for elements outside the testing container', async function(assert) { + test('looks for elements outside the testing container', async function (assert) { assert.expect(1); - let expectedContext = '#alternate-ember-testing'; + const expectedContext = '#alternate-ember-testing'; let page; page = create({ - foo: clickable('span', { testContainer: expectedContext }) + foo: clickable('span', { testContainer: expectedContext }), }); document.getElementById( 'alternate-ember-testing' )!.innerHTML = `Click me`; - document.querySelector('#alternate-ember-testing span')! + document + .querySelector('#alternate-ember-testing span')! .addEventListener('click', () => assert.ok(1)); await page.foo(); }); - test('looks for elements within test container specified at node level', async function(assert) { + test('looks for elements within test container specified at node level', async function (assert) { assert.expect(1); - let expectedContext = '#alternate-ember-testing'; + const expectedContext = '#alternate-ember-testing'; let page; page = create({ testContainer: expectedContext, - foo: clickable('span') + foo: clickable('span'), }); document.getElementById( 'alternate-ember-testing' )!.innerHTML = `Click me`; - document.querySelector('#alternate-ember-testing span')! + document + .querySelector('#alternate-ember-testing span')! .addEventListener('click', () => assert.ok(1)); await page.foo(); }); - test("raises an error when the element doesn't exist", async function(assert) { + test("raises an error when the element doesn't exist", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: clickable('button') - } - } - } + qux: clickable('button'), + }, + }, + }, }); await render(hbs``); - await assert.throws(function() { - return page.foo.bar.baz.qux(); - }, /page\.foo\.bar\.baz\.qux/, 'Element not found'); + await assert.throws( + function () { + return page.foo.bar.baz.qux(); + }, + /page\.foo\.bar\.baz\.qux/, + 'Element not found' + ); }); - test("doesn't raise an error when the element is not visible and `visible` is not set", async function(assert) { + test("doesn't raise an error when the element is not visible and `visible` is not set", async function (assert) { assert.expect(1); - let page = create({ - foo: clickable('span') + const page = create({ + foo: clickable('span'), }); await render(hbs`Click me`); @@ -179,17 +191,21 @@ module('clickable', function(hooks) { await page.foo(); }); - test('raises an error when the element is not visible and `visible` is true', async function(assert) { + test('raises an error when the element is not visible and `visible` is true', async function (assert) { assert.expect(1); - let page = create({ - foo: clickable('span', { visible: true }) + const page = create({ + foo: clickable('span', { visible: true }), }); await render(hbs`Click me`); - await assert.throws(function() { - return page.foo(); - }, /page\.foo/, 'Element not found'); + await assert.throws( + function () { + return page.foo(); + }, + /page\.foo/, + 'Element not found' + ); }); }); diff --git a/test-app/tests/unit/-private/properties/collection-test.ts b/test-app/tests/unit/-private/properties/collection-test.ts index e2e95309..1e7bcc79 100644 --- a/test-app/tests/unit/-private/properties/collection-test.ts +++ b/test-app/tests/unit/-private/properties/collection-test.ts @@ -3,12 +3,12 @@ import withIteratorSymbolDefined from '../../../helpers/with-iterator-symbol-def import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; -module('collection', function(hooks) { +module('collection', function (hooks) { setupRenderingTest(hooks); - test('returns the same collection instance', async function(this: TestContext, assert) { - let page = create({ - foo: collection('span') + test('returns the same collection instance', async function (this: TestContext, assert) { + const page = create({ + foo: collection('span'), }); await this.createTemplate(` @@ -19,9 +19,9 @@ module('collection', function(hooks) { assert.equal(page.foo, page.foo); }); - test(`returns the same collection's item instance`, async function(this: TestContext, assert) { - let page = create({ - foo: collection('span') + test(`returns the same collection's item instance`, async function (this: TestContext, assert) { + const page = create({ + foo: collection('span'), }); await this.createTemplate(` @@ -32,9 +32,9 @@ module('collection', function(hooks) { assert.equal(page.foo[0], page.foo[0]); }); - test('generates a length property', async function(this: TestContext, assert) { - let page = create({ - foo: collection('span') + test('generates a length property', async function (this: TestContext, assert) { + const page = create({ + foo: collection('span'), }); await this.createTemplate(` @@ -45,9 +45,9 @@ module('collection', function(hooks) { assert.equal(page.foo.length, 2); }); - test('Works with zero length', async function(this: TestContext, assert) { - let page = create({ - foo: collection('span') + test('Works with zero length', async function (this: TestContext, assert) { + const page = create({ + foo: collection('span'), }); await this.createTemplate(` @@ -58,11 +58,11 @@ module('collection', function(hooks) { assert.equal(page.foo.length, 0); }); - test('returns an item', async function(this: TestContext, assert) { - let page = create({ + test('returns an item', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -74,11 +74,11 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(1)!.text, 'Ipsum'); }); - test('collects an array of items', async function(this: TestContext, assert) { - let page = create({ + test('collects an array of items', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -86,22 +86,22 @@ module('collection', function(hooks) { Ipsum `); - let array = page.foo.toArray(); + const array = page.foo.toArray(); assert.equal(array.length, 2); assert.equal(array[0]?.text, 'Lorem'); assert.equal(array[1]?.text, 'Ipsum'); - let proxyArray = page.foo.toArray(); + const proxyArray = page.foo.toArray(); assert.equal(proxyArray.length, 2); assert.equal(proxyArray[0]?.text, 'Lorem'); assert.equal(proxyArray[1]?.text, 'Ipsum'); }); - test('produces an iterator for items', async function(this: TestContext, assert) { - let page = create({ + test('produces an iterator for items', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -109,9 +109,9 @@ module('collection', function(hooks) { Ipsum `); - let textContents: string[] = []; + const textContents: string[] = []; withIteratorSymbolDefined(() => { - for (let item of page.foo) { + for (const item of page.foo) { textContents.push(item.text); } }); @@ -119,13 +119,13 @@ module('collection', function(hooks) { assert.deepEqual(textContents, ['Lorem', 'Ipsum']); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -140,17 +140,17 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(0)!.text, 'Ipsum'); }); - test('looks for elements inside multiple scopes', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements inside multiple scopes', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', foo: collection('li', { bar: { scope: '.another-scope', - text: text('li', { at: 0 }) - } - }) + text: text('li', { at: 0 }), + }, + }), }); await this.createTemplate(` @@ -179,14 +179,14 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(1)!.bar.text, 'Sit'); }); - test('resets scope for items', async function(this: TestContext, assert) { - let page = create({ + test('resets scope for items', async function (this: TestContext, assert) { + const page = create({ scope: 'div', foo: collection('span', { resetScope: true, - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -199,15 +199,15 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(0)!.text, 'Lorem'); }); - test('sets correct scope to child collections', async function(this: TestContext, assert) { - let page = create({ + test('sets correct scope to child collections', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', foo: collection('span', { bar: collection('em', { - text: text() - }) - }) + text: text(), + }), + }), }); await this.createTemplate(` @@ -218,12 +218,12 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(0)!.bar.objectAt(0)!.text, 'Ipsum'); }); - test('iterates over scoped items with a for loop', async function(this: TestContext, assert) { - let page = create({ + test('iterates over scoped items with a for loop', async function (this: TestContext, assert) { + const page = create({ scope: 'div', foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -233,22 +233,22 @@ module('collection', function(hooks) { `); - let textContents: string[] = []; + const textContents: string[] = []; for (let i = 0; i < page.foo.length; i++) { - let item = page.foo.objectAt(i)!; + const item = page.foo.objectAt(i)!; textContents.push(item.text); } assert.deepEqual(textContents, ['Lorem', 'Ipsum']); }); - test('iterates over scoped items with a for of loop', async function(this: TestContext, assert) { - let page = create({ + test('iterates over scoped items with a for of loop', async function (this: TestContext, assert) { + const page = create({ scope: 'div', foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -258,10 +258,10 @@ module('collection', function(hooks) { `); - let textContents: string[] = []; + const textContents: string[] = []; withIteratorSymbolDefined(() => { - for (let item of page.foo) { + for (const item of page.foo) { textContents.push(item.text); } }); @@ -269,13 +269,13 @@ module('collection', function(hooks) { assert.deepEqual(textContents, ['Lorem', 'Ipsum']); }); - test('iterates over scoped items with a forEach loop', async function(this: TestContext, assert) { - let page = create({ + test('iterates over scoped items with a forEach loop', async function (this: TestContext, assert) { + const page = create({ scope: 'div', foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -285,7 +285,7 @@ module('collection', function(hooks) { `); - let textContents: string[] = []; + const textContents: string[] = []; page.foo.forEach((item) => { textContents.push(item.text); @@ -294,56 +294,55 @@ module('collection', function(hooks) { assert.deepEqual(textContents, ['Lorem', 'Ipsum']); }); - test('does not mutate definition object', async function(this: TestContext, assert) { - let prop = text('.baz'); + test('does not mutate definition object', async function (this: TestContext, assert) { + const prop = text('.baz'); - let expected = { + const expected = { bar: prop, baz: { - qux: prop - } + qux: prop, + }, }; - let actual = { + const actual = { bar: prop, baz: { - qux: prop - } + qux: prop, + }, }; create({ - foo: collection('.another-scope', actual) + foo: collection('.another-scope', actual), }); assert.deepEqual(actual, expected); }); - test('looks for elements within test container specified', async function(this: TestContext, assert) { + test('looks for elements within test container specified', async function (this: TestContext, assert) { assert.expect(2); - let expectedContext = '#alternate-ember-testing'; + const expectedContext = '#alternate-ember-testing'; let page; page = create({ foo: collection('span', { testContainer: expectedContext, - }) + }), }); - await this.createTemplate( - 'Loremipsum', - { useAlternateContainer: true } - ); + await this.createTemplate('Loremipsum', { + useAlternateContainer: true, + }); assert.equal(page.foo.length, 2); assert.equal(page.foo.objectAt(0)!.text, 'Lorem'); }); - test('objectAt returns an item', async function(this: TestContext, assert) { - let page = create({ + test('objectAt returns an item', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -355,11 +354,11 @@ module('collection', function(hooks) { assert.equal(page.foo.objectAt(1)!.text, 'Ipsum'); }); - test('forEach works correctly', async function(this: TestContext, assert) { - let page = create({ + test('forEach works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -367,7 +366,7 @@ module('collection', function(hooks) { Ipsum `); - let textArray: string[] = []; + const textArray: string[] = []; page.foo.forEach((i) => { textArray.push(i.text); }); @@ -375,11 +374,11 @@ module('collection', function(hooks) { assert.deepEqual(textArray, ['Lorem', 'Ipsum']); }); - test('map works correctly', async function(this: TestContext, assert) { - let page = create({ + test('map works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -387,14 +386,17 @@ module('collection', function(hooks) { Ipsum `); - assert.deepEqual(page.foo.map((i) => i.text), ['Lorem', 'Ipsum']); + assert.deepEqual( + page.foo.map((i) => i.text), + ['Lorem', 'Ipsum'] + ); }); - test('mapBy works correctly', async function(this: TestContext, assert) { - let page = create({ + test('mapBy works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -405,11 +407,11 @@ module('collection', function(hooks) { assert.deepEqual(page.foo.mapBy('text'), ['Lorem', 'Ipsum']); }); - test('findOneBy works correctly', async function(this: TestContext, assert) { - let page = create({ + test('findOneBy works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -420,12 +422,12 @@ module('collection', function(hooks) { assert.equal(page.foo.findOneBy('text', 'Lorem').text, 'Lorem'); }); - test('findOneBy throws error if > 1 elements found', async function(this: TestContext, assert) { + test('findOneBy throws error if > 1 elements found', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -435,7 +437,9 @@ module('collection', function(hooks) { Ipsum `); - const expectedError = new RegExp(`3 elements found by text: "Ipsum", but expected 1\n\nPageObject: 'page.foo'`); + const expectedError = new RegExp( + `3 elements found by text: "Ipsum", but expected 1\n\nPageObject: 'page.foo'` + ); assert.throws( () => page.foo.findOneBy('text', 'Ipsum'), @@ -444,12 +448,12 @@ module('collection', function(hooks) { ); }); - test('findOneBy throws error if no elements found', async function(this: TestContext, assert) { + test('findOneBy throws error if no elements found', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -469,11 +473,11 @@ module('collection', function(hooks) { ); }); - test('findOne works correctly', async function(this: TestContext, assert) { - let page = create({ + test('findOne works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -481,15 +485,15 @@ module('collection', function(hooks) { Ipsum `); - assert.equal(page.foo.findOne(i => i.text === 'Lorem').text, 'Lorem'); + assert.equal(page.foo.findOne((i) => i.text === 'Lorem').text, 'Lorem'); }); - test('findOne throws error if > 1 elements found', async function(this: TestContext, assert) { + test('findOne throws error if > 1 elements found', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -509,12 +513,12 @@ module('collection', function(hooks) { ); }); - test('findOne throws error if no elements found', async function(this: TestContext, assert) { + test('findOne throws error if no elements found', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: collection('span', { - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -534,12 +538,12 @@ module('collection', function(hooks) { ); }); - test('filter works correctly', async function(this: TestContext, assert) { - let page = create({ + test('filter works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { isSpecial: hasClass('special'), - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -547,16 +551,22 @@ module('collection', function(hooks) { Ipsum `); - assert.deepEqual(page.foo.filter((i) => i.isSpecial).map((i) => i.text), ['Lorem']); - assert.deepEqual(page.foo.filter((i) => i['isFoo'] as any).map((i) => i.text), []); + assert.deepEqual( + page.foo.filter((i) => i.isSpecial).map((i) => i.text), + ['Lorem'] + ); + assert.deepEqual( + page.foo.filter((i) => i['isFoo'] as any).map((i) => i.text), + [] + ); }); - test('filterBy works correctly', async function(this: TestContext, assert) { - let page = create({ + test('filterBy works correctly', async function (this: TestContext, assert) { + const page = create({ foo: collection('span', { isSpecial: hasClass('special'), - text: text() - }) + text: text(), + }), }); await this.createTemplate(` @@ -564,13 +574,19 @@ module('collection', function(hooks) { Ipsum `); - assert.deepEqual(page.foo.filterBy('isSpecial').map((i) => i.text), ['Lorem']); - assert.deepEqual(page.foo.filterBy('isFoo' as any).map((i) => i.text), []); + assert.deepEqual( + page.foo.filterBy('isSpecial').map((i) => i.text), + ['Lorem'] + ); + assert.deepEqual( + page.foo.filterBy('isFoo' as any).map((i) => i.text), + [] + ); }); - test('uses array accessor', async function(this: TestContext, assert) { - let page = create({ - foo: collection('span') + test('uses array accessor', async function (this: TestContext, assert) { + const page = create({ + foo: collection('span'), }); await this.createTemplate(` diff --git a/test-app/tests/unit/-private/properties/contains-test.ts b/test-app/tests/unit/-private/properties/contains-test.ts index 4d8e83a0..e2aaaf58 100644 --- a/test-app/tests/unit/-private/properties/contains-test.ts +++ b/test-app/tests/unit/-private/properties/contains-test.ts @@ -2,12 +2,12 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { create, contains } from 'ember-cli-page-object'; import { module, test } from 'qunit'; -module('contains', function(hooks) { +module('contains', function (hooks) { setupRenderingTest(hooks); - test('returns true when the element contains the text', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span') + test('returns true when the element contains the text', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span'), }); await this.createTemplate('Lorem ipsum'); @@ -16,9 +16,9 @@ module('contains', function(hooks) { assert.ok(page.foo('ipsum')); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span', { scope: '.scope' }), }); await this.createTemplate(` @@ -31,11 +31,11 @@ module('contains', function(hooks) { assert.ok(page.foo('ipsum')); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: contains('span') + foo: contains('span'), }); await this.createTemplate(` @@ -48,27 +48,30 @@ module('contains', function(hooks) { assert.ok(page.foo('ipsum')); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: contains('.element') - } - } - } + qux: contains('.element'), + }, + }, + }, }); await this.createTemplate(''); - assert.throws(() => page.foo.bar.baz.qux('baz'), /page\.foo\.bar\.baz\.qux/); + assert.throws( + () => page.foo.bar.baz.qux('baz'), + /page\.foo\.bar\.baz\.qux/ + ); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: contains('span', { at: 0, resetScope: true }) + foo: contains('span', { at: 0, resetScope: true }), }); await this.createTemplate(` @@ -80,9 +83,9 @@ module('contains', function(hooks) { assert.ok(page.foo('lorem')); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span'), }); await this.createTemplate(` @@ -91,13 +94,15 @@ module('contains', function(hooks) { lorem `); - assert.throws(() => page.foo('lorem'), - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo('lorem'), + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span', { at: 1 }), }); await this.createTemplate(` @@ -110,44 +115,52 @@ module('contains', function(hooks) { assert.ok(page.foo('ipsum')); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span', { testContainer: '#alternate-ember-testing' }), }); - await this.createTemplate('Lorem ipsum', { useAlternateContainer: true }); + await this.createTemplate('Lorem ipsum', { + useAlternateContainer: true, + }); assert.ok(page.foo('ipsum')); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: contains('span') + foo: contains('span'), }); - await this.createTemplate('Lorem ipsum', { useAlternateContainer: true }); + await this.createTemplate('Lorem ipsum', { + useAlternateContainer: true, + }); assert.ok(page.foo('ipsum')); }); - test('looks for elements that are visibility hidden', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span') + test('looks for elements that are visibility hidden', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span'), }); - await this.createTemplate('Lorem ipsum'); + await this.createTemplate( + 'Lorem ipsum' + ); assert.ok(!page.foo('Not here')); assert.ok(page.foo('ipsum')); }); - test('looks for elements that are display none', async function(this: TestContext, assert) { - let page = create({ - foo: contains('span') + test('looks for elements that are display none', async function (this: TestContext, assert) { + const page = create({ + foo: contains('span'), }); - await this.createTemplate('Lorem ipsum'); + await this.createTemplate( + 'Lorem ipsum' + ); assert.ok(!page.foo('Not here')); assert.ok(page.foo('ipsum')); diff --git a/test-app/tests/unit/-private/properties/count-test.ts b/test-app/tests/unit/-private/properties/count-test.ts index e9ae9f2d..3575e057 100644 --- a/test-app/tests/unit/-private/properties/count-test.ts +++ b/test-app/tests/unit/-private/properties/count-test.ts @@ -2,12 +2,12 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { create, count } from 'ember-cli-page-object'; import { module, test } from 'qunit'; -module('count', function(hooks) { +module('count', function (hooks) { setupRenderingTest(hooks); - test('returns the number of elements that match the selector', async function(this: TestContext, assert) { - let page = create({ - foo: count('span') + test('returns the number of elements that match the selector', async function (this: TestContext, assert) { + const page = create({ + foo: count('span'), }); await this.createTemplate(` @@ -18,9 +18,9 @@ module('count', function(hooks) { assert.equal(page.foo, 2); }); - test('returns 0 when the no element is matched', async function(this: TestContext, assert) { - let page = create({ - foo: count('span') + test('returns 0 when the no element is matched', async function (this: TestContext, assert) { + const page = create({ + foo: count('span'), }); await this.createTemplate(''); @@ -28,9 +28,9 @@ module('count', function(hooks) { assert.equal(page.foo, 0); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: count('span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: count('span', { scope: '.scope' }), }); await this.createTemplate(` @@ -41,11 +41,11 @@ module('count', function(hooks) { assert.equal(page.foo, 2); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: count('span') + foo: count('span'), }); await this.createTemplate(` @@ -56,11 +56,11 @@ module('count', function(hooks) { assert.equal(page.foo, 2); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: count('span', { resetScope: true }) + foo: count('span', { resetScope: true }), }); await this.createTemplate(` @@ -71,23 +71,27 @@ module('count', function(hooks) { assert.equal(page.foo, 1); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: count('span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: count('span', { testContainer: '#alternate-ember-testing' }), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.equal(page.foo, 2); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: count('span') + foo: count('span'), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.equal(page.foo, 2); }); diff --git a/test-app/tests/unit/-private/properties/create-test.ts b/test-app/tests/unit/-private/properties/create-test.ts index 28b6c0be..7c495961 100644 --- a/test-app/tests/unit/-private/properties/create-test.ts +++ b/test-app/tests/unit/-private/properties/create-test.ts @@ -7,13 +7,13 @@ module('create', function () { setupRenderingTest(hooks); test('creates new page object', async function (this: TestContext, assert) { - let page = create({ + const page = create({ get foo() { return 'a value'; }, bar: { get baz() { - return 'another value' + return 'another value'; }, }, }); @@ -25,7 +25,7 @@ module('create', function () { }); test('resets scope', async function (this: TestContext, assert) { - let page = create({ + const page = create({ scope: '.invalid-scope', foo: { @@ -45,8 +45,8 @@ module('create', function () { }); test('does not mutate definition object', async function (this: TestContext, assert) { - let prop = text('.baz'); - let expected = { + const prop = text('.baz'); + const expected = { scope: '.a-scope', foo: { baz: prop, @@ -54,7 +54,7 @@ module('create', function () { bar: prop, }; - let actual = { + const actual = { scope: '.a-scope', foo: { baz: prop, @@ -69,7 +69,7 @@ module('create', function () { }); test('generates a default scope', async function (this: TestContext, assert) { - let page = create({}); + const page = create({}); await this.createTemplate('

Lorem ipsum

'); diff --git a/test-app/tests/unit/-private/properties/dsl-test.ts b/test-app/tests/unit/-private/properties/dsl-test.ts index 97840cc6..9649d75c 100644 --- a/test-app/tests/unit/-private/properties/dsl-test.ts +++ b/test-app/tests/unit/-private/properties/dsl-test.ts @@ -7,7 +7,7 @@ module('dsl', function (hooks) { setupRenderingTest(hooks); test('generates .isVisible', async function (this: TestContext, assert) { - let page = create({ + const page = create({ scope: 'span', foo: {}, }); @@ -19,7 +19,7 @@ module('dsl', function (hooks) { }); test('generates .isHidden', async function (this: TestContext, assert) { - let page = create({ + const page = create({ scope: 'span', foo: {}, }); @@ -31,7 +31,7 @@ module('dsl', function (hooks) { }); test('generates .isPresent', async function (this: TestContext, assert) { - let page = create({ + const page = create({ scope: 'span', foo: {}, }); @@ -57,7 +57,7 @@ module('dsl', function (hooks) { 'value', ].forEach((prop) => { test(`does not override .${prop}`, async function (this: TestContext, assert) { - let page = create({ + const page = create({ get [prop]() { return 'foo bar'; }, @@ -72,7 +72,7 @@ module('dsl', function (hooks) { test('generates .blur', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'button', }, @@ -90,7 +90,7 @@ module('dsl', function (hooks) { test('generates .clickOn', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: {}, }); @@ -106,7 +106,7 @@ module('dsl', function (hooks) { test('generates .click', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'button', }, @@ -114,13 +114,15 @@ module('dsl', function (hooks) { await this.createTemplate(''); - (find('button') as HTMLElement).addEventListener('click', () => assert.ok(1)); + (find('button') as HTMLElement).addEventListener('click', () => + assert.ok(1) + ); await page.foo.click(); }); test('generates .contains', async function (this: TestContext, assert) { - let page = create({ + const page = create({ foo: { scope: 'span', }, @@ -132,7 +134,7 @@ module('dsl', function (hooks) { }); test('generates .text', async function (this: TestContext, assert) { - let page = create({ + const page = create({ scope: '.scope', foo: { scope: 'span', @@ -151,7 +153,7 @@ module('dsl', function (hooks) { test('generates .fillIn', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'input', }, @@ -167,7 +169,7 @@ module('dsl', function (hooks) { test('generates .focus', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'button', }, @@ -175,7 +177,9 @@ module('dsl', function (hooks) { await this.createTemplate(''); - (find('button') as HTMLElement).addEventListener('focus', () => assert.ok(1)); + (find('button') as HTMLElement).addEventListener('focus', () => + assert.ok(1) + ); await page.foo.focus(); }); @@ -183,7 +187,7 @@ module('dsl', function (hooks) { test('generates .select', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'input', }, @@ -201,7 +205,7 @@ module('dsl', function (hooks) { test('generates .value', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { scope: 'input', }, @@ -213,7 +217,7 @@ module('dsl', function (hooks) { }); test('generates .then', async function (this: TestContext, assert) { - let page = create({ + const page = create({ foo: {}, }); @@ -226,7 +230,7 @@ module('dsl', function (hooks) { test('generates .as', async function (this: TestContext, assert) { assert.expect(2); - let page = create({ + const page = create({ scope: 'span', foo: { get baz() { @@ -239,7 +243,7 @@ module('dsl', function (hooks) { // @ts-expect-error no types exposed. // @todo: deprecate and remove the `as()` - let foo = page.foo.as((element) => { + const foo = page.foo.as((element) => { assert.equal(element.text, 'ipsum'); }); @@ -249,7 +253,7 @@ module('dsl', function (hooks) { test('generates .as when nested', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ scope: 'span', foo: { bar: { @@ -272,7 +276,7 @@ module('dsl', function (hooks) { test('generates .as in collections', async function (this: TestContext, assert) { assert.expect(2); - let page = create({ + const page = create({ items: collection('ul li'), }); diff --git a/test-app/tests/unit/-private/properties/fillable-test.ts b/test-app/tests/unit/-private/properties/fillable-test.ts index 56b25e24..4930db0b 100644 --- a/test-app/tests/unit/-private/properties/fillable-test.ts +++ b/test-app/tests/unit/-private/properties/fillable-test.ts @@ -4,25 +4,28 @@ import { render, find } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; import { module, test } from 'qunit'; -module('fillable', function(hooks) { +module('fillable', function (hooks) { setupRenderingTest(hooks); - test("calls fillIn method belonging to execution context", async function(assert) { + test('calls fillIn method belonging to execution context', async function (assert) { assert.expect(1); - let expectedSelector = 'input'; - let expectedText = 'dummy text'; + const expectedSelector = 'input'; + const expectedText = 'dummy text'; let page; page = create({ - foo: fillable(expectedSelector) + foo: fillable(expectedSelector), }); await render(hbs``); await page.foo(expectedText); - assert.equal((find(expectedSelector) as HTMLInputElement).value, expectedText); + assert.equal( + (find(expectedSelector) as HTMLInputElement).value, + expectedText + ); }); const formControlTemplates = [ @@ -45,18 +48,18 @@ module('fillable', function(hooks) { '', ]; - formControlTemplates.forEach(template => { - let gtPos = template.indexOf('='); - let name = template.substr(1, gtPos - 1); + formControlTemplates.forEach((template) => { + const gtPos = template.indexOf('='); + const name = template.substr(1, gtPos - 1); const [tagName, attrName] = name.split(' '); - test(`looks for ${tagName} with ${attrName}`, async function(this: TestContext, assert) { - ( this as any ).template = template; - let expectedText = 'dummy text'; - let clue = 'clue'; - let page = create({ + test(`looks for ${tagName} with ${attrName}`, async function (this: TestContext, assert) { + (this as any).template = template; + const expectedText = 'dummy text'; + const clue = 'clue'; + const page = create({ scope: '.scope', - foo: fillable() + foo: fillable(), }); await this.createTemplate(`
${this['template']}
`); @@ -64,20 +67,31 @@ module('fillable', function(hooks) { await page.foo(clue, expectedText); assert.equal( - (find(`${tagName}[${attrName}="${clue}"]`) as HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement).value, + ( + find(`${tagName}[${attrName}="${clue}"]`) as + | HTMLInputElement + | HTMLSelectElement + | HTMLTextAreaElement + ).value, expectedText ); }); }); - const targetAttributes = ['data-test', 'aria-label', 'placeholder', 'name', 'id']; - targetAttributes.forEach(attrName => { - test(`looks for [contenteditable] with ${attrName}`, async function(this: TestContext, assert) { - let expectedText = 'dummy text'; - let clue = 'clue'; - let page = create({ + const targetAttributes = [ + 'data-test', + 'aria-label', + 'placeholder', + 'name', + 'id', + ]; + targetAttributes.forEach((attrName) => { + test(`looks for [contenteditable] with ${attrName}`, async function (this: TestContext, assert) { + const expectedText = 'dummy text'; + const clue = 'clue'; + const page = create({ scope: '.scope', - foo: fillable() + foo: fillable(), }); this[attrName] = attrName; @@ -92,42 +106,48 @@ module('fillable', function(hooks) { }); }); - test('looks for elements inside the scope', async function(assert) { + test('looks for elements inside the scope', async function (assert) { assert.expect(1); - let page = create({ - foo: fillable('input', { scope: '.scope' }) + const page = create({ + foo: fillable('input', { scope: '.scope' }), }); await render(hbs`
`); await page.foo('dummy text'); - assert.equal((find('.scope input') as HTMLInputElement).value, 'dummy text'); + assert.equal( + (find('.scope input') as HTMLInputElement).value, + 'dummy text' + ); }); - test("looks for elements inside page's scope", async function(assert) { + test("looks for elements inside page's scope", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: fillable('input') + foo: fillable('input'), }); await render(hbs`
`); await page.foo('dummy text'); - assert.equal((find('.scope input') as HTMLInputElement).value, 'dummy text'); + assert.equal( + (find('.scope input') as HTMLInputElement).value, + 'dummy text' + ); }); - test('resets scope', async function(assert) { + test('resets scope', async function (assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: fillable('input', { resetScope: true }) + foo: fillable('input', { resetScope: true }), }); await render(hbs``); @@ -137,87 +157,99 @@ module('fillable', function(hooks) { assert.equal((find('input') as HTMLInputElement).value, 'dummy text'); }); - test('returns chainable object', async function(assert) { + test('returns chainable object', async function (assert) { assert.expect(1); - let page = create({ - foo: fillable('input') + const page = create({ + foo: fillable('input'), }); await render(hbs``); - let ret = page.foo('dummy text'); + const ret = page.foo('dummy text'); assert.ok(ret.foo); await ret; }); - test('finds element by index', async function(assert) { + test('finds element by index', async function (assert) { assert.expect(1); - let page = create({ - foo: fillable('input', { at: 3 }) + const page = create({ + foo: fillable('input', { at: 3 }), }); await render(hbs``); await page.foo('dummy text'); - assert.equal((find('input:nth-of-type(4)') as HTMLInputElement).value, 'dummy text'); + assert.equal( + (find('input:nth-of-type(4)') as HTMLInputElement).value, + 'dummy text' + ); }); - test('is aliased to selectable', async function(assert) { + test('is aliased to selectable', async function (assert) { assert.expect(1); - let expectedSelector = 'input'; - let expectedText = 'dummy text'; - let page = create({ - foo: selectable(expectedSelector) + const expectedSelector = 'input'; + const expectedText = 'dummy text'; + const page = create({ + foo: selectable(expectedSelector), }); await render(hbs``); await page.foo(expectedText); - assert.equal((find(expectedSelector) as HTMLInputElement).value, expectedText); + assert.equal( + (find(expectedSelector) as HTMLInputElement).value, + expectedText + ); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { + test('looks for elements outside the testing container', async function (this: TestContext, assert) { assert.expect(1); - let expectedText = 'foo'; - let page = create({ - foo: fillable('input', { testContainer: '#alternate-ember-testing' }) + const expectedText = 'foo'; + const page = create({ + foo: fillable('input', { testContainer: '#alternate-ember-testing' }), }); await this.createTemplate(``, { useAlternateContainer: true }); await page.foo(expectedText); - assert.equal(this.findExternal('input')?.value, expectedText); + assert.equal( + this.findExternal('input')?.value, + expectedText + ); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { assert.expect(1); - let expectedText = 'foo'; - let page = create({ + const expectedText = 'foo'; + const page = create({ testContainer: '#alternate-ember-testing', - foo: fillable('input') + foo: fillable('input'), }); await this.createTemplate(``, { useAlternateContainer: true }); await page.foo(expectedText); - assert.equal(this.findExternal('input')?.value, expectedText); + assert.equal( + this.findExternal('input')?.value, + expectedText + ); }); - test(`raises an error when can't find an element by clue`, async function(assert) { - let clue = 'clue'; + test(`raises an error when can't find an element by clue`, async function (assert) { + const clue = 'clue'; - let page = create({ + const page = create({ scope: '.scope', - fillInByClue: fillable() + fillInByClue: fillable(), }); await render(hbs``); @@ -227,17 +259,17 @@ module('fillable', function(hooks) { }, /Can\ not\ find\ element\ by\ clue:\ \"clue\"\./); }); - test("raises an error when the element doesn't exist", async function(assert) { + test("raises an error when the element doesn't exist", async function (assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: fillable('input') - } - } - } + qux: fillable('input'), + }, + }, + }, }); await render(hbs``); @@ -251,9 +283,9 @@ module('fillable', function(hooks) { ); }); - test('raises an error when the element has contenteditable="false"', async function(assert) { - let page = create({ - foo: fillable('[contenteditable]') + test('raises an error when the element has contenteditable="false"', async function (assert) { + const page = create({ + foo: fillable('[contenteditable]'), }); await render(hbs`
`); diff --git a/test-app/tests/unit/-private/properties/focusable-test.ts b/test-app/tests/unit/-private/properties/focusable-test.ts index cc14e4c6..1db714b1 100644 --- a/test-app/tests/unit/-private/properties/focusable-test.ts +++ b/test-app/tests/unit/-private/properties/focusable-test.ts @@ -3,14 +3,14 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; import { find } from '@ember/test-helpers'; -module('focusable', function(hooks) { +module('focusable', function (hooks) { setupRenderingTest(hooks); - test('calls focus with proper args', async function(this: TestContext, assert) { + test('calls focus with proper args', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: focusable('input') + const page = create({ + foo: focusable('input'), }); await this.createTemplate(''); @@ -22,17 +22,17 @@ module('focusable', function(hooks) { await page.foo(); }); - test('actually focuses the element', async function(this: TestContext, assert) { + test('actually focuses the element', async function (this: TestContext, assert) { assert.expect(2); - let expectedSelector = 'input'; - let page = create({ - foo: focusable(expectedSelector) + const expectedSelector = 'input'; + const page = create({ + foo: focusable(expectedSelector), }); await this.createTemplate(''); - let input = find('input')!; + const input = find('input')!; input.addEventListener('focus', () => { assert.ok(1, 'focussed'); @@ -42,11 +42,11 @@ module('focusable', function(hooks) { await page.foo(); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { + test('looks for elements inside the scope', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: focusable('input', { scope: '.scope' }) + const page = create({ + foo: focusable('input', { scope: '.scope' }), }); await this.createTemplate('
'); @@ -55,13 +55,13 @@ module('focusable', function(hooks) { await page.foo(); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { + test("looks for elements inside page's scope", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: focusable('input') + foo: focusable('input'), }); await this.createTemplate('
'); @@ -71,12 +71,12 @@ module('focusable', function(hooks) { await page.foo(); }); - test('resets scope', async function(this: TestContext, assert) { + test('resets scope', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: focusable('input', { resetScope: true }) + foo: focusable('input', { resetScope: true }), }); await this.createTemplate(''); @@ -86,27 +86,27 @@ module('focusable', function(hooks) { await page.foo(); }); - test('returns chainable object', async function(this: TestContext, assert) { + test('returns chainable object', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: focusable('input') + const page = create({ + foo: focusable('input'), }); await this.createTemplate(''); - let ret = page.foo(); + const ret = page.foo(); assert.ok(ret.foo); return ret; }); - test('finds element by index', async function(this: TestContext, assert) { + test('finds element by index', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: focusable('input', { at: 3 }) + const page = create({ + foo: focusable('input', { at: 3 }), }); await this.createTemplate(''); @@ -115,59 +115,67 @@ module('focusable', function(hooks) { await page.foo(); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { + test('looks for elements outside the testing container', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: focusable('input', { testContainer: '#alternate-ember-testing' }) + const page = create({ + foo: focusable('input', { testContainer: '#alternate-ember-testing' }), }); await this.createTemplate('', { useAlternateContainer: true }); - document.querySelector('#alternate-ember-testing input')!.addEventListener('focus', () => assert.ok(1)); + document + .querySelector('#alternate-ember-testing input')! + .addEventListener('focus', () => assert.ok(1)); await page.foo(); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ testContainer: '#alternate-ember-testing', - foo: focusable('input') + foo: focusable('input'), }); await this.createTemplate('', { useAlternateContainer: true }); - document.querySelector('#alternate-ember-testing input')!.addEventListener('focus', () => assert.ok(1)); + document + .querySelector('#alternate-ember-testing input')! + .addEventListener('focus', () => assert.ok(1)); await page.foo(); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: focusable('button') - } - } - } + qux: focusable('button'), + }, + }, + }, }); await this.createTemplate(''); - await assert.throws(function() { - return page.foo.bar.baz.qux(); - }, /page\.foo\.bar\.baz\.qux/, 'Element not found'); + await assert.throws( + function () { + return page.foo.bar.baz.qux(); + }, + /page\.foo\.bar\.baz\.qux/, + 'Element not found' + ); }); - test('Does not raise error when focussing focusable elements', async function(this: TestContext, assert) { + test('Does not raise error when focussing focusable elements', async function (this: TestContext, assert) { assert.expect(0); - let page = create({ + const page = create({ foo: { bar: { input: focusable('input'), @@ -176,8 +184,8 @@ module('focusable', function(hooks) { button: focusable('button'), contentEditable: focusable('[contenteditable]'), tabindex: focusable('[tabindex]'), - } - } + }, + }, }); await this.createTemplate(` @@ -197,18 +205,18 @@ module('focusable', function(hooks) { await page.foo.bar.tabindex(); }); - test('raises an error when the element is not focusable', async function(this: TestContext, assert) { + test('raises an error when the element is not focusable', async function (this: TestContext, assert) { assert.expect(2); - let page = create({ + const page = create({ foo: { bar: { baz: focusable('span'), qux: focusable('input'), quux: focusable('button'), - quuz: focusable('[contenteditable]') - } - } + quuz: focusable('[contenteditable]'), + }, + }, }); await this.createTemplate(` diff --git a/test-app/tests/unit/-private/properties/getter-test.ts b/test-app/tests/unit/-private/properties/getter-test.ts index f5584089..4f75a324 100644 --- a/test-app/tests/unit/-private/properties/getter-test.ts +++ b/test-app/tests/unit/-private/properties/getter-test.ts @@ -1,26 +1,22 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; -import { - create, - property, - value -} from 'ember-cli-page-object'; +import { create, property, value } from 'ember-cli-page-object'; import { getter } from 'ember-cli-page-object/macros'; import { module, test } from 'qunit'; import { findOne } from 'ember-cli-page-object/extend'; -module('getter', function(hooks) { +module('getter', function (hooks) { setupRenderingTest(hooks); - test('returns the result of the passed-in function', function(this: TestContext, assert) { + test('returns the result of the passed-in function', function (this: TestContext, assert) { assert.expect(2); const page = create({ - foo: getter(function() { + foo: getter(function () { return 'lorem'; }), - bar: getter(function() { + bar: getter(function () { return 'ipsum'; - }) + }), }); assert.equal(page.foo, 'lorem'); @@ -33,18 +29,18 @@ module('getter', function(hooks) { type Getter = ReturnType>; type Definition = { - inputValue: Getter, - isSubmitButtonDisabled: Getter, - isFormEmpty: Getter - } + inputValue: Getter; + isSubmitButtonDisabled: Getter; + isFormEmpty: Getter; + }; const def: Definition = { inputValue: value('input'), isSubmitButtonDisabled: property('disabled', 'button'), - isFormEmpty: getter (function() { + isFormEmpty: getter(function () { return !this.inputValue && this.isSubmitButtonDisabled; - }) - } + }), + }; const page = create(def); await this.createTemplate(` @@ -55,34 +51,37 @@ module('getter', function(hooks) { assert.true(page.isFormEmpty); }); - test('calls the passed-in function with the property key', function(this: TestContext, assert) { + test('calls the passed-in function with the property key', function (this: TestContext, assert) { assert.expect(2); const page = create({ - foo: getter(function(key) { + foo: getter(function (key) { assert.equal(key, 'foo'); return true; - }) + }), }); assert.ok(page.foo); }); - test('throws an error if a function is not passed in', function(this: TestContext, assert) { + test('throws an error if a function is not passed in', function (this: TestContext, assert) { assert.expect(1); try { getter('not a function' as any); } catch (e) { - assert.strictEqual(e?.toString(), `Error: Argument passed to \`getter\` must be a function.`) + assert.strictEqual( + e?.toString(), + `Error: Argument passed to \`getter\` must be a function.` + ); } }); - test('supplies correct path in error message', function(this: TestContext, assert) { + test('supplies correct path in error message', function (this: TestContext, assert) { assert.expect(1); const page = create({ - foo: getter(function() { + foo: getter(function () { throw new Error('custom error message'); }), }); @@ -91,17 +90,20 @@ module('getter', function(hooks) { page.foo; assert.true(false); } catch (e) { - assert.strictEqual(e?.toString(), `Error: custom error message + assert.strictEqual( + e?.toString(), + `Error: custom error message -PageObject: \'page.foo\'`) +PageObject: \'page.foo\'` + ); } }); - test('supplies correct selector in error message', function(this: TestContext, assert) { + test('supplies correct selector in error message', function (this: TestContext, assert) { assert.expect(1); const page = create({ - foo: getter(function() { + foo: getter(function () { findOne(this, '.non-existing-scope'); }), }); diff --git a/test-app/tests/unit/-private/properties/has-class-test.ts b/test-app/tests/unit/-private/properties/has-class-test.ts index a4013635..7f8bf6b9 100644 --- a/test-app/tests/unit/-private/properties/has-class-test.ts +++ b/test-app/tests/unit/-private/properties/has-class-test.ts @@ -2,38 +2,42 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { create, hasClass } from 'ember-cli-page-object'; import { module, test } from 'qunit'; -module('hasClass', function(hooks) { +module('hasClass', function (hooks) { setupRenderingTest(hooks); - test('returns true when the element has the class', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('ipsum', 'span') + test('returns true when the element has the class', async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('ipsum', 'span'), }); - await this.createTemplate(''); + await this.createTemplate( + '' + ); assert.ok(page.foo); }); - test('returns false when the element doesn\'t have the class', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('lorem', 'span') + test("returns false when the element doesn't have the class", async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('lorem', 'span'), }); - await this.createTemplate(''); + await this.createTemplate( + '' + ); assert.ok(!page.foo); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: hasClass('lorem', 'span') - } - } - } + qux: hasClass('lorem', 'span'), + }, + }, + }, }); await this.createTemplate(''); @@ -41,9 +45,9 @@ module('hasClass', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('ipsum', 'span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('ipsum', 'span', { scope: '.scope' }), }); await this.createTemplate(` @@ -58,11 +62,11 @@ module('hasClass', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: hasClass('ipsum', 'span') + foo: hasClass('ipsum', 'span'), }); await this.createTemplate(` @@ -77,11 +81,11 @@ module('hasClass', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: hasClass('lorem', '.foo span', { resetScope: true }) + foo: hasClass('lorem', '.foo span', { resetScope: true }), }); await this.createTemplate(` @@ -96,9 +100,9 @@ module('hasClass', function(hooks) { assert.ok(page.foo); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('lorem', 'span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('lorem', 'span'), }); await this.createTemplate(` @@ -106,13 +110,15 @@ module('hasClass', function(hooks) { `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('ipsum', 'span', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('ipsum', 'span', { at: 1 }), }); await this.createTemplate(` @@ -123,23 +129,29 @@ module('hasClass', function(hooks) { assert.ok(page.foo); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: hasClass('lorem', 'span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: hasClass('lorem', 'span', { + testContainer: '#alternate-ember-testing', + }), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: hasClass('lorem', 'span') + foo: hasClass('lorem', 'span'), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(page.foo); }); diff --git a/test-app/tests/unit/-private/properties/is-hidden-test.ts b/test-app/tests/unit/-private/properties/is-hidden-test.ts index 311c8bf9..04aef911 100644 --- a/test-app/tests/unit/-private/properties/is-hidden-test.ts +++ b/test-app/tests/unit/-private/properties/is-hidden-test.ts @@ -2,12 +2,12 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { create, isHidden } from 'ember-cli-page-object'; import { module, test } from 'qunit'; -module('isHidden', function(hooks) { +module('isHidden', function (hooks) { setupRenderingTest(hooks); - test('returns true when the element is hidden', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('span') + test('returns true when the element is hidden', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('span'), }); await this.createTemplate('Lorem ipsum'); @@ -15,9 +15,9 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test("returns true when the element doesn't exist in the DOM", async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('span') + test("returns true when the element doesn't exist in the DOM", async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('span'), }); await this.createTemplate(''); @@ -25,9 +25,9 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test('returns false when the element is visible', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('span') + test('returns false when the element is visible', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('span'), }); await this.createTemplate('Lorem ipsum'); @@ -35,9 +35,9 @@ module('isHidden', function(hooks) { assert.ok(!page.foo); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('span', { scope: '.scope' }), }); await this.createTemplate(` @@ -49,11 +49,11 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isHidden('span') + foo: isHidden('span'), }); await this.createTemplate(` @@ -65,11 +65,11 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isHidden('span', { resetScope: true, at: 0 }) + foo: isHidden('span', { resetScope: true, at: 0 }), }); await this.createTemplate(` @@ -81,9 +81,9 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('em') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('em'), }); await this.createTemplate(` @@ -91,13 +91,15 @@ module('isHidden', function(hooks) { dolor `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('em', { at: 2 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('em', { at: 2 }), }); await this.createTemplate(` @@ -109,26 +111,30 @@ module('isHidden', function(hooks) { assert.ok(page.foo); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: isHidden('span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: isHidden('span', { testContainer: '#alternate-ember-testing' }), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: isHidden('span') + foo: isHidden('span'), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); diff --git a/test-app/tests/unit/-private/properties/is-present-test.ts b/test-app/tests/unit/-private/properties/is-present-test.ts index c8cc642d..c28424d5 100644 --- a/test-app/tests/unit/-private/properties/is-present-test.ts +++ b/test-app/tests/unit/-private/properties/is-present-test.ts @@ -2,13 +2,12 @@ import { create, isPresent } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; - -module('isPresent', function(hooks) { +module('isPresent', function (hooks) { setupRenderingTest(hooks); - test('returns true when the element is visible', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span') + test('returns true when the element is visible', async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span'), }); await this.createTemplate('Lorem ipsum'); @@ -16,9 +15,9 @@ module('isPresent', function(hooks) { assert.ok(page.foo); }); - test('returns true when the element is hidden', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span') + test('returns true when the element is hidden', async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span'), }); await this.createTemplate('Lorem ipsum'); @@ -26,9 +25,9 @@ module('isPresent', function(hooks) { assert.ok(page.foo); }); - test('returns false when the element doesn\'t exist', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span') + test("returns false when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span'), }); await this.createTemplate(''); @@ -36,9 +35,9 @@ module('isPresent', function(hooks) { assert.ok(!page.foo); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span', { scope: '.scope', at: 0 }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span', { scope: '.scope', at: 0 }), }); await this.createTemplate(` @@ -49,11 +48,11 @@ module('isPresent', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isPresent('span', { at: 0 }) + foo: isPresent('span', { at: 0 }), }); await this.createTemplate(` @@ -64,11 +63,11 @@ module('isPresent', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isPresent('span', { resetScope: true, at: 0 }) + foo: isPresent('span', { resetScope: true, at: 0 }), }); await this.createTemplate(` @@ -79,9 +78,9 @@ module('isPresent', function(hooks) { assert.ok(page.foo); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span'), }); await this.createTemplate(` @@ -90,14 +89,16 @@ module('isPresent', function(hooks) { dolor `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ foo: isPresent('em', { at: 0 }), - bar: isPresent('em', { at: 2 }) + bar: isPresent('em', { at: 2 }), }); await this.createTemplate(` @@ -109,26 +110,30 @@ module('isPresent', function(hooks) { assert.ok(!page.bar); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: isPresent('span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: isPresent('span', { testContainer: '#alternate-ember-testing' }), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: isPresent('span') + foo: isPresent('span'), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); diff --git a/test-app/tests/unit/-private/properties/is-visible-test.ts b/test-app/tests/unit/-private/properties/is-visible-test.ts index a2dece49..9d351a5a 100644 --- a/test-app/tests/unit/-private/properties/is-visible-test.ts +++ b/test-app/tests/unit/-private/properties/is-visible-test.ts @@ -2,13 +2,12 @@ import { create, isVisible } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; - -module('isVisible', function(hooks) { +module('isVisible', function (hooks) { setupRenderingTest(hooks); - test('returns true when the element is visible', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span') + test('returns true when the element is visible', async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span'), }); await this.createTemplate('Lorem ipsum'); @@ -16,9 +15,9 @@ module('isVisible', function(hooks) { assert.ok(page.foo); }); - test('returns false when the element is hidden', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span') + test('returns false when the element is hidden', async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span'), }); await this.createTemplate('Lorem ipsum'); @@ -26,9 +25,9 @@ module('isVisible', function(hooks) { assert.ok(!page.foo); }); - test('returns false when the element doesn\'t exist', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span') + test("returns false when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span'), }); await this.createTemplate(''); @@ -36,9 +35,9 @@ module('isVisible', function(hooks) { assert.ok(!page.foo); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span', { scope: '.scope', at: 0 }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span', { scope: '.scope', at: 0 }), }); await this.createTemplate(` @@ -49,11 +48,11 @@ module('isVisible', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isVisible('span', { at: 0 }) + foo: isVisible('span', { at: 0 }), }); await this.createTemplate(` @@ -64,11 +63,11 @@ module('isVisible', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: isVisible('span', { resetScope: true, at: 0 }) + foo: isVisible('span', { resetScope: true, at: 0 }), }); await this.createTemplate(` @@ -79,9 +78,9 @@ module('isVisible', function(hooks) { assert.ok(page.foo); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span'), }); await this.createTemplate(` @@ -90,14 +89,16 @@ module('isVisible', function(hooks) { dolor `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ foo: isVisible('em', { at: 0 }), - bar: isVisible('em', { at: 2 }) + bar: isVisible('em', { at: 2 }), }); await this.createTemplate(` @@ -110,26 +111,30 @@ module('isVisible', function(hooks) { assert.ok(page.bar); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: isVisible('span', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: isVisible('span', { testContainer: '#alternate-ember-testing' }), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: isVisible('span') + foo: isVisible('span'), }); // FIXME the order we call createTemplate here is important! (it shouldn't, that's why there's a FIXME tag) - await this.createTemplate('ipsum', { useAlternateContainer: true }); + await this.createTemplate('ipsum', { + useAlternateContainer: true, + }); await this.createTemplate('ipsum'); assert.ok(page.foo); diff --git a/test-app/tests/unit/-private/properties/native-getter-test.ts b/test-app/tests/unit/-private/properties/native-getter-test.ts index 91d3086b..10352880 100644 --- a/test-app/tests/unit/-private/properties/native-getter-test.ts +++ b/test-app/tests/unit/-private/properties/native-getter-test.ts @@ -1,24 +1,20 @@ import hbs from 'htmlbars-inline-precompile'; import { render } from '@ember/test-helpers'; -import { - create, - property, - value -} from 'ember-cli-page-object'; +import { create, property, value } from 'ember-cli-page-object'; import { setupRenderingTest } from '../../../helpers'; import { module, test } from 'qunit'; -module('native getter', function(hooks) { +module('native getter', function (hooks) { setupRenderingTest(hooks); - test('returns the result of the passed-in function', function(assert) { + test('returns the result of the passed-in function', function (assert) { const page = create({ get foo() { return 'lorem'; }, get bar() { return 'ipsum'; - } + }, }); assert.equal(page.foo, 'lorem'); @@ -31,7 +27,7 @@ module('native getter', function(hooks) { isSubmitButtonDisabled: property('disabled', 'button'), get isFormEmpty(): boolean { return !this.inputValue && this.isSubmitButtonDisabled; - } + }, }); await render(hbs` diff --git a/test-app/tests/unit/-private/properties/not-has-class-test.ts b/test-app/tests/unit/-private/properties/not-has-class-test.ts index 1b0cc0cf..05757eaa 100644 --- a/test-app/tests/unit/-private/properties/not-has-class-test.ts +++ b/test-app/tests/unit/-private/properties/not-has-class-test.ts @@ -2,12 +2,12 @@ import { create, notHasClass } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; -module('notHasClass', function(hooks) { +module('notHasClass', function (hooks) { setupRenderingTest(hooks); - test('returns false when the element has the class', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('ipsum', '.lorem') + test('returns false when the element has the class', async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('ipsum', '.lorem'), }); await this.createTemplate(''); @@ -15,9 +15,9 @@ module('notHasClass', function(hooks) { assert.ok(!page.foo); }); - test('returns true when the element doesn\'t have the class', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('ipsum', '.lorem') + test("returns true when the element doesn't have the class", async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('ipsum', '.lorem'), }); await this.createTemplate(''); @@ -25,15 +25,15 @@ module('notHasClass', function(hooks) { assert.ok(page.foo); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: notHasClass('has-error', '.element') - } - } - } + qux: notHasClass('has-error', '.element'), + }, + }, + }, }); await this.createTemplate(''); @@ -41,9 +41,9 @@ module('notHasClass', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('lorem', 'span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('lorem', 'span', { scope: '.scope' }), }); await this.createTemplate(` @@ -58,11 +58,11 @@ module('notHasClass', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: notHasClass('lorem', 'span') + foo: notHasClass('lorem', 'span'), }); await this.createTemplate(` @@ -77,11 +77,11 @@ module('notHasClass', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: notHasClass('ipsum', 'span', { resetScope: true, at: 0 }) + foo: notHasClass('ipsum', 'span', { resetScope: true, at: 0 }), }); await this.createTemplate(` @@ -96,9 +96,9 @@ module('notHasClass', function(hooks) { assert.ok(page.foo); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('lorem', 'span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('lorem', 'span'), }); await this.createTemplate(` @@ -106,13 +106,15 @@ module('notHasClass', function(hooks) { `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('lorem', 'span', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('lorem', 'span', { at: 1 }), }); await this.createTemplate(` @@ -123,23 +125,29 @@ module('notHasClass', function(hooks) { assert.ok(page.foo); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: notHasClass('ipsum', '.lorem', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: notHasClass('ipsum', '.lorem', { + testContainer: '#alternate-ember-testing', + }), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(!page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: notHasClass('ipsum', '.lorem') + foo: notHasClass('ipsum', '.lorem'), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(!page.foo); }); diff --git a/test-app/tests/unit/-private/properties/property-test.ts b/test-app/tests/unit/-private/properties/property-test.ts index 271c3a26..d23e454e 100644 --- a/test-app/tests/unit/-private/properties/property-test.ts +++ b/test-app/tests/unit/-private/properties/property-test.ts @@ -2,13 +2,13 @@ import { create, property } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; -module('property', function(hooks) { +module('property', function (hooks) { setupRenderingTest(hooks); - test('it works', async function(this: TestContext, assert) { - let page = create({ + test('it works', async function (this: TestContext, assert) { + const page = create({ scope: 'input', - foo: property('checked') + foo: property('checked'), }); await this.createTemplate(''); @@ -16,9 +16,9 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test('returns property value', async function(this: TestContext, assert) { - let page = create({ - foo: property('checked', ':input') + test('returns property value', async function (this: TestContext, assert) { + const page = create({ + foo: property('checked', ':input'), }); await this.createTemplate(''); @@ -26,15 +26,15 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: property('checked', ':input') - } - } - } + qux: property('checked', ':input'), + }, + }, + }, }); await this.createTemplate(''); @@ -42,9 +42,9 @@ module('property', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: property('checked', ':input', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: property('checked', ':input', { scope: '.scope' }), }); await this.createTemplate(` @@ -56,11 +56,11 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: property('checked', ':input') + foo: property('checked', ':input'), }); await this.createTemplate(` @@ -72,11 +72,11 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: property('checked', ':input', { resetScope: true }) + foo: property('checked', ':input', { resetScope: true }), }); await this.createTemplate(` @@ -87,15 +87,15 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: property('checked', ':input') - } - } - } + qux: property('checked', ':input'), + }, + }, + }, }); await this.createTemplate(''); @@ -103,9 +103,9 @@ module('property', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: property('checked', ':input') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: property('checked', ':input'), }); await this.createTemplate(` @@ -113,13 +113,15 @@ module('property', function(hooks) { `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: property('checked', ':input', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: property('checked', ':input', { at: 1 }), }); await this.createTemplate(` @@ -130,23 +132,29 @@ module('property', function(hooks) { assert.ok(page.foo); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: property('checked', ':input', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: property('checked', ':input', { + testContainer: '#alternate-ember-testing', + }), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(page.foo); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: property('checked', ':input') + foo: property('checked', ':input'), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.ok(page.foo); }); diff --git a/test-app/tests/unit/-private/properties/text-test.ts b/test-app/tests/unit/-private/properties/text-test.ts index df216819..cf89015d 100644 --- a/test-app/tests/unit/-private/properties/text-test.ts +++ b/test-app/tests/unit/-private/properties/text-test.ts @@ -2,12 +2,12 @@ import { create, text } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; -module('text', function(hooks) { +module('text', function (hooks) { setupRenderingTest(hooks); - test('returns the inner text of the element', async function(this: TestContext, assert) { - let page = create({ - foo: text('span') + test('returns the inner text of the element', async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); await this.createTemplate('Hello world!'); @@ -15,10 +15,9 @@ module('text', function(hooks) { assert.equal(page.foo, 'world!'); }); - test('removes white spaces from the beginning and end of the text', async function(this: TestContext, assert) { - - let page = create({ - foo: text('span') + test('removes white spaces from the beginning and end of the text', async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); await this.createTemplate(' awesome! '); @@ -26,21 +25,30 @@ module('text', function(hooks) { assert.equal(page.foo, 'awesome!'); }); - test('normalizes inner text of the element containing newlines', async function(this: TestContext, assert) { - let page = create({ - foo: text('span') + test('normalizes inner text of the element containing newlines', async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); - await this.createTemplate(['', 'Hello', 'multi-line', 'world!', ''].join('\n')); + await this.createTemplate( + ['', 'Hello', 'multi-line', 'world!', ''].join('\n') + ); assert.equal(page.foo, 'Hello multi-line world!'); }); - test('avoid text normalization if normalize:false', async function(this: TestContext, assert) { - let denormalizedText = [' \n ', 'Hello', 'multi-line', 'world! ', '\t', '\n'].join('\n'); - - let page = create({ - foo: text('span', { normalize: false }) + test('avoid text normalization if normalize:false', async function (this: TestContext, assert) { + const denormalizedText = [ + ' \n ', + 'Hello', + 'multi-line', + 'world! ', + '\t', + '\n', + ].join('\n'); + + const page = create({ + foo: text('span', { normalize: false }), }); await this.createTemplate(`${denormalizedText}`); @@ -48,9 +56,9 @@ module('text', function(hooks) { assert.equal(page.foo, denormalizedText); }); - test('converts   characters into standard whitespace characters', async function(this: TestContext, assert) { - let page = create({ - foo: text('span') + test('converts   characters into standard whitespace characters', async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); await this.createTemplate('This is awesome.'); @@ -58,9 +66,9 @@ module('text', function(hooks) { assert.equal(page.foo, 'This is awesome.'); }); - test("returns empty text when the element doesn't have text", async function(this: TestContext, assert) { - let page = create({ - foo: text('span') + test("returns empty text when the element doesn't have text", async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); await this.createTemplate(''); @@ -68,15 +76,15 @@ module('text', function(hooks) { assert.equal(page.foo, ''); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: text('span') - } - } - } + qux: text('span'), + }, + }, + }, }); await this.createTemplate(''); @@ -84,9 +92,9 @@ module('text', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: text('span', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: text('span', { scope: '.scope' }), }); await this.createTemplate(` @@ -98,11 +106,11 @@ module('text', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: text('span') + foo: text('span'), }); await this.createTemplate(` @@ -114,11 +122,11 @@ module('text', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: text('span', { at: 0, resetScope: true }) + foo: text('span', { at: 0, resetScope: true }), }); await this.createTemplate(` @@ -130,9 +138,9 @@ module('text', function(hooks) { assert.equal(page.foo, 'lorem'); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: text('span', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: text('span', { at: 1 }), }); await this.createTemplate(` @@ -144,8 +152,8 @@ module('text', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test('finds element without using a selector', async function(this: TestContext, assert) { - let page = create({ + test('finds element without using a selector', async function (this: TestContext, assert) { + const page = create({ scope: 'p', foo: text(), @@ -153,8 +161,8 @@ module('text', function(hooks) { bar: { scope: 'span', - baz: text() - } + baz: text(), + }, }); await this.createTemplate('

Hello world!

'); @@ -163,9 +171,9 @@ module('text', function(hooks) { assert.equal(page.bar.baz, 'world!'); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: text('span') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: text('span'), }); await this.createTemplate(` @@ -174,27 +182,33 @@ module('text', function(hooks) { dolor `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { - let page = create({ - foo: text('h1', { testContainer: '#alternate-ember-testing' }) + test('looks for elements outside the testing container', async function (this: TestContext, assert) { + const page = create({ + foo: text('h1', { testContainer: '#alternate-ember-testing' }), }); - await this.createTemplate('

lorem ipsum

', { useAlternateContainer: true }); + await this.createTemplate('

lorem ipsum

', { + useAlternateContainer: true, + }); assert.equal(page.foo, 'lorem ipsum'); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: text('h1') + foo: text('h1'), }); - await this.createTemplate('

lorem ipsum

', { useAlternateContainer: true }); + await this.createTemplate('

lorem ipsum

', { + useAlternateContainer: true, + }); assert.equal(page.foo, 'lorem ipsum'); }); diff --git a/test-app/tests/unit/-private/properties/triggerable-test.ts b/test-app/tests/unit/-private/properties/triggerable-test.ts index 2ff29616..b51435ca 100644 --- a/test-app/tests/unit/-private/properties/triggerable-test.ts +++ b/test-app/tests/unit/-private/properties/triggerable-test.ts @@ -3,15 +3,15 @@ import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; import { find } from '@ember/test-helpers'; -module('triggerable', function(hooks) { +module('triggerable', function (hooks) { setupRenderingTest(hooks); - test("calls Ember's triggerEvent helper with proper args", async function(this: TestContext, assert) { + test("calls Ember's triggerEvent helper with proper args", async function (this: TestContext, assert) { assert.expect(1); - let expectedSelector = 'input'; - let page = create({ - foo: triggerable('focus', expectedSelector) + const expectedSelector = 'input'; + const page = create({ + foo: triggerable('focus', expectedSelector), }); await this.createTemplate(''); @@ -23,55 +23,63 @@ module('triggerable', function(hooks) { await page.foo(); }); - test("calls Ember's triggerEvent helper with static event options", async function(this: TestContext, assert) { + test("calls Ember's triggerEvent helper with static event options", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('keypress', 'input', { eventProperties: { keyCode: 13 } }) + const page = create({ + foo: triggerable('keypress', 'input', { + eventProperties: { keyCode: 13 }, + }), }); await this.createTemplate(''); - find('input')!.addEventListener('keypress', (e: KeyboardEvent) => assert.equal(e.keyCode, 13)); + find('input')!.addEventListener('keypress', (e: KeyboardEvent) => + assert.equal(e.keyCode, 13) + ); await page.foo(); }); - test("calls Ember's triggerEvent helper with dynamic event options", async function(this: TestContext, assert) { + test("calls Ember's triggerEvent helper with dynamic event options", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('keypress', 'input') + const page = create({ + foo: triggerable('keypress', 'input'), }); await this.createTemplate(''); - find('input')!.addEventListener('keypress', (e: KeyboardEvent) => assert.equal(e.keyCode, 13)); + find('input')!.addEventListener('keypress', (e: KeyboardEvent) => + assert.equal(e.keyCode, 13) + ); await page.foo({ keyCode: 13 }); }); - test("overrides static event options with dynamic event options", async function(this: TestContext, assert) { + test('overrides static event options with dynamic event options', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: triggerable('keypress', 'input', { - eventProperties: { keyCode: 0 } - }) + eventProperties: { keyCode: 0 }, + }), }); await this.createTemplate(''); - find('input')!.addEventListener('keypress', (e: KeyboardEvent) => assert.equal(e.keyCode, 13)); + find('input')!.addEventListener('keypress', (e: KeyboardEvent) => + assert.equal(e.keyCode, 13) + ); await page.foo({ keyCode: 13 }); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { + test('looks for elements inside the scope', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('focus', 'input', { scope: '.scope' }) + const page = create({ + foo: triggerable('focus', 'input', { scope: '.scope' }), }); await this.createTemplate('
'); @@ -80,13 +88,13 @@ module('triggerable', function(hooks) { await page.foo(); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { + test("looks for elements inside page's scope", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: triggerable('focus', 'input') + foo: triggerable('focus', 'input'), }); await this.createTemplate('
'); @@ -96,12 +104,12 @@ module('triggerable', function(hooks) { await page.foo(); }); - test('resets scope', async function(this: TestContext, assert) { + test('resets scope', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ scope: '.scope', - foo: triggerable('focus', 'input', { resetScope: true }) + foo: triggerable('focus', 'input', { resetScope: true }), }); await this.createTemplate(''); @@ -111,25 +119,25 @@ module('triggerable', function(hooks) { await page.foo(); }); - test('returns chainable object', async function(this: TestContext, assert) { + test('returns chainable object', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('focus', 'input') + const page = create({ + foo: triggerable('focus', 'input'), }); await this.createTemplate(''); - let ret = page.foo(); + const ret = page.foo(); assert.ok(ret.foo); await ret; }); - test('finds element by index', async function(this: TestContext, assert) { + test('finds element by index', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('focus', 'input', { at: 3 }) + const page = create({ + foo: triggerable('focus', 'input', { at: 3 }), }); await this.createTemplate(''); @@ -138,52 +146,62 @@ module('triggerable', function(hooks) { await page.foo(); }); - test('looks for elements outside the testing container', async function(this: TestContext, assert) { + test('looks for elements outside the testing container', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ - foo: triggerable('focus', 'input', { testContainer: '#alternate-ember-testing' }) + const page = create({ + foo: triggerable('focus', 'input', { + testContainer: '#alternate-ember-testing', + }), }); await this.createTemplate('', { useAlternateContainer: true }); - document.querySelector('#alternate-ember-testing input')!.addEventListener('focus', () => assert.ok(1)); + document + .querySelector('#alternate-ember-testing input')! + .addEventListener('focus', () => assert.ok(1)); await page.foo(); }); - test('looks for elements within test container specified at node level', async function(this: TestContext, assert) { + test('looks for elements within test container specified at node level', async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ testContainer: '#alternate-ember-testing', - foo: triggerable('focus', 'input') + foo: triggerable('focus', 'input'), }); await this.createTemplate('', { useAlternateContainer: true }); - document.querySelector('#alternate-ember-testing input')!.addEventListener('focus', () => assert.ok(1)); + document + .querySelector('#alternate-ember-testing input')! + .addEventListener('focus', () => assert.ok(1)); await page.foo(); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { assert.expect(1); - let page = create({ + const page = create({ foo: { bar: { baz: { - qux: triggerable('focus', 'button') - } - } - } + qux: triggerable('focus', 'button'), + }, + }, + }, }); await this.createTemplate(''); - await assert.throws(function() { - return page.foo.bar.baz.qux(); - }, /page\.foo\.bar\.baz\.qux/, 'Element not found'); + await assert.throws( + function () { + return page.foo.bar.baz.qux(); + }, + /page\.foo\.bar\.baz\.qux/, + 'Element not found' + ); }); }); diff --git a/test-app/tests/unit/-private/properties/value-test.ts b/test-app/tests/unit/-private/properties/value-test.ts index 97f3df5d..d1c348a2 100644 --- a/test-app/tests/unit/-private/properties/value-test.ts +++ b/test-app/tests/unit/-private/properties/value-test.ts @@ -2,12 +2,12 @@ import { create, value } from 'ember-cli-page-object'; import { setupRenderingTest, TestContext } from '../../../helpers'; import { module, test } from 'qunit'; -module('value', function(hooks) { +module('value', function (hooks) { setupRenderingTest(hooks); - test('returns the text of the input', async function(this: TestContext, assert) { - let page = create({ - foo: value('input') + test('returns the text of the input', async function (this: TestContext, assert) { + const page = create({ + foo: value('input'), }); await this.createTemplate(''); @@ -15,19 +15,21 @@ module('value', function(hooks) { assert.equal(page.foo, 'Lorem ipsum'); }); - test('returns the html of the contenteditable', async function(this: TestContext, assert) { - let page = create({ - foo: value('[contenteditable]') + test('returns the html of the contenteditable', async function (this: TestContext, assert) { + const page = create({ + foo: value('[contenteditable]'), }); - await this.createTemplate('
Lorem ipsum
'); + await this.createTemplate( + '
Lorem ipsum
' + ); assert.equal(page.foo, 'Lorem ipsum'); }); - test('returns empty when the element doesn\'t have value attribute and is not contenteditable', async function(this: TestContext, assert) { - let page = create({ - foo: value('input') + test("returns empty when the element doesn't have value attribute and is not contenteditable", async function (this: TestContext, assert) { + const page = create({ + foo: value('input'), }); await this.createTemplate(''); @@ -35,15 +37,15 @@ module('value', function(hooks) { assert.equal(page.foo, ''); }); - test("raises an error when the element doesn't exist", async function(this: TestContext, assert) { - let page = create({ + test("raises an error when the element doesn't exist", async function (this: TestContext, assert) { + const page = create({ foo: { bar: { baz: { - qux: value('input') - } - } - } + qux: value('input'), + }, + }, + }, }); await this.createTemplate(''); @@ -51,9 +53,9 @@ module('value', function(hooks) { assert.throws(() => page.foo.bar.baz.qux, /page\.foo\.bar\.baz\.qux/); }); - test('looks for elements inside the scope', async function(this: TestContext, assert) { - let page = create({ - foo: value('input', { scope: '.scope' }) + test('looks for elements inside the scope', async function (this: TestContext, assert) { + const page = create({ + foo: value('input', { scope: '.scope' }), }); await this.createTemplate(` @@ -64,11 +66,11 @@ module('value', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test("looks for elements inside page's scope", async function(this: TestContext, assert) { - let page = create({ + test("looks for elements inside page's scope", async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: value('input') + foo: value('input'), }); await this.createTemplate(` @@ -79,11 +81,11 @@ module('value', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test('resets scope', async function(this: TestContext, assert) { - let page = create({ + test('resets scope', async function (this: TestContext, assert) { + const page = create({ scope: '.scope', - foo: value('input', { at: 0, resetScope: true }) + foo: value('input', { at: 0, resetScope: true }), }); await this.createTemplate(` @@ -94,9 +96,9 @@ module('value', function(hooks) { assert.equal(page.foo, 'lorem'); }); - test('throws error if selector matches more than one element', async function(this: TestContext, assert) { - let page = create({ - foo: value('input') + test('throws error if selector matches more than one element', async function (this: TestContext, assert) { + const page = create({ + foo: value('input'), }); await this.createTemplate(` @@ -104,13 +106,15 @@ module('value', function(hooks) { `); - assert.throws(() => page.foo, - /matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => page.foo, + /matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('finds element by index', async function(this: TestContext, assert) { - let page = create({ - foo: value('input', { at: 1 }) + test('finds element by index', async function (this: TestContext, assert) { + const page = create({ + foo: value('input', { at: 1 }), }); await this.createTemplate(` @@ -121,23 +125,27 @@ module('value', function(hooks) { assert.equal(page.foo, 'ipsum'); }); - test('looks for elements within test container specified at the property', async function(this: TestContext, assert) { - let page = create({ - foo: value('input', { testContainer: '#alternate-ember-testing' }) + test('looks for elements within test container specified at the property', async function (this: TestContext, assert) { + const page = create({ + foo: value('input', { testContainer: '#alternate-ember-testing' }), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.equal(page.foo, 'lorem'); }); - test('looks for elements within test container specified at the node', async function(this: TestContext, assert) { - let page = create({ + test('looks for elements within test container specified at the node', async function (this: TestContext, assert) { + const page = create({ testContainer: '#alternate-ember-testing', - foo: value('input') + foo: value('input'), }); - await this.createTemplate('', { useAlternateContainer: true }); + await this.createTemplate('', { + useAlternateContainer: true, + }); assert.equal(page.foo, 'lorem'); }); diff --git a/test-app/tests/unit/-private/properties/visitable-test.ts b/test-app/tests/unit/-private/properties/visitable-test.ts index 993ddb3e..8b2e8f85 100644 --- a/test-app/tests/unit/-private/properties/visitable-test.ts +++ b/test-app/tests/unit/-private/properties/visitable-test.ts @@ -3,16 +3,16 @@ import { create, visitable } from 'ember-cli-page-object'; import { module, test } from 'qunit'; import { currentURL } from '@ember/test-helpers'; -module('visitable', function(hooks) { +module('visitable', function (hooks) { setupApplicationTest(hooks); - test("calls Ember's visit helper", async function(assert) { + test("calls Ember's visit helper", async function (assert) { assert.expect(1); - let expectedRoute = '/html-render'; + const expectedRoute = '/html-render'; - let page = create({ - foo: visitable(expectedRoute) + const page = create({ + foo: visitable(expectedRoute), }); await page.foo(); @@ -20,42 +20,42 @@ module('visitable', function(hooks) { assert.equal(currentURL(), expectedRoute); }); - test('fills in dynamic segments', async function(assert) { + test('fills in dynamic segments', async function (assert) { assert.expect(1); - let page = create({ - foo: visitable('/users/:user_id/comments/:comment_id') + const page = create({ + foo: visitable('/users/:user_id/comments/:comment_id'), }); await page.foo({ user_id: 5, comment_id: 1 }); - assert.equal(currentURL(), '/users/5/comments/1') + assert.equal(currentURL(), '/users/5/comments/1'); }); - test("raises an exception if params aren't given for all dynamic segments", async function(assert) { - let page = create({ - foo: visitable('/users/:user_id') + test("raises an exception if params aren't given for all dynamic segments", async function (assert) { + const page = create({ + foo: visitable('/users/:user_id'), }); assert.throws(() => page.foo(), /Missing parameter for \'user_id\'/); assert.throws(() => page.foo(), /page\.foo\(\)/); }); - test('appends query params to the path', async function(assert) { + test('appends query params to the path', async function (assert) { assert.expect(1); - let page = create({ - foo: visitable('/html-render') + const page = create({ + foo: visitable('/html-render'), }); await page.foo({ hello: 'world', lorem: 'ipsum' }); - assert.equal(currentURL(), '/html-render?hello=world&lorem=ipsum') + assert.equal(currentURL(), '/html-render?hello=world&lorem=ipsum'); }); - test('accepts both dynamic segments and query params', async function(assert) { + test('accepts both dynamic segments and query params', async function (assert) { assert.expect(1); - let page = create({ - foo: visitable('/users/:user_id/comments/:comment_id') + const page = create({ + foo: visitable('/users/:user_id/comments/:comment_id'), }); await page.foo({ @@ -69,36 +69,36 @@ module('visitable', function(hooks) { topic: 'lts', deep: { my_array: [99, 77], - my_value: true - } - } + my_value: true, + }, + }, }); assert.equal( decodeURIComponent(currentURL()), '/users/5/comments/1' + - '?hello=world&lorem=ipsum' + - '&reply_ids[]=1&reply_ids[]=2' + - '&search[author]=ember&search[topic]=lts' + - '&search[deep][my_array][]=99&search[deep][my_array][]=77&search[deep][my_value]=true' + '?hello=world&lorem=ipsum' + + '&reply_ids[]=1&reply_ids[]=2' + + '&search[author]=ember&search[topic]=lts' + + '&search[deep][my_array][]=99&search[deep][my_array][]=77&search[deep][my_value]=true' ); }); - test('fills in encoded dynamic segments', async function(assert) { + test('fills in encoded dynamic segments', async function (assert) { assert.expect(1); - let page = create({ - foo: visitable('/users/:user_id/comments/:comment_id') + const page = create({ + foo: visitable('/users/:user_id/comments/:comment_id'), }); await page.foo({ user_id: 'a/user', comment_id: 1 }); assert.equal(currentURL(), '/users/a%2Fuser/comments/1'); }); - test('async error message', async function(assert) { - let page = create({ + test('async error message', async function (assert) { + const page = create({ scope: '.scope', - foo: visitable('/non-existing-url/:param') + foo: visitable('/non-existing-url/:param'), }); try { @@ -106,10 +106,13 @@ module('visitable', function(hooks) { assert.false(true, 'visit should have failed'); } catch (e) { - assert.strictEqual(e?.toString(), `Error: Failed to visit URL '/non-existing-url/value' + assert.strictEqual( + e?.toString(), + `Error: Failed to visit URL '/non-existing-url/value' PageObject: 'page.foo(\"[object Object]\")' - Selector: '.scope'`); + Selector: '.scope'` + ); } }); }); diff --git a/test-app/tests/unit/adapters/helpers.ts b/test-app/tests/unit/adapters/helpers.ts index db93131e..a58de036 100644 --- a/test-app/tests/unit/adapters/helpers.ts +++ b/test-app/tests/unit/adapters/helpers.ts @@ -6,20 +6,20 @@ function spyAction(assert: Assert) { let i = 0; return () => { - let id = i++; + const id = i++; assert.step(`begin #${id}`); return later(() => { assert.step(`complete #${id}`); - }, 10) + }, 10); }; } export function createClickTrackerComponent(assert: Assert) { const trackAction = spyAction(assert); - const layout = hbs`` + const layout = hbs``; return Component.extend({ layout, @@ -27,11 +27,11 @@ export function createClickTrackerComponent(assert: Assert) { actions: { trackAction() { return trackAction(); - } - } + }, + }, }); } export const ClickTrackerDef = { - scope: 'input' + scope: 'input', }; diff --git a/test-app/tests/unit/adapters/rfc268-test.ts b/test-app/tests/unit/adapters/rfc268-test.ts index 80b1c2d5..400b8611 100644 --- a/test-app/tests/unit/adapters/rfc268-test.ts +++ b/test-app/tests/unit/adapters/rfc268-test.ts @@ -2,68 +2,51 @@ import { test, module } from 'qunit'; import { render } from '@ember/test-helpers'; import { setupRenderingTest } from '../../helpers'; import hbs from 'htmlbars-inline-precompile'; -import { create } from 'ember-cli-page-object' +import { create } from 'ember-cli-page-object'; import { createClickTrackerComponent, ClickTrackerDef } from './helpers'; import { TestContext } from 'ember-test-helpers'; const node = create(ClickTrackerDef); -module('Integration | rfc268 adapter | actions', function(hooks) { +module('Integration | rfc268 adapter | actions', function (hooks) { setupRenderingTest(hooks); - hooks.beforeEach(function(this: TestContext, assert) { - this.owner.register('component:action-tracker', createClickTrackerComponent(assert)) + hooks.beforeEach(function (this: TestContext, assert) { + this.owner.register( + 'component:action-tracker', + createClickTrackerComponent(assert) + ); return render(hbs`{{action-tracker}}`); - }) + }); - test('sync invocations', async function(assert) { - node.click() + test('sync invocations', async function (assert) { + node.click(); node.click(); await node; - assert.verifySteps([ - 'begin #0', - 'begin #1', - 'complete #0', - 'complete #1' - ]) + assert.verifySteps(['begin #0', 'begin #1', 'complete #0', 'complete #1']); }); - test('async invocations', async function(assert) { - await node.click() + test('async invocations', async function (assert) { + await node.click(); await node.click(); - assert.verifySteps([ - 'begin #0', - 'complete #0', - 'begin #1', - 'complete #1' - ]) + assert.verifySteps(['begin #0', 'complete #0', 'begin #1', 'complete #1']); }); - test('async chained invocations', async function(assert) { + test('async chained invocations', async function (assert) { await node.click().click(); - assert.verifySteps([ - 'begin #0', - 'complete #0', - 'begin #1', - 'complete #1' - ]) + assert.verifySteps(['begin #0', 'complete #0', 'begin #1', 'complete #1']); }); - test('sync chained invocations', async function(assert) { + test('sync chained invocations', async function (assert) { node.click().click(); await node; - assert.verifySteps([ - 'begin #0', - 'complete #0', - 'begin #1', - 'complete #1', - ]) + assert.verifySteps(['begin #0', 'complete #0', 'begin #1', 'complete #1']); }); }); diff --git a/test-app/tests/unit/extend/find-element-test.ts b/test-app/tests/unit/extend/find-element-test.ts index 7b0a1abc..9f8c78af 100644 --- a/test-app/tests/unit/extend/find-element-test.ts +++ b/test-app/tests/unit/extend/find-element-test.ts @@ -5,11 +5,11 @@ import { findElement } from 'ember-cli-page-object/extend'; import hbs from 'htmlbars-inline-precompile'; import { render } from '@ember/test-helpers'; -module(`Extend | findElement`, function(hooks) { +module(`Extend | findElement`, function (hooks) { setupRenderingTest(hooks); - test('finds by selector and returns jQuery elements collection', async function(assert) { - let page = create({}); + test('finds by selector and returns jQuery elements collection', async function (assert) { + const page = create({}); await render(hbs`12`); @@ -23,8 +23,8 @@ module(`Extend | findElement`, function(hooks) { ); }); - test('finds deeper in scope', async function(assert) { - let page = create({ scope: '.lorem' }); + test('finds deeper in scope', async function (assert) { + const page = create({ scope: '.lorem' }); await render(hbs` @@ -43,16 +43,16 @@ module(`Extend | findElement`, function(hooks) { ); }); - test('returns empty list when no elements found', async function(assert) { - let page = create({}); + test('returns empty list when no elements found', async function (assert) { + const page = create({}); await render(hbs``); assert.deepEqual(findElement(page, '.ipsum', {}).length, 0); }); - test('testContainer param', async function(assert) { - let page = create({}); + test('testContainer param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -63,14 +63,16 @@ module(`Extend | findElement`, function(hooks) { assert.deepEqual( findElement(page, '.ipsum', { - testContainer: '.new-test-root' - }).toArray().map(e => e.innerText), + testContainer: '.new-test-root', + }) + .toArray() + .map((e) => e.innerText), ['2'] ); }); - test('resetScope param', async function(assert) { - let page = create({ scope: 'my-page' }); + test('resetScope param', async function (assert) { + const page = create({ scope: 'my-page' }); await render(hbs` 1 @@ -81,13 +83,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { resetScope: true }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { resetScope: true }) + .toArray() + .map((el) => el.innerText), ['1'] ); }); - test('contains param', async function(assert) { - let page = create({}); + test('contains param', async function (assert) { + const page = create({}); await render(hbs` @@ -95,13 +99,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { contains: 'Word' }).toArray().map((el) => el.id), + findElement(page, '.lorem', { contains: 'Word' }) + .toArray() + .map((el) => el.id), ['2'] ); }); - test('scope param', async function(assert) { - let page = create({}); + test('scope param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -111,13 +117,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { scope: '.ipsum' }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { scope: '.ipsum' }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('visible param', async function(assert) { - let page = create({}); + test('visible param', async function (assert) { + const page = create({}); await render(hbs` @@ -125,13 +133,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { visible: true }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { visible: true }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('at param', async function(assert) { - let page = create({}); + test('at param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -140,13 +150,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { at: 1 }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { at: 1 }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('last param', async function(assert) { - let page = create({}); + test('last param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -155,13 +167,15 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { last: true }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { last: true }) + .toArray() + .map((el) => el.innerText), ['3'] ); }); - test('multiple param', async function(assert) { - let page = create({}); + test('multiple param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -170,7 +184,9 @@ module(`Extend | findElement`, function(hooks) { `); assert.deepEqual( - findElement(page, '.lorem', { multiple: true }).toArray().map((el) => el.innerText), + findElement(page, '.lorem', { multiple: true }) + .toArray() + .map((el) => el.innerText), ['1', '2', '3'] ); }); diff --git a/test-app/tests/unit/extend/find-element-with-assert-test.ts b/test-app/tests/unit/extend/find-element-with-assert-test.ts index 29f43e12..061987a5 100644 --- a/test-app/tests/unit/extend/find-element-with-assert-test.ts +++ b/test-app/tests/unit/extend/find-element-with-assert-test.ts @@ -5,11 +5,11 @@ import { findElementWithAssert } from 'ember-cli-page-object/extend'; import hbs from 'htmlbars-inline-precompile'; import { render } from '@ember/test-helpers'; -module(`Extend | findElementWithAssert`, function(hooks) { +module(`Extend | findElementWithAssert`, function (hooks) { setupRenderingTest(hooks); - test('finds by selector and returns jQuery elements collection', async function(assert) { - let page = create({}); + test('finds by selector and returns jQuery elements collection', async function (assert) { + const page = create({}); await render(hbs`12`); @@ -23,8 +23,8 @@ module(`Extend | findElementWithAssert`, function(hooks) { ); }); - test('finds deeper in scope', async function(assert) { - let page = create({ scope: '.lorem' }); + test('finds deeper in scope', async function (assert) { + const page = create({ scope: '.lorem' }); await render(hbs` @@ -43,25 +43,32 @@ module(`Extend | findElementWithAssert`, function(hooks) { ); }); - test('throws error if more than 1 element found', async function(assert) { - let page = create({}); + test('throws error if more than 1 element found', async function (assert) { + const page = create({}); - await render(hbs``); + await render( + hbs`` + ); - assert.throws(() => findElementWithAssert(page, '.lorem', {}), - /Error: ".lorem" matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => findElementWithAssert(page, '.lorem', {}), + /Error: ".lorem" matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('throws error if no elements found', async function(assert) { - let page = create({}); + test('throws error if no elements found', async function (assert) { + const page = create({}); await render(hbs``); - assert.throws(() => findElementWithAssert(page, '.lorem', {}), /Error: Element not found\./); + assert.throws( + () => findElementWithAssert(page, '.lorem', {}), + /Error: Element not found\./ + ); }); - test('testContainer param', async function(assert) { - let page = create({}); + test('testContainer param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -72,14 +79,16 @@ module(`Extend | findElementWithAssert`, function(hooks) { assert.deepEqual( findElementWithAssert(page, '.ipsum', { - testContainer: '.new-test-root' - }).toArray().map(e => e.innerText), + testContainer: '.new-test-root', + }) + .toArray() + .map((e) => e.innerText), ['2'] ); }); - test('resetScope param', async function(assert) { - let page = create({ scope: 'my-page' }); + test('resetScope param', async function (assert) { + const page = create({ scope: 'my-page' }); await render(hbs` 1 @@ -90,13 +99,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { resetScope: true }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { resetScope: true }) + .toArray() + .map((el) => el.innerText), ['1'] ); }); - test('contains param', async function(assert) { - let page = create({}); + test('contains param', async function (assert) { + const page = create({}); await render(hbs` @@ -104,13 +115,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { contains: 'Word' }).toArray().map((el) => el.id), + findElementWithAssert(page, '.lorem', { contains: 'Word' }) + .toArray() + .map((el) => el.id), ['2'] ); }); - test('scope param', async function(assert) { - let page = create({}); + test('scope param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -120,13 +133,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { scope: '.ipsum' }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { scope: '.ipsum' }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('visible param', async function(assert) { - let page = create({}); + test('visible param', async function (assert) { + const page = create({}); await render(hbs` @@ -134,13 +149,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { visible: true }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { visible: true }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('at param', async function(assert) { - let page = create({}); + test('at param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -149,13 +166,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { at: 1 }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { at: 1 }) + .toArray() + .map((el) => el.innerText), ['2'] ); }); - test('last param', async function(assert) { - let page = create({}); + test('last param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -164,13 +183,15 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { last: true }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { last: true }) + .toArray() + .map((el) => el.innerText), ['3'] ); }); - test('multiple param', async function(assert) { - let page = create({}); + test('multiple param', async function (assert) { + const page = create({}); await render(hbs` 1 @@ -179,7 +200,9 @@ module(`Extend | findElementWithAssert`, function(hooks) { `); assert.deepEqual( - findElementWithAssert(page, '.lorem', { multiple: true }).toArray().map((el) => el.innerText), + findElementWithAssert(page, '.lorem', { multiple: true }) + .toArray() + .map((el) => el.innerText), ['1', '2', '3'] ); }); diff --git a/test-app/tests/unit/extend/find-many-test.ts b/test-app/tests/unit/extend/find-many-test.ts index 92fdf82e..7a291907 100644 --- a/test-app/tests/unit/extend/find-many-test.ts +++ b/test-app/tests/unit/extend/find-many-test.ts @@ -5,11 +5,11 @@ import { findMany } from 'ember-cli-page-object/extend'; import hbs from 'htmlbars-inline-precompile'; import { findAll, render } from '@ember/test-helpers'; -module(`Extend | findMany`, function(hooks) { +module(`Extend | findMany`, function (hooks) { setupRenderingTest(hooks); - test('finds by selector and returns array of Elements', async function(assert) { - let page = create({}); + test('finds by selector and returns array of Elements', async function (assert) { + const page = create({}); await render(hbs``); @@ -19,8 +19,8 @@ module(`Extend | findMany`, function(hooks) { assert.deepEqual(foundElements, findAll('.lorem')); }); - test('finds deeper in scope', async function(assert) { - let page = create({ scope: '.lorem' }); + test('finds deeper in scope', async function (assert) { + const page = create({ scope: '.lorem' }); await render(hbs` @@ -37,16 +37,16 @@ module(`Extend | findMany`, function(hooks) { assert.deepEqual(foundElements, findAll('.lorem .dolor')); }); - test('returns empty value when no elements found', async function(assert) { - let page = create({}); + test('returns empty value when no elements found', async function (assert) { + const page = create({}); await render(hbs``); assert.deepEqual(findMany(page, '.ipsum', {}), []); }); - test('testContainer param', async function(assert) { - let page = create({}); + test('testContainer param', async function (assert) { + const page = create({}); await render(hbs` @@ -56,11 +56,14 @@ module(`Extend | findMany`, function(hooks) { `); - assert.deepEqual(findMany(page, '.ipsum', { testContainer: '.new-test-root' }), findAll('.new-test-root .ipsum')); + assert.deepEqual( + findMany(page, '.ipsum', { testContainer: '.new-test-root' }), + findAll('.new-test-root .ipsum') + ); }); - test('resetScope param', async function(assert) { - let page = create({ scope: 'my-page' }); + test('resetScope param', async function (assert) { + const page = create({ scope: 'my-page' }); await render(hbs` @@ -70,11 +73,14 @@ module(`Extend | findMany`, function(hooks) { `); - assert.deepEqual(findMany(page, '.lorem', { resetScope: true }), findAll('.lorem')); + assert.deepEqual( + findMany(page, '.lorem', { resetScope: true }), + findAll('.lorem') + ); }); - test('contains param', async function(assert) { - let page = create({}); + test('contains param', async function (assert) { + const page = create({}); await render(hbs` @@ -82,11 +88,14 @@ module(`Extend | findMany`, function(hooks) { Word `); - assert.deepEqual(findMany(page, '.lorem', { contains: 'Word' }), findAll('.lorem').slice(1, 3)); + assert.deepEqual( + findMany(page, '.lorem', { contains: 'Word' }), + findAll('.lorem').slice(1, 3) + ); }); - test('scope param', async function(assert) { - let page = create({}); + test('scope param', async function (assert) { + const page = create({}); await render(hbs` @@ -96,11 +105,14 @@ module(`Extend | findMany`, function(hooks) {
`); - assert.deepEqual(findMany(page, '.lorem', { scope: '.ipsum' }), findAll('.ipsum .lorem')); + assert.deepEqual( + findMany(page, '.lorem', { scope: '.ipsum' }), + findAll('.ipsum .lorem') + ); }); - test('visible param', async function(assert) { - let page = create({}); + test('visible param', async function (assert) { + const page = create({}); await render(hbs` @@ -108,11 +120,14 @@ module(`Extend | findMany`, function(hooks) { `); - assert.deepEqual(findMany(page, '.lorem', { visible: true }), findAll('.lorem').slice(1, 3)); + assert.deepEqual( + findMany(page, '.lorem', { visible: true }), + findAll('.lorem').slice(1, 3) + ); }); - test('at param', async function(assert) { - let page = create({}); + test('at param', async function (assert) { + const page = create({}); await render(hbs` @@ -120,11 +135,13 @@ module(`Extend | findMany`, function(hooks) { `); - assert.deepEqual(findMany(page, '.lorem', { at: 1 }), [findAll('.lorem')[1]]); + assert.deepEqual(findMany(page, '.lorem', { at: 1 }), [ + findAll('.lorem')[1], + ]); }); - test('last param', async function(assert) { - let page = create({}); + test('last param', async function (assert) { + const page = create({}); await render(hbs` @@ -132,7 +149,9 @@ module(`Extend | findMany`, function(hooks) { `); - assert.deepEqual(findMany(page, '.lorem', { last: true }), [findAll('.lorem')[2]]); + assert.deepEqual(findMany(page, '.lorem', { last: true }), [ + findAll('.lorem')[2], + ]); }); module('comma separated selector', function () { @@ -143,7 +162,7 @@ module(`Extend | findMany`, function(hooks) { () => findMany(create({ scope: SELECTOR })), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); @@ -152,7 +171,7 @@ module(`Extend | findMany`, function(hooks) { () => findMany(create(), SELECTOR), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); @@ -161,8 +180,8 @@ module(`Extend | findMany`, function(hooks) { () => findMany(create(), '', { scope: SELECTOR }), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); - }) + }); }); diff --git a/test-app/tests/unit/extend/find-one-test.ts b/test-app/tests/unit/extend/find-one-test.ts index b1810688..9eefaad0 100644 --- a/test-app/tests/unit/extend/find-one-test.ts +++ b/test-app/tests/unit/extend/find-one-test.ts @@ -5,45 +5,53 @@ import { findOne } from 'ember-cli-page-object/extend'; import hbs from 'htmlbars-inline-precompile'; import { find, findAll, render } from '@ember/test-helpers'; -module(`Extend | findOne`, function(hooks) { +module(`Extend | findOne`, function (hooks) { setupRenderingTest(hooks); - test('finds by selector and returns Element', async function(assert) { - let page = create({}); + test('finds by selector and returns Element', async function (assert) { + const page = create({}); await render(hbs``); assert.equal(findOne(page, '.lorem', {}), find('.lorem')); }); - test('finds deeper in scope', async function(assert) { - let page = create({ scope: '.lorem' }); + test('finds deeper in scope', async function (assert) { + const page = create({ scope: '.lorem' }); - await render(hbs``); + await render( + hbs`` + ); assert.equal(findOne(page, '.dolor', {}), find('.lorem .dolor')); }); - test('throws error if more than 1 element found', async function(assert) { - let page = create({}); + test('throws error if more than 1 element found', async function (assert) { + const page = create({}); - await render(hbs``); + await render( + hbs`` + ); - assert.throws(() => findOne(page, '.lorem', {}), - /Error: ".lorem" matched more than one element. If you want to select many elements, use collections instead./); + assert.throws( + () => findOne(page, '.lorem', {}), + /Error: ".lorem" matched more than one element. If you want to select many elements, use collections instead./ + ); }); - test('throws error if 0 elements found', async function(assert) { - let page = create({}); + test('throws error if 0 elements found', async function (assert) { + const page = create({}); await render(hbs``); - assert.throws(() => findOne(page, '.unknown', {}), - /Error: Element not found./); + assert.throws( + () => findOne(page, '.unknown', {}), + /Error: Element not found./ + ); }); - test('testContainer param', async function(assert) { - let page = create({}); + test('testContainer param', async function (assert) { + const page = create({}); await render(hbs` @@ -52,11 +60,14 @@ module(`Extend | findOne`, function(hooks) { `); - assert.equal(findOne(page, '.ipsum', { testContainer: '.new-test-root' }), find('.new-test-root .ipsum')); + assert.equal( + findOne(page, '.ipsum', { testContainer: '.new-test-root' }), + find('.new-test-root .ipsum') + ); }); - test('resetScope param', async function(assert) { - let page = create({ scope: 'my-page' }); + test('resetScope param', async function (assert) { + const page = create({ scope: 'my-page' }); await render(hbs` @@ -68,8 +79,8 @@ module(`Extend | findOne`, function(hooks) { assert.equal(findOne(page, '.lorem', { resetScope: true }), find('.lorem')); }); - test('at param', async function(assert) { - let page = create({}); + test('at param', async function (assert) { + const page = create({}); await render(hbs` @@ -79,19 +90,22 @@ module(`Extend | findOne`, function(hooks) { assert.equal(findOne(page, '.lorem', { at: 1 }), findAll('.lorem')[1]); }); - test('contains param', async function(assert) { - let page = create({}); + test('contains param', async function (assert) { + const page = create({}); await render(hbs` Word `); - assert.equal(findOne(page, '.lorem', { contains: 'Word' }), findAll('.lorem')[1]); + assert.equal( + findOne(page, '.lorem', { contains: 'Word' }), + findAll('.lorem')[1] + ); }); - test('last param', async function(assert) { - let page = create({}); + test('last param', async function (assert) { + const page = create({}); await render(hbs` Word @@ -100,26 +114,31 @@ module(`Extend | findOne`, function(hooks) { assert.equal(findOne(page, '.lorem', { last: true }), findAll('.lorem')[1]); }); - test('pageObjectKey param', async function(assert) { - let page = create({}); + test('pageObjectKey param', async function (assert) { + const page = create({}); await render(hbs` `); - assert.throws(() => findOne(page, '.unknown', {pageObjectKey: 'CUSTOM KEY'}), - /PageObject: 'page.CUSTOM KEY'/); + assert.throws( + () => findOne(page, '.unknown', { pageObjectKey: 'CUSTOM KEY' }), + /PageObject: 'page.CUSTOM KEY'/ + ); }); - test('scope param', async function(assert) { - let page = create({}); + test('scope param', async function (assert) { + const page = create({}); await render(hbs` `); - assert.equal(findOne(page, '.lorem', { scope: '.ipsum' }), find('.ipsum .lorem')); + assert.equal( + findOne(page, '.lorem', { scope: '.ipsum' }), + find('.ipsum .lorem') + ); }); module('comma separated selector', function () { @@ -130,7 +149,7 @@ module(`Extend | findOne`, function(hooks) { () => findOne(create({ scope: SELECTOR })), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); @@ -139,7 +158,7 @@ module(`Extend | findOne`, function(hooks) { () => findOne(create(), SELECTOR), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); @@ -148,7 +167,7 @@ module(`Extend | findOne`, function(hooks) { () => findOne(create(), '', { scope: SELECTOR }), new Error( 'Usage of comma separated selectors is not supported. Please make sure your selector targets a single selector.' - ), + ) ); }); }); diff --git a/test-app/types/dummy/index.d.ts b/test-app/types/dummy/index.d.ts index 8b137891..e69de29b 100644 --- a/test-app/types/dummy/index.d.ts +++ b/test-app/types/dummy/index.d.ts @@ -1 +0,0 @@ - diff --git a/test-app/types/loader.js/require.d.ts b/test-app/types/loader.js/require.d.ts index 74f106d9..801d8a53 100644 --- a/test-app/types/loader.js/require.d.ts +++ b/test-app/types/loader.js/require.d.ts @@ -2,11 +2,10 @@ declare module 'require' { interface Require { (moduleName: string, ...args: any[]): any; - has(name: string): boolean + has(name: string): boolean; } const requirejs: Require; export default requirejs; } - From 6a4613370343184b6f159514d5e49cb08e69cb82 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:18:07 +0100 Subject: [PATCH 3/8] fix `any` usages --- test-app/tests/acceptance/rfc268-extension-helpers-test.ts | 5 +++-- test-app/tests/helpers/with-iterator-symbol-defined.ts | 5 +++-- test-app/tests/unit/-private/properties/collection-test.ts | 5 +++-- test-app/tests/unit/-private/properties/create-test.ts | 3 ++- test-app/tests/unit/-private/properties/fillable-test.ts | 2 +- test-app/tests/unit/-private/properties/getter-test.ts | 3 ++- test-app/types/loader.js/require.d.ts | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test-app/tests/acceptance/rfc268-extension-helpers-test.ts b/test-app/tests/acceptance/rfc268-extension-helpers-test.ts index 5b987395..435f880b 100644 --- a/test-app/tests/acceptance/rfc268-extension-helpers-test.ts +++ b/test-app/tests/acceptance/rfc268-extension-helpers-test.ts @@ -6,17 +6,18 @@ import { findElementWithAssert, } from 'ember-cli-page-object/extend'; +type Instance = ReturnType; module('Acceptance | extends [rfc268]', function (hooks) { setupApplicationTest(hooks); const page = create({ visit: visitable('/calculator'), - findElement(this: any, selector: string) { + findElement(this: Instance, selector: string) { return findElement(this, selector); }, - findElementWithAssert(this: any, selector: string) { + findElementWithAssert(this: Instance, selector: string) { return findElementWithAssert(this, selector); }, }); diff --git a/test-app/tests/helpers/with-iterator-symbol-defined.ts b/test-app/tests/helpers/with-iterator-symbol-defined.ts index b39ac54e..d08772bf 100644 --- a/test-app/tests/helpers/with-iterator-symbol-defined.ts +++ b/test-app/tests/helpers/with-iterator-symbol-defined.ts @@ -5,11 +5,12 @@ export default function withIteratorSymbolDefined(callback: () => unknown) { return callback(); } - // @ts-expect-error + // @ts-expect-error support old browsers window.Symbol = { iterator: '@@iterator' }; try { return callback(); } finally { - delete (window as any).Symbol; + // @ts-expect-error support old browsers + delete window.Symbol; } } diff --git a/test-app/tests/unit/-private/properties/collection-test.ts b/test-app/tests/unit/-private/properties/collection-test.ts index 1e7bcc79..4d0355e5 100644 --- a/test-app/tests/unit/-private/properties/collection-test.ts +++ b/test-app/tests/unit/-private/properties/collection-test.ts @@ -556,7 +556,7 @@ module('collection', function (hooks) { ['Lorem'] ); assert.deepEqual( - page.foo.filter((i) => i['isFoo'] as any).map((i) => i.text), + page.foo.filter((i) => Boolean(i['isFoo'])).map((i) => i.text), [] ); }); @@ -579,7 +579,8 @@ module('collection', function (hooks) { ['Lorem'] ); assert.deepEqual( - page.foo.filterBy('isFoo' as any).map((i) => i.text), + // @ts-expect-error intentionally test against a non-existing property + page.foo.filterBy('isFoo').map((i) => i.text), [] ); }); diff --git a/test-app/tests/unit/-private/properties/create-test.ts b/test-app/tests/unit/-private/properties/create-test.ts index 7c495961..bf062f1d 100644 --- a/test-app/tests/unit/-private/properties/create-test.ts +++ b/test-app/tests/unit/-private/properties/create-test.ts @@ -94,7 +94,8 @@ module('create', function () { // @ts-expect-error violate types to check if it fails in weakly-typed envs create(''); assert.true(false, 'should error'); - } catch (e: any) { + } catch (e) { + // @ts-expect-error workaround the `unknown` error type typings assert.strictEqual(e.message, 'Definition can not be a string'); } }); diff --git a/test-app/tests/unit/-private/properties/fillable-test.ts b/test-app/tests/unit/-private/properties/fillable-test.ts index 4930db0b..b3138845 100644 --- a/test-app/tests/unit/-private/properties/fillable-test.ts +++ b/test-app/tests/unit/-private/properties/fillable-test.ts @@ -54,7 +54,7 @@ module('fillable', function (hooks) { const [tagName, attrName] = name.split(' '); test(`looks for ${tagName} with ${attrName}`, async function (this: TestContext, assert) { - (this as any).template = template; + this['template'] = template; const expectedText = 'dummy text'; const clue = 'clue'; const page = create({ diff --git a/test-app/tests/unit/-private/properties/getter-test.ts b/test-app/tests/unit/-private/properties/getter-test.ts index 4f75a324..825b4678 100644 --- a/test-app/tests/unit/-private/properties/getter-test.ts +++ b/test-app/tests/unit/-private/properties/getter-test.ts @@ -68,7 +68,8 @@ module('getter', function (hooks) { assert.expect(1); try { - getter('not a function' as any); + // @ts-expect-error internally pass a wrong type to check the runtime error + getter('not a function' as () => unknown); } catch (e) { assert.strictEqual( e?.toString(), diff --git a/test-app/types/loader.js/require.d.ts b/test-app/types/loader.js/require.d.ts index 801d8a53..d0a66890 100644 --- a/test-app/types/loader.js/require.d.ts +++ b/test-app/types/loader.js/require.d.ts @@ -1,6 +1,6 @@ declare module 'require' { interface Require { - (moduleName: string, ...args: any[]): any; + (moduleName: string, ...args: unknown[]): unknown; has(name: string): boolean; } From acd27e4396749bd154bfa28cb0bffd4b654f148b Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:30:05 +0100 Subject: [PATCH 4/8] fix no-useless-escape --- test-app/tests/unit/-private/properties/fillable-test.ts | 2 +- test-app/tests/unit/-private/properties/getter-test.ts | 2 +- test-app/tests/unit/-private/properties/visitable-test.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test-app/tests/unit/-private/properties/fillable-test.ts b/test-app/tests/unit/-private/properties/fillable-test.ts index b3138845..5feb55ad 100644 --- a/test-app/tests/unit/-private/properties/fillable-test.ts +++ b/test-app/tests/unit/-private/properties/fillable-test.ts @@ -256,7 +256,7 @@ module('fillable', function (hooks) { return assert.throws(() => { return page.fillInByClue(clue, 'dummy text'); - }, /Can\ not\ find\ element\ by\ clue:\ \"clue\"\./); + }, /Can not find element by clue: "clue"\./); }); test("raises an error when the element doesn't exist", async function (assert) { diff --git a/test-app/tests/unit/-private/properties/getter-test.ts b/test-app/tests/unit/-private/properties/getter-test.ts index 825b4678..bb9ca16b 100644 --- a/test-app/tests/unit/-private/properties/getter-test.ts +++ b/test-app/tests/unit/-private/properties/getter-test.ts @@ -95,7 +95,7 @@ module('getter', function (hooks) { e?.toString(), `Error: custom error message -PageObject: \'page.foo\'` +PageObject: 'page.foo'` ); } }); diff --git a/test-app/tests/unit/-private/properties/visitable-test.ts b/test-app/tests/unit/-private/properties/visitable-test.ts index 8b2e8f85..10b858e2 100644 --- a/test-app/tests/unit/-private/properties/visitable-test.ts +++ b/test-app/tests/unit/-private/properties/visitable-test.ts @@ -36,7 +36,7 @@ module('visitable', function (hooks) { foo: visitable('/users/:user_id'), }); - assert.throws(() => page.foo(), /Missing parameter for \'user_id\'/); + assert.throws(() => page.foo(), /Missing parameter for 'user_id'/); assert.throws(() => page.foo(), /page\.foo\(\)/); }); @@ -110,7 +110,7 @@ module('visitable', function (hooks) { e?.toString(), `Error: Failed to visit URL '/non-existing-url/value' -PageObject: 'page.foo(\"[object Object]\")' +PageObject: 'page.foo("[object Object]")' Selector: '.scope'` ); } From c63dde67ebfdbb0e4cf99b6231197298db0ad91d Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:33:20 +0100 Subject: [PATCH 5/8] fix prefer-const rule --- .../-private/properties/click-on-text-test.ts | 3 +-- .../unit/-private/properties/clickable-test.ts | 15 +++++---------- .../unit/-private/properties/collection-test.ts | 3 +-- .../unit/-private/properties/fillable-test.ts | 3 +-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/test-app/tests/unit/-private/properties/click-on-text-test.ts b/test-app/tests/unit/-private/properties/click-on-text-test.ts index dc75a4ed..f5529aec 100644 --- a/test-app/tests/unit/-private/properties/click-on-text-test.ts +++ b/test-app/tests/unit/-private/properties/click-on-text-test.ts @@ -175,9 +175,8 @@ module('clickOnText', function (hooks) { assert.expect(1); const expectedContext = '#alternate-ember-testing'; - let page; - page = create({ + const page = create({ foo: clickOnText('button', { testContainer: expectedContext }), }); diff --git a/test-app/tests/unit/-private/properties/clickable-test.ts b/test-app/tests/unit/-private/properties/clickable-test.ts index 77e2099f..1f1b98d0 100644 --- a/test-app/tests/unit/-private/properties/clickable-test.ts +++ b/test-app/tests/unit/-private/properties/clickable-test.ts @@ -28,9 +28,8 @@ module('clickable', function (hooks) { assert.expect(1); const expectedSelector = '.scope span'; - let page; - page = create({ + const page = create({ foo: clickable('span', { scope: '.scope' }), }); @@ -47,9 +46,8 @@ module('clickable', function (hooks) { assert.expect(1); const expectedSelector = '.scope span'; - let page; - page = create({ + const page = create({ scope: '.scope', foo: clickable('span'), @@ -66,9 +64,8 @@ module('clickable', function (hooks) { assert.expect(1); const expectedSelector = 'span'; - let page; - page = create({ + const page = create({ scope: '.scope', foo: clickable('span', { resetScope: true }), }); @@ -114,9 +111,8 @@ module('clickable', function (hooks) { assert.expect(1); const expectedContext = '#alternate-ember-testing'; - let page; - page = create({ + const page = create({ foo: clickable('span', { testContainer: expectedContext }), }); @@ -135,9 +131,8 @@ module('clickable', function (hooks) { assert.expect(1); const expectedContext = '#alternate-ember-testing'; - let page; - page = create({ + const page = create({ testContainer: expectedContext, foo: clickable('span'), }); diff --git a/test-app/tests/unit/-private/properties/collection-test.ts b/test-app/tests/unit/-private/properties/collection-test.ts index 4d0355e5..3ecfb149 100644 --- a/test-app/tests/unit/-private/properties/collection-test.ts +++ b/test-app/tests/unit/-private/properties/collection-test.ts @@ -322,9 +322,8 @@ module('collection', function (hooks) { assert.expect(2); const expectedContext = '#alternate-ember-testing'; - let page; - page = create({ + const page = create({ foo: collection('span', { testContainer: expectedContext, }), diff --git a/test-app/tests/unit/-private/properties/fillable-test.ts b/test-app/tests/unit/-private/properties/fillable-test.ts index 5feb55ad..9f1eb95e 100644 --- a/test-app/tests/unit/-private/properties/fillable-test.ts +++ b/test-app/tests/unit/-private/properties/fillable-test.ts @@ -12,9 +12,8 @@ module('fillable', function (hooks) { const expectedSelector = 'input'; const expectedText = 'dummy text'; - let page; - page = create({ + const page = create({ foo: fillable(expectedSelector), }); From 85ea19ae2bd38e2d6477fdf5f7060b987674584a Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:40:01 +0100 Subject: [PATCH 6/8] fix @typescript-eslint/no-this-alias --- test-app/tests/helpers/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test-app/tests/helpers/index.ts b/test-app/tests/helpers/index.ts index 5ad5eeba..e3fb1ccf 100644 --- a/test-app/tests/helpers/index.ts +++ b/test-app/tests/helpers/index.ts @@ -41,20 +41,24 @@ export function setupRenderingTest(hooks: NestedHooks) { upstreamSetupRenderingTest(hooks); hooks.beforeEach(function (this: TestContext) { - const testContext = this; - - this.createTemplate = function (template, options): Promise { + this.createTemplate = function ( + this: TestContext, + template: string, + options?: { + useAlternateContainer?: boolean; + } + ): Promise { if (options && options.useAlternateContainer) { // The idea is to render the HTML outside the testing container so we // render an empty component getAlternateContainer().innerHTML = template; - testContext.set('raw', ''); + this.set('raw', ''); } else { - testContext.set('raw', template); + this.set('raw', template); } return render(hbs`{{html-render html=this.raw}}`); - }; + }.bind(this); this.findExternal = function (selector: string) { return getAlternateContainer().querySelector(selector); From ec3521f0d7b1bb5e7498d54e2b7fa277111bea1d Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 22:56:09 +0100 Subject: [PATCH 7/8] downgrade "@typescript-eslint/*" to support node@14 for now --- pnpm-lock.yaml | 154 ++++++++++++++++++++---------------------- test-app/package.json | 4 +- 2 files changed, 74 insertions(+), 84 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7c24b851..83a98914 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,8 +106,8 @@ importers: '@types/jquery': ^3.3.31 '@types/qunit': ^2.11.1 '@types/rsvp': ^4.0.3 - '@typescript-eslint/eslint-plugin': ^6.18.1 - '@typescript-eslint/parser': ^6.18.1 + '@typescript-eslint/eslint-plugin': ^5.0.0 + '@typescript-eslint/parser': ^5.0.0 broccoli-asset-rev: ^3.0.0 coveralls: ^3.0.0 ember-auto-import: ^2.4.1 @@ -178,8 +178,8 @@ importers: '@types/jquery': 3.5.16 '@types/qunit': 2.19.4 '@types/rsvp': 4.0.4 - '@typescript-eslint/eslint-plugin': 6.18.1_l5rnfrnsogonklwz3mvufhz6r4 - '@typescript-eslint/parser': 6.18.1_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/eslint-plugin': 5.62.0_3nivbvuzyn2m5ff4u7ffd7szlq + '@typescript-eslint/parser': 5.62.0_vgl77cfdswitgr47lm5swmv43m broccoli-asset-rev: 3.0.0 coveralls: 3.1.1 ember-auto-import: 2.6.1_webpack@5.76.3 @@ -1580,7 +1580,7 @@ packages: find-up: 5.0.0 lodash: 4.17.21 resolve: 1.22.1 - semver: 7.3.8 + semver: 7.5.4 transitivePeerDependencies: - supports-color dev: true @@ -1644,7 +1644,7 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.36.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.3 dev: true /@eslint-community/regexpp/4.10.0: @@ -2565,49 +2565,47 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin/6.18.1_l5rnfrnsogonklwz3mvufhz6r4: - resolution: {integrity: sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/eslint-plugin/5.62.0_3nivbvuzyn2m5ff4u7ffd7szlq: + resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha - eslint: ^7.0.0 || ^8.0.0 + '@typescript-eslint/parser': ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 6.18.1_vgl77cfdswitgr47lm5swmv43m - '@typescript-eslint/scope-manager': 6.18.1 - '@typescript-eslint/type-utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m - '@typescript-eslint/utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m - '@typescript-eslint/visitor-keys': 6.18.1 + '@typescript-eslint/parser': 5.62.0_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/scope-manager': 5.62.0 + '@typescript-eslint/type-utils': 5.62.0_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/utils': 5.62.0_vgl77cfdswitgr47lm5swmv43m debug: 4.3.4 eslint: 8.36.0 graphemer: 1.4.0 ignore: 5.2.4 - natural-compare: 1.4.0 + natural-compare-lite: 1.4.0 semver: 7.5.4 - ts-api-utils: 1.0.3_typescript@4.9.5 + tsutils: 3.21.0_typescript@4.9.5 typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser/6.18.1_vgl77cfdswitgr47lm5swmv43m: - resolution: {integrity: sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/parser/5.62.0_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 6.18.1 - '@typescript-eslint/types': 6.18.1 - '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 - '@typescript-eslint/visitor-keys': 6.18.1 + '@typescript-eslint/scope-manager': 5.62.0 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/typescript-estree': 5.62.0_typescript@4.9.5 debug: 4.3.4 eslint: 8.36.0 typescript: 4.9.5 @@ -2615,85 +2613,85 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager/6.18.1: - resolution: {integrity: sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/scope-manager/5.62.0: + resolution: {integrity: sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 6.18.1 - '@typescript-eslint/visitor-keys': 6.18.1 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/visitor-keys': 5.62.0 dev: true - /@typescript-eslint/type-utils/6.18.1_vgl77cfdswitgr47lm5swmv43m: - resolution: {integrity: sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/type-utils/5.62.0_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + eslint: '*' typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 - '@typescript-eslint/utils': 6.18.1_vgl77cfdswitgr47lm5swmv43m + '@typescript-eslint/typescript-estree': 5.62.0_typescript@4.9.5 + '@typescript-eslint/utils': 5.62.0_vgl77cfdswitgr47lm5swmv43m debug: 4.3.4 eslint: 8.36.0 - ts-api-utils: 1.0.3_typescript@4.9.5 + tsutils: 3.21.0_typescript@4.9.5 typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types/6.18.1: - resolution: {integrity: sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/types/5.62.0: + resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/6.18.1_typescript@4.9.5: - resolution: {integrity: sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/typescript-estree/5.62.0_typescript@4.9.5: + resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/types': 6.18.1 - '@typescript-eslint/visitor-keys': 6.18.1 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/visitor-keys': 5.62.0 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - minimatch: 9.0.3 semver: 7.5.4 - ts-api-utils: 1.0.3_typescript@4.9.5 + tsutils: 3.21.0_typescript@4.9.5 typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils/6.18.1_vgl77cfdswitgr47lm5swmv43m: - resolution: {integrity: sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/utils/5.62.0_vgl77cfdswitgr47lm5swmv43m: + resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@eslint-community/eslint-utils': 4.4.0_eslint@8.36.0 '@types/json-schema': 7.0.15 '@types/semver': 7.5.6 - '@typescript-eslint/scope-manager': 6.18.1 - '@typescript-eslint/types': 6.18.1 - '@typescript-eslint/typescript-estree': 6.18.1_typescript@4.9.5 + '@typescript-eslint/scope-manager': 5.62.0 + '@typescript-eslint/types': 5.62.0 + '@typescript-eslint/typescript-estree': 5.62.0_typescript@4.9.5 eslint: 8.36.0 + eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys/6.18.1: - resolution: {integrity: sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/visitor-keys/5.62.0: + resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 6.18.1 + '@typescript-eslint/types': 5.62.0 eslint-visitor-keys: 3.4.3 dev: true @@ -4617,12 +4615,6 @@ packages: balanced-match: 1.0.2 concat-map: 0.0.1 - /brace-expansion/2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - /braces/1.8.5: resolution: {integrity: sha512-xU7bpz2ytJl1bH9cgIurjpg/n8Gohy9GTw81heDYLJQ4RU60dlyJsa+atVF2pI0yMMvKxI9HkKwjePCj5XI1hw==} engines: {node: '>=0.10.0'} @@ -7258,7 +7250,7 @@ packages: engines: {node: 10.* || >= 12.*} dependencies: resolve-package-path: 3.1.0 - semver: 7.3.8 + semver: 7.5.4 silent-error: 1.1.1 transitivePeerDependencies: - supports-color @@ -11995,13 +11987,6 @@ packages: dependencies: brace-expansion: 1.1.11 - /minimatch/9.0.3: - resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} - engines: {node: '>=16 || 14 >=14.17'} - dependencies: - brace-expansion: 2.0.1 - dev: true - /minimist/0.0.8: resolution: {integrity: sha512-miQKw5Hv4NS1Psg2517mV4e4dYNaO3++hjAvLOAzKqZ61rH8NS1SK+vbfBWZ5PY/Me/bEWhUwqMghEW5Fb9T7Q==} dev: true @@ -12187,6 +12172,10 @@ packages: - supports-color dev: true + /natural-compare-lite/1.4.0: + resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} + dev: true + /natural-compare/1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true @@ -15602,15 +15591,6 @@ packages: resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} dev: true - /ts-api-utils/1.0.3_typescript@4.9.5: - resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} - engines: {node: '>=16.13.0'} - peerDependencies: - typescript: '>=4.2.0' - dependencies: - typescript: 4.9.5 - dev: true - /tslib/1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true @@ -15619,6 +15599,16 @@ packages: resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} dev: true + /tsutils/3.21.0_typescript@4.9.5: + resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} + engines: {node: '>= 6'} + peerDependencies: + typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + dependencies: + tslib: 1.14.1 + typescript: 4.9.5 + dev: true + /tty-browserify/0.0.0: resolution: {integrity: sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw==} dev: true diff --git a/test-app/package.json b/test-app/package.json index f62f52b5..3ef98058 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -61,8 +61,8 @@ "@types/jquery": "^3.3.31", "@types/qunit": "^2.11.1", "@types/rsvp": "^4.0.3", - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0", "broccoli-asset-rev": "^3.0.0", "coveralls": "^3.0.0", "ember-auto-import": "^2.4.1", From 79841f2109b30fb276c675aaece56694b6b92735 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Sun, 14 Jan 2024 23:11:37 +0100 Subject: [PATCH 8/8] make `createClickTrackerComponent` pass eslint --- test-app/tests/unit/adapters/helpers.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test-app/tests/unit/adapters/helpers.ts b/test-app/tests/unit/adapters/helpers.ts index a58de036..657a7045 100644 --- a/test-app/tests/unit/adapters/helpers.ts +++ b/test-app/tests/unit/adapters/helpers.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line ember/no-classic-components import Component from '@ember/component'; import { later } from '@ember/runloop'; import hbs from 'htmlbars-inline-precompile'; @@ -19,17 +20,15 @@ function spyAction(assert: Assert) { export function createClickTrackerComponent(assert: Assert) { const trackAction = spyAction(assert); - const layout = hbs``; + const layout = hbs``; - return Component.extend({ - layout, + return class TestComponent extends Component { + layout = layout; - actions: { - trackAction() { - return trackAction(); - }, - }, - }); + trackAction = () => { + return trackAction(); + }; + }; } export const ClickTrackerDef = {