From d47bba191bb228ee77dd7117c4fd282cae12aaa7 Mon Sep 17 00:00:00 2001 From: Matheus Bernardo Date: Fri, 8 Dec 2017 01:22:00 -0200 Subject: [PATCH 1/3] Adding unit tests --- package-lock.json | 139 ++++++++++-------- package.json | 2 + src/components/Authentication/Login.vue | 37 +---- src/components/GitHub/GitHubCallBack.vue | 10 +- src/components/Projects/DeleteProject.vue | 1 - src/components/Projects/Projects.vue | 1 - src/components/Releases/AddRelease.vue | 2 +- src/components/Releases/Release.vue | 4 - src/components/Releases/Releases.vue | 12 +- .../Retrospective/DeleteRetrospective.vue | 2 +- src/services/auth/index.js | 22 ++- test/unit/karma.conf.js | 4 +- test/unit/specs/Authentication/Login.spec.js | 70 +++++++++ .../specs/Authentication/Register.spec.js | 77 ++++++++++ test/unit/specs/GitHub/GitHubCallBack.spec.js | 52 +++++++ .../specs/{ => GitHub}/GitHubProjects.spec.js | 11 +- test/unit/specs/GitHubCallBack.spec.js | 48 ------ test/unit/specs/Hello.spec.js | 0 test/unit/specs/Projects/AddProject.spec.js | 45 ++++++ .../unit/specs/Projects/DeleteProject.spec.js | 49 ++++++ test/unit/specs/Projects/EditProject.spec.js | 68 +++++++++ test/unit/specs/Projects/Project.spec.js | 53 +++++++ test/unit/specs/Projects/Projects.spec.js | 72 +++++++++ test/unit/specs/Releases/AddRelease.spec.js | 50 +++++++ .../unit/specs/Releases/DeleteRelease.spec.js | 49 ++++++ test/unit/specs/Releases/EditRelease.spec.js | 68 +++++++++ test/unit/specs/Releases/Release.spec.js | 68 +++++++++ test/unit/specs/Releases/Releases.spec.js | 85 +++++++++++ .../Retrospective/AddRetrospective.spec.js | 93 ++++++++++++ .../Retrospective/DeleteRetrospective.spec.js | 52 +++++++ .../Retrospective/EditRetrospective.spec.js | 91 ++++++++++++ test/unit/specs/Retrospective/List.spec.js | 35 +++++ .../specs/Retrospective/Retrospective.spec.js | 69 +++++++++ 33 files changed, 1270 insertions(+), 171 deletions(-) create mode 100644 test/unit/specs/Authentication/Login.spec.js create mode 100644 test/unit/specs/Authentication/Register.spec.js create mode 100644 test/unit/specs/GitHub/GitHubCallBack.spec.js rename test/unit/specs/{ => GitHub}/GitHubProjects.spec.js (93%) delete mode 100644 test/unit/specs/GitHubCallBack.spec.js delete mode 100644 test/unit/specs/Hello.spec.js create mode 100644 test/unit/specs/Projects/AddProject.spec.js create mode 100644 test/unit/specs/Projects/DeleteProject.spec.js create mode 100644 test/unit/specs/Projects/EditProject.spec.js create mode 100644 test/unit/specs/Projects/Project.spec.js create mode 100644 test/unit/specs/Projects/Projects.spec.js create mode 100644 test/unit/specs/Releases/AddRelease.spec.js create mode 100644 test/unit/specs/Releases/DeleteRelease.spec.js create mode 100644 test/unit/specs/Releases/EditRelease.spec.js create mode 100644 test/unit/specs/Releases/Release.spec.js create mode 100644 test/unit/specs/Releases/Releases.spec.js create mode 100644 test/unit/specs/Retrospective/AddRetrospective.spec.js create mode 100644 test/unit/specs/Retrospective/DeleteRetrospective.spec.js create mode 100644 test/unit/specs/Retrospective/EditRetrospective.spec.js create mode 100644 test/unit/specs/Retrospective/List.spec.js create mode 100644 test/unit/specs/Retrospective/Retrospective.spec.js diff --git a/package-lock.json b/package-lock.json index aa930cf8..7fd20661 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,7 +103,7 @@ "acorn": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", - "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "integrity": "sha1-kRy1PgNoB88Pp3jcXTcPvYZCRtc=", "dev": true }, "acorn-dynamic-import": { @@ -225,7 +225,7 @@ "ansi-styles": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "integrity": "sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g=", "dev": true, "requires": { "color-convert": "1.9.0" @@ -234,7 +234,7 @@ "anymatch": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "integrity": "sha1-VT3Lj5HjyImEXf26NMd3IbkLnXo=", "dev": true, "requires": { "micromatch": "2.3.11", @@ -262,7 +262,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", "dev": true }, "array-find-index": { @@ -363,7 +363,7 @@ "async": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "integrity": "sha1-hDGQ/WtzV6C54clW7d3V7IRitU0=", "dev": true, "requires": { "lodash": "4.17.4" @@ -648,7 +648,7 @@ "babel-loader": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.2.tgz", - "integrity": "sha512-jRwlFbINAeyDStqK6Dd5YuY0k5YuzQUvlz2ZamuXrXmxav3pNqe9vfJ402+2G+OmlJSXxCOpB6Uz0INM7RQe2A==", + "integrity": "sha1-9svhInEPGqKvTYgcbVtUNYyiQSY=", "dev": true, "requires": { "find-cache-dir": "1.0.0", @@ -1040,7 +1040,7 @@ "babel-preset-env": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "integrity": "sha1-LeHHgqeAoKXWBdGZyVdZbaQ8ROQ=", "dev": true, "requires": { "babel-plugin-check-es2015-constants": "6.22.0", @@ -1197,7 +1197,7 @@ "babylon": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" + "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=" }, "backo2": { "version": "1.0.2", @@ -1220,7 +1220,7 @@ "base64-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", + "integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY=", "dev": true }, "base64id": { @@ -1275,7 +1275,7 @@ "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", + "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=", "dev": true }, "body-parser": { @@ -1347,7 +1347,7 @@ "browserify-aes": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.8.tgz", - "integrity": "sha512-WYCMOT/PtGTlpOKFht0YJFYcPy6pLCR98CtWfzK13zoynLlBMvAdEMSRGmgnJCw2M2j/5qxBkinZQFobieM8dQ==", + "integrity": "sha1-yPo7G3WFu3unfFVgtgmW3extUwk=", "dev": true, "requires": { "buffer-xor": "1.0.3", @@ -1417,7 +1417,7 @@ "browserslist": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.4.0.tgz", - "integrity": "sha512-aM2Gt4x9bVlCUteADBS6JP0F+2tMWKM1jQzUulVROtdFWFIcIVvY76AJbr7GDqy0eDhn+PcnpzzivGxY4qiaKQ==", + "integrity": "sha1-aT7pPQHmZGimNI2lSY4BH1ePh/g=", "dev": true, "requires": { "caniuse-lite": "1.0.30000738", @@ -1610,7 +1610,7 @@ "chalk": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "integrity": "sha1-rFvs8U+iG5nGySynp9fP1bF+dD4=", "dev": true, "requires": { "ansi-styles": "3.2.0", @@ -1668,7 +1668,7 @@ "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", "dev": true, "requires": { "inherits": "2.0.3", @@ -1884,7 +1884,7 @@ "commander": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + "integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM=" }, "common-tags": { "version": "1.4.0", @@ -2102,7 +2102,7 @@ "cosmiconfig": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-2.2.2.tgz", - "integrity": "sha512-GiNXLwAFPYHy25XmTPpafYvn3CLAkJ8FLsscq78MQd1Kh0OU6Yzhn4eV2MVF4G9WEQZoWEGltatdR+ntGPMl5A==", + "integrity": "sha1-YXPOvVb6wELB9DkO33r2wHx8uJI=", "dev": true, "requires": { "is-directory": "0.3.1", @@ -2202,7 +2202,7 @@ "crypto-browserify": { "version": "3.11.1", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "integrity": "sha1-lIlF78Z1ekANbl5a9HGU0QBkJ58=", "dev": true, "requires": { "browserify-cipher": "1.0.0", @@ -2226,7 +2226,7 @@ "css-loader": { "version": "0.28.7", "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.28.7.tgz", - "integrity": "sha512-GxMpax8a/VgcfRrVy0gXD6yLd5ePYbXX/5zGgTVYp4wXtJklS8Z2VaUArJgc//f6/Dzil7BaJObdSv8eKKCPgg==", + "integrity": "sha1-Xy7pid0y7dkHcX+VMxdlYWCZnBs=", "dev": true, "requires": { "babel-code-frame": "6.26.0", @@ -3010,7 +3010,7 @@ "data-uri-to-buffer": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz", - "integrity": "sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ==", + "integrity": "sha1-dxY+qcINhkG0cH6PGKvfmnjzSDU=", "dev": true }, "date-fns": { @@ -3923,7 +3923,7 @@ "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "integrity": "sha1-f8vbGY3HGVlDLv4ThCaE4FJaywI=", "dev": true, "requires": { "md5.js": "1.3.4", @@ -4184,7 +4184,7 @@ "file-loader": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-0.11.2.tgz", - "integrity": "sha512-N+uhF3mswIFeziHQjGScJ/yHXYt3DiLBeC+9vWW+WjUBiClMSOlV1YrXQi+7KM2aA3Rn4Bybgv+uXFQbfkzpvg==", + "integrity": "sha1-T/HfKK84cZpgmAk7iMgscdF5SjQ=", "dev": true, "requires": { "loader-utils": "1.1.0" @@ -4193,7 +4193,7 @@ "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "integrity": "sha1-VTp7hEb/b2hDWcRF8eN6BdrMM90=", "dev": true }, "filename-regex": { @@ -4431,7 +4431,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", "dev": true }, "functional-red-black-tree": { @@ -4461,7 +4461,7 @@ "get-uri": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-2.0.1.tgz", - "integrity": "sha512-7aelVrYqCLuVjq2kEKRTH8fXPTC0xKTkM+G7UlFkEwCXY3sFbSxvY375JoFowOAYbkaU47SrBvOefUlLZZ+6QA==", + "integrity": "sha1-29ysrNjGCKODFoaTaBF2l6FjHFk=", "dev": true, "requires": { "data-uri-to-buffer": "1.2.0", @@ -4533,7 +4533,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -4575,7 +4575,7 @@ "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==" + "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=" }, "globby": { "version": "5.0.0", @@ -4748,7 +4748,7 @@ "hash.js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", "dev": true, "requires": { "inherits": "2.0.3", @@ -4818,7 +4818,7 @@ "hosted-git-info": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "integrity": "sha1-bWDjSzq7yDEwYsO3mO+NkBoHrzw=", "dev": true }, "html-comment-regex": { @@ -5104,7 +5104,7 @@ "inject-loader": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/inject-loader/-/inject-loader-3.0.1.tgz", - "integrity": "sha512-0Kd4NqMJUhknG4ECiJ/mgyHJBpfBBWZ3IKHl2BLNQiFtMO7/xiv9mmHl7mGvE0iKrBeQAZdMcQP3sMXZN0cqeg==", + "integrity": "sha1-hEpFlhUM9rhkwveYBtQKLK7kwsc=", "dev": true, "requires": { "babel-core": "6.26.0" @@ -5516,7 +5516,7 @@ "istanbul-lib-coverage": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz", - "integrity": "sha512-0+1vDkmzxqJIn5rcoEqapSB4DmPxE31EtI2dF2aCkV5esN9EWHxZ0dwgDClivMXJqE7zaYQxq30hj5L0nlTN5Q==", + "integrity": "sha1-c7+5mIhSmUFck9OKPprfeEp3qdo=", "dev": true }, "istanbul-lib-instrument": { @@ -5582,7 +5582,7 @@ "json-loader": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", - "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==", + "integrity": "sha1-3KFKcCNf+C8KyaOr62DTN6NlGF0=", "dev": true }, "json-schema": { @@ -5660,7 +5660,7 @@ "karma": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz", - "integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==", + "integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=", "dev": true, "requires": { "bluebird": "3.5.0", @@ -6548,7 +6548,7 @@ "lru-cache": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "integrity": "sha1-Yi4y6CSItJJ5EUpPns9F581rulU=", "dev": true, "requires": { "pseudomap": "1.0.2", @@ -6731,7 +6731,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "dev": true, "requires": { "brace-expansion": "1.1.8" @@ -7057,7 +7057,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -7178,7 +7178,7 @@ "opn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/opn/-/opn-5.1.0.tgz", - "integrity": "sha512-iPNl7SyM8L30Rm1sjGdLLheyHVw5YXVfi3SKWJzBI7efxRwHojfRFjwE/OLM6qp9xJYMgab8WicTU1cPoY+Hpg==", + "integrity": "sha1-cs4jBqF9vqWP8QQYUzUrSo/HdRk=", "dev": true, "requires": { "is-wsl": "1.1.0" @@ -7340,7 +7340,7 @@ "pac-proxy-agent": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-1.1.0.tgz", - "integrity": "sha512-QBELCWyLYPgE2Gj+4wUEiMscHrQ8nRPBzYItQNOHWavwBt25ohZHQC4qnd5IszdVVrFbLsQ+dPkm6eqdjJAmwQ==", + "integrity": "sha1-NKOF399h0vDsrOCIWMdF0+eR/U0=", "dev": true, "requires": { "agent-base": "2.1.1", @@ -7535,6 +7535,12 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "phantomjs-polyfill-object-assign": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/phantomjs-polyfill-object-assign/-/phantomjs-polyfill-object-assign-0.0.2.tgz", + "integrity": "sha1-gymlx/eeAiUvp+/Da27QVdaC7ZE=", + "dev": true + }, "phantomjs-prebuilt": { "version": "2.1.15", "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.15.tgz", @@ -9710,7 +9716,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", "dev": true, "requires": { "is-number": "3.0.0", @@ -9751,7 +9757,7 @@ "randombytes": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "integrity": "sha1-3ACaJGuNCaF3tLegrne8Vw9LG3k=", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -9820,7 +9826,7 @@ "readable-stream": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", "dev": true, "requires": { "core-util-is": "1.0.2", @@ -9907,12 +9913,12 @@ "regenerator-runtime": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz", - "integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A==" + "integrity": "sha1-flT+W1zNXWYk6mJVw0c74JC4AuE=" }, "regenerator-transform": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", - "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "integrity": "sha1-HkmWg3Ix2ot/PPQRTXG1aRoGgN0=", "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", @@ -9922,7 +9928,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", + "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -10176,7 +10182,7 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", "dev": true }, "samsam": { @@ -10188,7 +10194,7 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=", "dev": true }, "schema-utils": { @@ -10203,13 +10209,13 @@ "selenium-server": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/selenium-server/-/selenium-server-3.5.3.tgz", - "integrity": "sha512-apELZb+nk5SdwGL84Aw9OmUBN/l4JeXgWd3oxc0Lg2r9yCMX5b9dJzIfdj5Tp3GytY2hz7lXuH7DrKZYObxktA==", + "integrity": "sha1-J4wK9hrClhR2pZxv+VEhbWfyCVw=", "dev": true }, "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "integrity": "sha1-4FnAnYVx8FQII3M0M1BdOi8AsY4=", "dev": true }, "send": { @@ -10559,7 +10565,7 @@ "socks-proxy-agent": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-2.1.1.tgz", - "integrity": "sha512-sFtmYqdUK5dAMh85H0LEVFUCO7OhJJe1/z2x/Z6mxp3s7/QPf1RkZmpZy+BpuU0bEjcV9npqKjq9Y3kwFUjnxw==", + "integrity": "sha1-huuwcZMlhjeHDhO3vZnybGY989M=", "dev": true, "requires": { "agent-base": "2.1.1", @@ -10579,7 +10585,7 @@ "source-list-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==", + "integrity": "sha1-qqR0A/eyRakvvJfqCPJQ1gh+0IU=", "dev": true }, "source-map": { @@ -10643,7 +10649,7 @@ "stackframe": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.0.4.tgz", - "integrity": "sha512-to7oADIniaYwS3MhtCa/sQhrxidCCQiF/qp4/m5iN3ipf0Y7Xlri0f6eG29r08aL7JYl8n32AF3Q5GYBZ7K8vw==", + "integrity": "sha1-NXskqZL5Qny6a1RdlqFO0svKGHs=", "dev": true }, "statuses": { @@ -10665,7 +10671,7 @@ "stream-http": { "version": "2.7.2", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "integrity": "sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=", "dev": true, "requires": { "builtin-status-codes": "3.0.0", @@ -10710,7 +10716,7 @@ "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -10757,7 +10763,7 @@ "supports-color": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "integrity": "sha1-iD992rwWUUKyphQn8zUt7RldGj4=", "dev": true, "requires": { "has-flag": "2.0.0" @@ -10846,7 +10852,7 @@ "test-exclude": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-4.1.1.tgz", - "integrity": "sha512-35+Asrsk3XHJDBgf/VRFexPgh3UyETv8IAn/LRTiZjVy6rjPVqdEk8dJcJYBzl1w0XCJM48lvTy8SfEsCWS4nA==", + "integrity": "sha1-TYSWSwlmsAh+zDNKLOAC09k0HiY=", "dev": true, "requires": { "arrify": "1.0.1", @@ -10895,7 +10901,7 @@ "timers-browserify": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz", - "integrity": "sha512-uZYhyU3EX8O7HQP+J9fTVYwsq90Vr68xPEFo7yrVImIxYvHgukBEgOB/SgGoorWVTzGM/3Z+wUNnboA4M8jWrg==", + "integrity": "sha1-lspT9LeUpefA4b18yIo3Ipj6AeY=", "dev": true, "requires": { "setimmediate": "1.0.5" @@ -11102,7 +11108,7 @@ "url-loader": { "version": "0.5.9", "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-0.5.9.tgz", - "integrity": "sha512-B7QYFyvv+fOBqBVeefsxv6koWWtjmHaMFT6KZWti4KRw8YUD/hOU+3AECvXuzyVawIBx3z7zQRejXCDSO5kk1Q==", + "integrity": "sha1-zI/qgse5Bud3cBklCGnlaemVwpU=", "dev": true, "requires": { "loader-utils": "1.1.0", @@ -11170,7 +11176,7 @@ "uuid": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=", "dev": true }, "validate-npm-package-license": { @@ -11277,7 +11283,7 @@ "vue-router": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-2.7.0.tgz", - "integrity": "sha512-kxgsT50dDExua3i103nxNBjlfk8LeUmO9iujVxXV42MnISINHUjqMrknpOOJEg+i9nEkoVgG8N86Pklze35c/A==" + "integrity": "sha1-FtQkSTqlHDyMzot8chDqTDqJr/E=" }, "vue-style-loader": { "version": "3.0.3", @@ -11302,9 +11308,18 @@ "vue-template-es2015-compiler": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.5.3.tgz", - "integrity": "sha512-j3TBDtjqz7pC9XUzeSeqF5oekqPahxyUHsdG+kZKDH/V/DTexq5inYdLGstnqCUljoLC9LTj3H/5hmyToeSd1A==", + "integrity": "sha1-Inh95ON+vZM5t0IjvEZ9Gt7jBUU=", "dev": true }, + "vue-test-utils": { + "version": "1.0.0-beta.6", + "resolved": "https://registry.npmjs.org/vue-test-utils/-/vue-test-utils-1.0.0-beta.6.tgz", + "integrity": "sha512-mma+nVIK4znVcboIWHdYiPO4AmHM5k6vWD0QWO6sffFnqS/ABTJ37sXEl0Z9f35MdUijPFSp9iBdmeF4rwy/Lw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + }, "vue-windows": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/vue-windows/-/vue-windows-0.1.3.tgz", @@ -11348,7 +11363,7 @@ "webpack": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-2.7.0.tgz", - "integrity": "sha512-MjAA0ZqO1ba7ZQJRnoCdbM56mmFpipOPUv/vQpwwfSI42p5PVDdoiuK2AL2FwFUVgT859Jr43bFZXRg/LNsqvg==", + "integrity": "sha1-sqEiaAQ3P/09A+qca9UlBnA09rE=", "dev": true, "requires": { "acorn": "5.1.2", @@ -11595,7 +11610,7 @@ "webpack-sources": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", - "integrity": "sha512-05tMxipUCwHqYaVS8xc7sYPTly8PzXayRCB4dTxLhWTqlKUiwH6ezmEe0OSreL1c30LAuA3Zqmc+uEBUGFJDjw==", + "integrity": "sha1-xzVkNqTRMSO+LiQmoF0drZy+Zc8=", "dev": true, "requires": { "source-list-map": "2.0.0", @@ -11611,7 +11626,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/package.json b/package.json index da86b0fd..66324013 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "opn": "^5.1.0", "optimize-css-assets-webpack-plugin": "^2.0.0", "ora": "^1.2.0", + "phantomjs-polyfill-object-assign": "0.0.2", "phantomjs-prebuilt": "^2.1.15", "rimraf": "^2.6.0", "selenium-server": "^3.0.1", @@ -86,6 +87,7 @@ "vue-loader": "^13.0.4", "vue-style-loader": "^3.0.1", "vue-template-compiler": "^2.4.2", + "vue-test-utils": "^1.0.0-beta.6", "webpack": "^2.6.1", "webpack-bundle-analyzer": "^2.2.1", "webpack-dev-middleware": "^1.10.0", diff --git a/src/components/Authentication/Login.vue b/src/components/Authentication/Login.vue index d50aca79..949c5c98 100644 --- a/src/components/Authentication/Login.vue +++ b/src/components/Authentication/Login.vue @@ -45,40 +45,17 @@ export default { }; }, - computed: { - ...mapState({ - token: state => state.auth.token, - userId: state => state.auth.userId, - }), - }, - methods: { login() { const thisOne = this; - this.$store.dispatch('login', { email: this.email, password: this.password }) - .then(() => { - this.$router.push({ name: 'Projects' }); - }) - .catch((err) => { - thisOne.errors.add('wrong-credentials', 'Wrong Credentials'); - console.log(err); // It goes here! - }); - }, - - isGitHubAuthenticated() { - const headers = { Authorization: this.token }; - HTTP.get(`users/${this.userId}`, { headers }) - .then((response) => { - if (response.data.access_token != null) { - localStorage.setItem('is_github_authenticated', 'true'); - } else { - localStorage.setItem('is_github_authenticated', 'false'); - } - }) - .catch((err) => { - console.log(err); // It goes here! - }); + this.$store.dispatch('login', { email: this.email, password: this.password }) + .then((res) => { + this.$router.push({ name: 'Projects' }); + }) + .catch((err) => { + thisOne.errors.add('wrong-credentials', 'Wrong Credentials'); + }); }, }, }; diff --git a/src/components/GitHub/GitHubCallBack.vue b/src/components/GitHub/GitHubCallBack.vue index bdc03bda..fb6078e3 100644 --- a/src/components/GitHub/GitHubCallBack.vue +++ b/src/components/GitHub/GitHubCallBack.vue @@ -20,14 +20,10 @@ export default { mounted() { const code = window.location.search.split('=')[1]; const headers = { Authorization: this.token }; - HTTP.post('request_github_token', { - code, - id: this.userId, - }, { headers }) - .then((response) => { - this.github_token = response.data.access_token; + this.$store.dispatch('linkGithub', { code, headers, userId: this.userId }) + .then(() => { this.$router.push({ name: 'UserProfile' }); - }) + }) .catch((e) => { this.errors.push(e); }); diff --git a/src/components/Projects/DeleteProject.vue b/src/components/Projects/DeleteProject.vue index 759c6300..5a1ff832 100644 --- a/src/components/Projects/DeleteProject.vue +++ b/src/components/Projects/DeleteProject.vue @@ -36,7 +36,6 @@ export default { computed: { ...mapState({ token: state => state.auth.token, - userId: state => state.auth.userId, }), }, methods: { diff --git a/src/components/Projects/Projects.vue b/src/components/Projects/Projects.vue index b16b86d7..cc4c141f 100644 --- a/src/components/Projects/Projects.vue +++ b/src/components/Projects/Projects.vue @@ -93,7 +93,6 @@ export default { refreshProjects() { this.getProjects(); - this.gitHubAuthenticated(); }, isProjectsEmpty() { diff --git a/src/components/Releases/AddRelease.vue b/src/components/Releases/AddRelease.vue index e1b159d4..3b2f9666 100644 --- a/src/components/Releases/AddRelease.vue +++ b/src/components/Releases/AddRelease.vue @@ -77,7 +77,7 @@ export default { this.description = ''; this.initialDate = ''; this.finalDate = ''; - EventBus.$emit('added-release', 1); + this.$emit('added'); }) .catch((e) => { this.errors.push(e); diff --git a/src/components/Releases/Release.vue b/src/components/Releases/Release.vue index 6b9088f3..93b5a6fc 100644 --- a/src/components/Releases/Release.vue +++ b/src/components/Releases/Release.vue @@ -85,10 +85,6 @@ export default { }, }, - ready() { - this.dateConvert(); - }, - mounted() { this.getRelease(); }, diff --git a/src/components/Releases/Releases.vue b/src/components/Releases/Releases.vue index 7d231b92..a3b1a9f3 100644 --- a/src/components/Releases/Releases.vue +++ b/src/components/Releases/Releases.vue @@ -5,7 +5,7 @@
- +
@@ -87,7 +87,7 @@ export default { methods: { getReleases() { const headers = { Authorization: this.token }; - console.log(headers); + HTTP.get(`projects/${this.$route.params.id}/releases`, { headers }) .then((response) => { this.releases = response.data; @@ -102,17 +102,9 @@ export default { }, - ready() { - this.dateConvert(); - }, - mounted() { this.getReleases(); }, - - updated() { - this.getReleases(); - }, }; diff --git a/src/components/Retrospective/DeleteRetrospective.vue b/src/components/Retrospective/DeleteRetrospective.vue index a1c112bb..928a085b 100644 --- a/src/components/Retrospective/DeleteRetrospective.vue +++ b/src/components/Retrospective/DeleteRetrospective.vue @@ -49,12 +49,12 @@ export default { methods: { async deleteRetrospective() { const headers = { Authorization: this.token }; - try { const response = await HTTP.get(`/retrospectives/${this.$route.params.id}`, { headers }); const id = response.data.sprint_id; await HTTP.delete(`/retrospectives/${this.$route.params.id}`, { headers }); + this.$router.push({ path: `/Sprints/${id}` }); } catch (err) { console.log(err); diff --git a/src/services/auth/index.js b/src/services/auth/index.js index 1285a143..5952244d 100644 --- a/src/services/auth/index.js +++ b/src/services/auth/index.js @@ -2,13 +2,15 @@ import { HTTP } from '../../http-common'; const LOGIN = 'LOGIN'; const LOGOUT = 'LOGOUT'; - +const LINK_GITHUB = 'LINK_GITHUB'; +const UNLINK_GITHUB = 'UNLINK_GITHUB'; const auth = { state() { return { authenticated: false, token: null, userId: null, + githubAuthenticated: false, }; }, mutations: { @@ -24,6 +26,14 @@ const auth = { localState.userId = null; localState.authenticated = false; }, + [LINK_GITHUB](state) { + const localState = state; + localState.githubAuthenticated = true; + }, + [UNLINK_GITHUB](state) { + const localState = state; + localState.githubAuthenticated = false; + } }, actions: { login({ commit }, credentials) { @@ -40,6 +50,16 @@ const auth = { logout({ commit }) { commit(LOGOUT); }, + + linkGithub({ commit }, credentials) { + return HTTP.post('request_github_token', { + code: credentials.code, + id: credentials.userId, + }, { headers: credentials.headers }) + .then((response) => { + commit(LINK_GITHUB); + }) + } }, }; diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js index 9a4bb17c..937a85b8 100644 --- a/test/unit/karma.conf.js +++ b/test/unit/karma.conf.js @@ -10,7 +10,9 @@ module.exports = function (config) { // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'sinon-chai'], reporters: ['spec', 'coverage'], - files: ['../../node_modules/es6-promise/dist/es6-promise.auto.js', './index.js'], + files: ['../../node_modules/es6-promise/dist/es6-promise.auto.js', + '../../node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js', + './index.js'], // we will pass the entry file to webpack for bundling. preprocessors: { './index.js': ['webpack', 'sourcemap'], diff --git a/test/unit/specs/Authentication/Login.spec.js b/test/unit/specs/Authentication/Login.spec.js new file mode 100644 index 00000000..9790c13e --- /dev/null +++ b/test/unit/specs/Authentication/Login.spec.js @@ -0,0 +1,70 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import Login from '../../../../src/components/Authentication/Login.vue'; +import sinon from 'sinon'; + + + +describe('On login', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + let router; + let stub = sandbox.stub(); + + beforeEach(() => { + actions = { + login: stub, + }; + + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + actions, + }); + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should loggin correctly', (done) => { + const $router = { + push: sandbox.stub() + } + + const wrapper = shallow(Login, { store, localVue, mocks: {$router} }); + wrapper.vm.login(); + + expect(actions.login.called).to.equal(true); + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.$router.push.called).to.be.true; + done(); + }); + }); + + it('should not loggin with wrong credentials', (done) => { + const wrapper = shallow(Login, { store, localVue}); + stub.reset(); + stub.rejects(); + wrapper.vm.login(); + + expect(actions.login.called).to.equal(true); + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.errors.has('wrong-credentials')).to.be.true; + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/unit/specs/Authentication/Register.spec.js b/test/unit/specs/Authentication/Register.spec.js new file mode 100644 index 00000000..79020e49 --- /dev/null +++ b/test/unit/specs/Authentication/Register.spec.js @@ -0,0 +1,77 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import Register from '../../../../src/components/Authentication/Register.vue'; +import sinon from 'sinon'; + + + +describe('On register', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + let router; + let loginStub = sandbox.stub(); + + beforeEach(() => { + actions = { + login: loginStub, + }; + + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + actions, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should register correctly', (done) => { + + const $router = { + push: sandbox.stub() + } + let httpStub = sandbox.stub(HTTP, 'post').resolves({data: 200}); + + const wrapper = shallow(Register, { store, localVue, mocks: {$router} }); + + wrapper.vm.register(); + + wrapper.vm.$nextTick(() => { + expect(actions.login.called).to.equal(true); + expect(wrapper.vm.$router.push.called).to.be.true; + done(); + }); + }); + + it('should not register correctly', (done) => { + const $router = { + push: sandbox.stub() + } + let httpStub = sandbox.stub(HTTP, 'post').rejects(); + const wrapper = shallow(Register, { store, localVue, mocks: {$router} }); + + wrapper.vm.register(); + + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.$router.push.called).to.be.false; + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/unit/specs/GitHub/GitHubCallBack.spec.js b/test/unit/specs/GitHub/GitHubCallBack.spec.js new file mode 100644 index 00000000..3b1f3d83 --- /dev/null +++ b/test/unit/specs/GitHub/GitHubCallBack.spec.js @@ -0,0 +1,52 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import Vuex from 'vuex'; +import GitHubCallBack from '../../../../src/components/GitHub/GitHubCallBack.vue'; +import sinon from 'sinon'; + +describe('On github callback', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + + let state; + let actions; + let store; + + beforeEach(() => { + actions = { + linkGithub: sinon.stub(), + }; + + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + actions, + }); + + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should have the correct token', () => { + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(GitHubCallBack, { store, localVue, mocks: {$router} }); + + expect(actions.linkGithub.calledOnce).to.equal(true); + localVue.nextTick(() => { + expect($router.push.calledOnce).to.equal(true); + }); + + }); +}); diff --git a/test/unit/specs/GitHubProjects.spec.js b/test/unit/specs/GitHub/GitHubProjects.spec.js similarity index 93% rename from test/unit/specs/GitHubProjects.spec.js rename to test/unit/specs/GitHub/GitHubProjects.spec.js index ba93f2cf..1926a046 100644 --- a/test/unit/specs/GitHubProjects.spec.js +++ b/test/unit/specs/GitHub/GitHubProjects.spec.js @@ -1,13 +1,14 @@ import Vue from 'vue'; import Vuex from 'vuex'; -import GitHubProjects from '../../../src/components/GitHub/GitHubProjects.vue'; -import { HTTP } from '../../../src/http-common.js'; +import GitHubProjects from '../../../../src/components/GitHub/GitHubProjects.vue'; +import { HTTP } from '../../../../src/http-common.js'; import sinon from 'sinon'; -import auth from '../../../src/services/auth/index'; +import auth from '../../../../src/services/auth/index'; + -const sandbox = sinon.createSandbox(); describe('On github project list repos', () => { + const sandbox = sinon.createSandbox(); let state; let store; beforeEach(() => { @@ -32,6 +33,7 @@ describe('On github project list repos', () => { }); afterEach(() => { + sandbox.reset(); sandbox.restore(); }); @@ -92,6 +94,7 @@ describe('On github project list repos', () => { describe('On GitHubProjects import', () => { + const sandbox = sinon.createSandbox(); let state; let store; beforeEach(() => { diff --git a/test/unit/specs/GitHubCallBack.spec.js b/test/unit/specs/GitHubCallBack.spec.js deleted file mode 100644 index 9b4a433c..00000000 --- a/test/unit/specs/GitHubCallBack.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; -import GitHubCallBack from '../../../src/components/GitHub/GitHubCallBack.vue'; -import { HTTP } from '../../../src/http-common'; -import sinon from 'sinon'; -import auth from '../../../src/services/auth/index'; - -const sandbox = sinon.createSandbox(); - -describe('On github callback', () => { - let state; - let store; - beforeEach(() => { - Vue.use(Vuex); - const response = new Promise(r => r({ - data: { - access_token: '1234', - }, - })); - - sandbox.stub(HTTP, 'post').returns(response); - - state = { - auth: { - token: '12345', - userId: '1', - }, - }; - store = new Vuex.Store({ - state, - }); - }); - - afterEach(() => { - sandbox.restore(); - }); - - it('should have the correct token', (done) => { - const Constructor = Vue.extend(GitHubCallBack); - const component = new Constructor({ store }); - component.$mount(); - process.nextTick(() => { - expect(component.github_token).to.equal('1234'); - HTTP.post.restore(); - done(); - }); - }); -}); diff --git a/test/unit/specs/Hello.spec.js b/test/unit/specs/Hello.spec.js deleted file mode 100644 index e69de29b..00000000 diff --git a/test/unit/specs/Projects/AddProject.spec.js b/test/unit/specs/Projects/AddProject.spec.js new file mode 100644 index 00000000..ab091f60 --- /dev/null +++ b/test/unit/specs/Projects/AddProject.spec.js @@ -0,0 +1,45 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import AddProject from '../../../../src/components/Projects/AddProject.vue'; +import sinon from 'sinon'; + +describe('On Add Project', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + //localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + it('should add a project correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'post').resolves({data: 200}); + const wrapper = shallow(AddProject, {store, localVue}); + wrapper.vm.addProject(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('added')).to.be.truthy + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/unit/specs/Projects/DeleteProject.spec.js b/test/unit/specs/Projects/DeleteProject.spec.js new file mode 100644 index 00000000..2b58ea84 --- /dev/null +++ b/test/unit/specs/Projects/DeleteProject.spec.js @@ -0,0 +1,49 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import DeleteProject from '../../../../src/components/Projects/DeleteProject.vue'; +import sinon from 'sinon'; + +describe('On Delete Project', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + it('should delete a project correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'delete').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(DeleteProject, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.deleteProject(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.$router.push.called).to.be.true; + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/unit/specs/Projects/EditProject.spec.js b/test/unit/specs/Projects/EditProject.spec.js new file mode 100644 index 00000000..b63ec030 --- /dev/null +++ b/test/unit/specs/Projects/EditProject.spec.js @@ -0,0 +1,68 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import EditProject from '../../../../src/components/Projects/EditProject.vue'; +import sinon from 'sinon'; + +describe('On Edit Project', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should mount and get project information correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'get').resolves({ data: { name: 'ProjectName', description: 'ProjectDescription', isScoring: true } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditProject, {store, localVue, mocks: {$route, $router} }); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('edited-project')).to.be.truthy; + done(); + }); + }); + + it('should edit a project correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'put').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditProject, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.editProject(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('edited-project')).to.be.truthy; + done(); + }); + }); + +}); \ No newline at end of file diff --git a/test/unit/specs/Projects/Project.spec.js b/test/unit/specs/Projects/Project.spec.js new file mode 100644 index 00000000..7a24680b --- /dev/null +++ b/test/unit/specs/Projects/Project.spec.js @@ -0,0 +1,53 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import Project from '../../../../src/components/Projects/Project.vue'; +import sinon from 'sinon'; + +describe('On Project Component', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should mount and get project information correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'get').resolves({ data: { name: 'ProjectName', description: 'ProjectDescription', isScoring: true, is_project_from_github: true } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(Project, {store, localVue, mocks: {$route, $router} }); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.project.name).to.be.equal('ProjectName'); + done(); + }); + }); + + + +}); \ No newline at end of file diff --git a/test/unit/specs/Projects/Projects.spec.js b/test/unit/specs/Projects/Projects.spec.js new file mode 100644 index 00000000..209df02a --- /dev/null +++ b/test/unit/specs/Projects/Projects.spec.js @@ -0,0 +1,72 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import Projects from '../../../../src/components/Projects/Projects.vue'; +import sinon from 'sinon'; + + +describe('On projects component', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let store; + let router; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should get projects when mounted',() => { + + let stub = sandbox.stub(HTTP, 'get').resolves({data: [{name: "project1", description: "description1"}]}); + + const wrapper = shallow(Projects, { store, localVue }); + expect(stub.called).to.be.true; + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.projects).to.be.deep.equal([{name: "project1", description: "description1"}]); + }); + }); + + it('should enter v-if with empty projects array',() => { + + let stub = sandbox.stub(HTTP, 'get').resolves({data: []}); + + const wrapper = shallow(Projects, { store, localVue }); + expect(stub.called).to.be.true; + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.projects).to.be.deep.equal([]); + }); + + expect(wrapper.vm.isProjectsEmpty()).to.be.true; + }); + + it('should get projects when refreshed',() => { + + let stub = sandbox.stub(HTTP, 'get').resolves({data: [{name: "project1", description: "description1"}]}); + const wrapper = shallow(Projects, { store, localVue }); + + wrapper.vm.refreshProjects(); + expect(stub.called).to.be.true; + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.projects).to.be.deep.equal([{name: "project1", description: "description1"}]); + }); + }); +}); \ No newline at end of file diff --git a/test/unit/specs/Releases/AddRelease.spec.js b/test/unit/specs/Releases/AddRelease.spec.js new file mode 100644 index 00000000..ce0c83d0 --- /dev/null +++ b/test/unit/specs/Releases/AddRelease.spec.js @@ -0,0 +1,50 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import AddRelease from '../../../../src/components/Releases/AddRelease.vue'; +import sinon from 'sinon'; + +describe('On Add Release', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + //localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + it('should add a release correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'post').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const wrapper = shallow(AddRelease, {store, localVue, mocks: {$route} }); + + wrapper.vm.addRelease(); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('added')).to.be.truthy + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/unit/specs/Releases/DeleteRelease.spec.js b/test/unit/specs/Releases/DeleteRelease.spec.js new file mode 100644 index 00000000..ca8048e0 --- /dev/null +++ b/test/unit/specs/Releases/DeleteRelease.spec.js @@ -0,0 +1,49 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import DeleteRelease from '../../../../src/components/Releases/DeleteRelease.vue'; +import sinon from 'sinon'; + +describe('On Delete Release', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + it('should delete a release correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'delete').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + go: sandbox.stub() + } + const wrapper = shallow(DeleteRelease, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.deleteRelease(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.$router.go.called).to.be.true; + done(); + }); + }) +}); \ No newline at end of file diff --git a/test/unit/specs/Releases/EditRelease.spec.js b/test/unit/specs/Releases/EditRelease.spec.js new file mode 100644 index 00000000..cac4f083 --- /dev/null +++ b/test/unit/specs/Releases/EditRelease.spec.js @@ -0,0 +1,68 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import EditRelease from '../../../../src/components/Releases/EditRelease.vue'; +import sinon from 'sinon'; + +describe('On Edit Release', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should mount and get release information correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'get').resolves({ data: { name: 'ProjectName', description: 'ProjectDescription', isScoring: true } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRelease, {store, localVue, mocks: {$route, $router} }); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('edited-release')).to.be.truthy; + done(); + }); + }); + + it('should edit a release correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'patch').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRelease, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.editRelease(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('edited-release')).to.be.truthy; + done(); + }); + }); + +}); \ No newline at end of file diff --git a/test/unit/specs/Releases/Release.spec.js b/test/unit/specs/Releases/Release.spec.js new file mode 100644 index 00000000..556f422d --- /dev/null +++ b/test/unit/specs/Releases/Release.spec.js @@ -0,0 +1,68 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import Release from '../../../../src/components/Releases/Release.vue'; +import sinon from 'sinon'; + +describe('On Release Component', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should mount and get release information correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'get').resolves({ data: { name: 'ReleaseName', description: 'ReleaseDescription', inital_date: "01/01/2017", final_date: "07/01/2017" } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(Release, {store, localVue, mocks: {$route, $router} }); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.release.name).to.be.equal('ReleaseName'); + done(); + }); + }); + + it('should refresh release information on edit', (done) => { + let httpStub = sandbox.stub(HTTP, 'get').resolves({ data: { name: 'ReleaseName', description: 'ReleaseDescription', initial_date: "01/01/2017", final_date: "07/01/2017" } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(Release, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.refreshRelease(); + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.release.name).to.be.equal('ReleaseName'); + done(); + }); + }) + +}); \ No newline at end of file diff --git a/test/unit/specs/Releases/Releases.spec.js b/test/unit/specs/Releases/Releases.spec.js new file mode 100644 index 00000000..de73320c --- /dev/null +++ b/test/unit/specs/Releases/Releases.spec.js @@ -0,0 +1,85 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import Releases from '../../../../src/components/Releases/Releases.vue'; +import sinon from 'sinon'; + + +describe('On releases component', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let store; + let router; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should get releases when mounted', (done) => { + let stub = sandbox.stub(HTTP, 'get').resolves({data: [{name: "release1", description: "description1"}]}); + const $route = { + params: {id: "2"} + } + + const wrapper = shallow(Releases, { store, localVue, mocks: {$route} }); + + expect(stub.called).to.be.true; + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.releases).to.be.deep.equal([{name: "release1", description: "description1"}]); + done(); + }); + + }); + + it('should enter v-if with empty releases array', (done) => { + let stub = sandbox.stub(HTTP, 'get').resolves({data: []}); + const $route = { + params: {id: "2"} + } + + const wrapper = shallow(Releases, { store, localVue, mocks: {$route} }); + expect(stub.calledOnce).to.be.true; + + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.releases).to.be.deep.equal([]); + expect(wrapper.vm.isReleasesEmpty()).to.be.true; + done(); + }); + }); + + it('should get releases when refreshed', (done) => { + let stub = sandbox.stub(HTTP, 'get').resolves({data: [{name: "release1", description: "description1"}]}); + const $route = { + params: {id: "2"} + } + + const wrapper = shallow(Releases, { store, localVue, mocks: {$route} }); + + wrapper.vm.$emit('added'); + + expect(stub.called).to.be.true; + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.releases).to.be.deep.equal([{name: "release1", description: "description1"}]); + done(); + }); + }); +}); \ No newline at end of file diff --git a/test/unit/specs/Retrospective/AddRetrospective.spec.js b/test/unit/specs/Retrospective/AddRetrospective.spec.js new file mode 100644 index 00000000..357b8d44 --- /dev/null +++ b/test/unit/specs/Retrospective/AddRetrospective.spec.js @@ -0,0 +1,93 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import VeeValidate from 'vee-validate'; +import AddRetrospective from '../../../../src/components/Retrospective/AddRetrospective.vue'; +import sinon from 'sinon'; + +describe('On Add Release', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + //localVue.use(VeeValidate); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should add a retrospective correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'post').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(AddRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.addRetrospective(); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('retrospectiveCreated')).to.be.truthy + done(); + }); + }); + + it('should update postive points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(AddRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint positivePoints1'}], 'PositivePoints'); + expect(wrapper.vm.positivePoints).to.be.deep.equal(['Sprint positivePoints1']) + }); + + it('should update negative points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(AddRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint negativePoints1'}], 'NegativePoints'); + expect(wrapper.vm.negativePoints).to.be.deep.equal(['Sprint negativePoints1']) + }); + + it('should update postive points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(AddRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint improvements'}], 'Improvements'); + expect(wrapper.vm.improvements).to.be.deep.equal(['Sprint improvements']) + }); +}); \ No newline at end of file diff --git a/test/unit/specs/Retrospective/DeleteRetrospective.spec.js b/test/unit/specs/Retrospective/DeleteRetrospective.spec.js new file mode 100644 index 00000000..6aa3d44f --- /dev/null +++ b/test/unit/specs/Retrospective/DeleteRetrospective.spec.js @@ -0,0 +1,52 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import DeleteRetrospective from '../../../../src/components/Retrospective/DeleteRetrospective.vue'; +import sinon from 'sinon'; + +describe('On Delete Retrospective', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.verify(); + sandbox.reset(); + sandbox.restore(); + }); + it('should delete a retrospective correctly', async () => { + let httpGetStub = sandbox.stub(HTTP, 'get').resolves({data: 4}); + let httpStub = sandbox.stub(HTTP, 'delete').resolves({data: 200}); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + + const wrapper = shallow(DeleteRetrospective, {store, localVue, mocks: {$route, $router} }); + await wrapper.vm.deleteRetrospective(); + + + expect(wrapper.vm.$router.push.called).to.be.true; + + + }) +}); \ No newline at end of file diff --git a/test/unit/specs/Retrospective/EditRetrospective.spec.js b/test/unit/specs/Retrospective/EditRetrospective.spec.js new file mode 100644 index 00000000..cf680854 --- /dev/null +++ b/test/unit/specs/Retrospective/EditRetrospective.spec.js @@ -0,0 +1,91 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import EditRetrospective from '../../../../src/components/Retrospective/EditRetrospective.vue'; +import sinon from 'sinon'; + +describe('On Edit Release', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should click and edit retrospective information correctly', (done) => { + let httpStub = sandbox.stub(HTTP, 'patch').resolves({ data: { } }); + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRetrospective, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.editRetrospective(); + + expect(httpStub.called).to.be.true + wrapper.vm.$nextTick(() => { + expect(wrapper.emitted('edited-retrospective')).to.be.truthy; + done(); + }); + }); + + it('should update postive points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint positivePoints1'}], 'PositivePoints'); + expect(wrapper.vm.positivePoints).to.be.deep.equal(['Sprint positivePoints1']) + }); + + it('should update negative points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint negativePoints1'}], 'NegativePoints'); + expect(wrapper.vm.negativePoints).to.be.deep.equal(['Sprint negativePoints1']) + }); + + it('should update postive points list of retrospective correctly', () => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(EditRetrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.updateList([{title: 'Sprint improvements'}], 'Improvements'); + expect(wrapper.vm.improvements).to.be.deep.equal(['Sprint improvements']) + }); + +}); \ No newline at end of file diff --git a/test/unit/specs/Retrospective/List.spec.js b/test/unit/specs/Retrospective/List.spec.js new file mode 100644 index 00000000..8d62bd83 --- /dev/null +++ b/test/unit/specs/Retrospective/List.spec.js @@ -0,0 +1,35 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import List from '../../../../src/components/Retrospective/List.vue'; +import sinon from 'sinon'; + +describe('On List component retrospective', () => { + const sandbox = sinon.createSandbox(); + + beforeEach(() => { + + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should add an item correctly', () => { + const wrapper = shallow(List); + wrapper.setData({newItemText: 'Item Text'}) + wrapper.vm.addNewItem(); + expect(wrapper.vm.items).to.be.deep.equal([{id: 1, title: 'Item Text'}]) + expect(wrapper.emitted('listUpdated')).not.undefined; + }); + + it('should remove an item correctly', () => { + const wrapper = shallow(List); + wrapper.setData({ items: [{id: 1, title: 'Item Text'}] }); + + expect(wrapper.vm.items).to.be.deep.equal([{id: 1, title: 'Item Text'}]); + wrapper.vm.removeItem(0); + + expect(wrapper.vm.items).to.be.empty; + expect(wrapper.emitted('listUpdated')).not.undefined; + }); +}); \ No newline at end of file diff --git a/test/unit/specs/Retrospective/Retrospective.spec.js b/test/unit/specs/Retrospective/Retrospective.spec.js new file mode 100644 index 00000000..c99101ab --- /dev/null +++ b/test/unit/specs/Retrospective/Retrospective.spec.js @@ -0,0 +1,69 @@ +import { shallow, createLocalVue } from 'vue-test-utils' +import { HTTP } from '../../../../src/http-common.js'; +import Vuex from 'vuex'; +import Retrospective from '../../../../src/components/Retrospective/Retrospective.vue'; +import sinon from 'sinon'; + +describe('On Retrospective Component', () => { + const localVue = createLocalVue(); + localVue.use(Vuex); + const sandbox = sinon.createSandbox(); + let state; + let actions; + let store; + + beforeEach(() => { + state = { + auth: { + token: '12345', + userId: '1', + }, + }; + + store = new Vuex.Store({ + state, + }); + sandbox.stub(HTTP, 'get').resolves({ data: { sprint_report: ['report'], + positive_points: ['postive'], + negative_points: ['negative'], + improvements: ['improve'] } }); + }); + + afterEach(() => { + sandbox.reset(); + sandbox.restore(); + }); + + it('should mount and get Retrospective information correctly', (done) => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + + const wrapper = shallow(Retrospective, {store, localVue, mocks: {$route, $router} }); + + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.sprintReport).to.be.deep.equal(['report']); + done(); + }); + }); + + it('should refresh Retrospective information on edit', (done) => { + const $route = { + params: {id: "2"} + } + const $router = { + push: sandbox.stub() + } + const wrapper = shallow(Retrospective, {store, localVue, mocks: {$route, $router} }); + wrapper.vm.refreshRetrospective(); + + wrapper.vm.$nextTick(() => { + expect(wrapper.vm.sprintReport).to.be.deep.equal(['report']); + done(); + }); + }) + +}); \ No newline at end of file From 190fc8687d7399af993e3441ba102e23951bbf30 Mon Sep 17 00:00:00 2001 From: MatheusRich Date: Sat, 9 Dec 2017 09:49:42 -0200 Subject: [PATCH 2/3] Adding Sprint unit tests --- src/components/Sprints/DeleteSprint.vue | 8 +- src/components/Sprints/Sprint.vue | 6 +- src/services/auth/index.js | 8 +- test/unit/specs/Releases/AddRelease.spec.js | 1 + .../Retrospective/DeleteRetrospective.spec.js | 6 +- .../Retrospective/EditRetrospective.spec.js | 2 +- test/unit/specs/Sprints/AddSprint.spec.js | 53 +++++++++++++ test/unit/specs/Sprints/DeleteSprint.spec.js | 51 ++++++++++++ test/unit/specs/Sprints/EditSprint.spec.js | 78 +++++++++++++++++++ test/unit/specs/Sprints/Sprint.spec.js | 68 ++++++++++++++++ test/unit/specs/Sprints/Sprints.spec.js | 67 ++++++++++++++++ 11 files changed, 331 insertions(+), 17 deletions(-) create mode 100644 test/unit/specs/Sprints/AddSprint.spec.js create mode 100644 test/unit/specs/Sprints/DeleteSprint.spec.js create mode 100644 test/unit/specs/Sprints/EditSprint.spec.js create mode 100644 test/unit/specs/Sprints/Sprint.spec.js create mode 100644 test/unit/specs/Sprints/Sprints.spec.js diff --git a/src/components/Sprints/DeleteSprint.vue b/src/components/Sprints/DeleteSprint.vue index 5ae920d8..681b3c7b 100644 --- a/src/components/Sprints/DeleteSprint.vue +++ b/src/components/Sprints/DeleteSprint.vue @@ -1,9 +1,9 @@