From 2d5cae2b703b3289036d9308a761d4b6b44d375b Mon Sep 17 00:00:00 2001 From: "miherlosev@mail.ru" Date: Tue, 18 Apr 2017 15:39:38 +0300 Subject: [PATCH 1/9] Angular1Selector implemented --- .babelrc | 3 + .editoreconfig | 15 +++++ .eslintrc | 87 ++++++++++++++++++++++++++++ .gitattributes | 17 ++++++ .gitignore | 52 +++++++++++++++++ .publishrc | 13 +++++ README.md | 77 +++++++++++++++++++++++++ appveyor.yml | 19 +++++++ package.json | 26 +++++++++ src/angular1-selector.js | 119 +++++++++++++++++++++++++++++++++++++++ src/index.js | 3 + test/.eslintrc | 6 ++ test/angular1-test.js | 69 +++++++++++++++++++++++ test/data/ng1/app.js | 22 ++++++++ test/data/ng1/index.html | 34 +++++++++++ 15 files changed, 562 insertions(+) create mode 100644 .babelrc create mode 100644 .editoreconfig create mode 100644 .eslintrc create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .publishrc create mode 100644 appveyor.yml create mode 100644 package.json create mode 100644 src/angular1-selector.js create mode 100644 src/index.js create mode 100644 test/.eslintrc create mode 100644 test/angular1-test.js create mode 100644 test/data/ng1/app.js create mode 100644 test/data/ng1/index.html diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..af0f0c3 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} \ No newline at end of file diff --git a/.editoreconfig b/.editoreconfig new file mode 100644 index 0000000..956a53a --- /dev/null +++ b/.editoreconfig @@ -0,0 +1,15 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[{.eslintrc,package.json,.travis.yml}] +indent_size = 2 \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..08d990a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,87 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + "rules": { + "no-alert": 2, + "no-array-constructor": 2, + "no-caller": 2, + "no-catch-shadow": 2, + "no-console": 0, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-implied-eval": 2, + "no-iterator": 2, + "no-label-var": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-new": 2, + "no-new-func": 0, + "no-new-object": 2, + "no-new-wrappers": 2, + "no-octal-escape": 2, + "no-proto": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-sequences": 2, + "no-shadow": 2, + "no-shadow-restricted-names": 2, + "no-spaced-func": 2, + "no-undef-init": 2, + "no-unused-expressions": 2, + "no-with": 2, + "camelcase": 2, + "comma-spacing": 2, + "consistent-return": 2, + "eqeqeq": 2, + "semi": 2, + "semi-spacing": [2, {"before": false, "after": true}], + "space-infix-ops": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "yoda": [2, "never"], + "brace-style": [2, "stroustrup", { "allowSingleLine": false }], + "eol-last": 2, + "indent": 2, + "key-spacing": [2, { "align": "value" }], + "max-nested-callbacks": [2, 3], + "new-parens": 2, + "newline-after-var": [2, "always"], + "no-lonely-if": 2, + "no-multiple-empty-lines": [2, { "max": 2 }], + "no-nested-ternary": 2, + "no-underscore-dangle": 0, + "no-unneeded-ternary": 2, + "object-curly-spacing": [2, "always"], + "operator-assignment": [2, "always"], + "quotes": [2, "single", "avoid-escape"], + "space-before-blocks": [2, "always"], + "prefer-const": 2, + "no-path-concat": 2, + "no-undefined": 2, + "keyword-spacing": 2, + "strict": 0, + "curly": [2, "multi-or-nest"], + "dot-notation": 0, + "no-else-return": 2, + "one-var": [2, "never"], + "no-multi-spaces": [2, { + "exceptions": { + "VariableDeclarator": true, + "AssignmentExpression": true + } + }], + "radix": 2, + "no-extra-parens": 2, + "new-cap": [2, { "capIsNew": false }], + "space-before-function-paren": [2, "always"], + "no-use-before-define" : [2, "nofunc"], + "handle-callback-err": 0 + }, + "env": { + "node": true, + "browser": true + } +} \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6ad4083 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2bc8632 --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +node_modules/* +.idea/* +lib/* +test/data/lib/* diff --git a/.publishrc b/.publishrc new file mode 100644 index 0000000..ab8381a --- /dev/null +++ b/.publishrc @@ -0,0 +1,13 @@ +{ + "validations": { + "vulnerableDependencies": false, + "uncommittedChanges": true, + "untrackedFiles": true, + "sensitiveData": true, + "branch": "master", + "gitTag": true + }, + "confirm": true, + "publishTag": "latest", + "prePublishScript": "npm test" +} \ No newline at end of file diff --git a/README.md b/README.md index 6f076e3..12e156b 100644 --- a/README.md +++ b/README.md @@ -1 +1,78 @@ # testcafe-angular-selectors + +This plugin provides selector extensions that make it easier to test Angular applications with [TestCafe](https://github.com/DevExpress/testcafe/). + +## Install + +``` +npm install testcafe-angular-selectors +``` + +## Angular1 Selector extensions + +### byBinding +Find elements by text binding. Does a partial match, so any elements can be returned. +```js +Angular1Selector.byBinding(expression, parentSelector) +``` +Parameter | Description +--------------------------- | ----------- +expression | The JavaScript expression to which the element's `textContent` is bound. +parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector. + +NOTE: we don't support a deprecated syntax `Angular1Selector.byBinding('{{person.name}}')` + +### byExactBinding +Find elements by exact binding. +```js +Angular1Selector.byExactBinding(expression, parentSelector) +``` +Parameter | Description +--------------------------- | ----------- +expression | The JavaScript expression to which the element's `textContent` is bound. +parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector. + +### byModel +Find elements by 'ng-model' expression +```js +Angular1Selector.byModel(expression, parentSelector) +``` +Parameter | Description +--------------------------- | ----------- +expression | The JavaScript expression to data-bind property of the scope to input,select, textarea (or custom form control). +parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector. + +### byOptions + +Find elements by 'ng-options' expression. +```js +Angular1Selector.byOptions(expression, parentSelector) +``` +Parameter | Description +--------------------------- | ----------- +expression | The JavaScript expression to dynamically generate a list of