diff --git a/core/tests/Drupal/Tests/MochaJsTestDiscovery.php b/core/tests/Drupal/Tests/MochaJsTestDiscovery.php new file mode 100644 index 0000000..4d6cac1 --- /dev/null +++ b/core/tests/Drupal/Tests/MochaJsTestDiscovery.php @@ -0,0 +1,36 @@ +root = $root; + $this->sitePath = $site_path; + } + + public function getTestClasses() { + $extension_discovery = new ExtensionDiscovery($this->root, TRUE, [], $this->sitePath); + + $extensions = ['core' => new Extension($this->root, 'core', 'core/core.info.yml')]; + $extensions += $extension_discovery->scan('module', TRUE); + $extensions += $extension_discovery->scan('theme', TRUE); + $extensions += $extension_discovery->scan('profile', TRUE); + + $js_tests = []; + foreach ($extensions as $extension) { + if (file_exists($this->root . '/' . $extension->getPath() . '/tests/js')) { + $js_tests['js--mocha-' . $extension->getName()] = TRUE; + }; + } + return $js_tests; + } + +} diff --git a/core/tests/Drupal/Tests/MochaJsTestDiscoveryTest.php b/core/tests/Drupal/Tests/MochaJsTestDiscoveryTest.php new file mode 100644 index 0000000..7c72cb5 --- /dev/null +++ b/core/tests/Drupal/Tests/MochaJsTestDiscoveryTest.php @@ -0,0 +1,69 @@ + [ + 'test.js' => '', + ], + 'modules' => [ + 'module_a' => [ + 'module_a.info.yml' => $module_a, + 'tests' => [ + 'js' => [ + 'test.js' => '', + ], + ], + ], + 'module_b' => [ + 'module_b.info.yml' => $module_b, + ], + ], + 'themes' => [ + 'theme_a' => [ + 'theme_a.info.yml' => $theme_a, + 'tests' => [ + 'js' => [ + 'test.js' => '', + ], + ], + ], + ], + ]); + + $js_test_discovery = new MochaJsTestDiscovery('vfs://drupal', 'sites/default'); + $result = $js_test_discovery->getTestClasses(); + $expected = [ + 'js--mocha-core' => TRUE, + 'js--mocha-module_a' => TRUE, + 'js--mocha-theme_a' => TRUE, + ]; + $this->assertEquals($expected, $result); + } + +} diff --git a/core/tests/js/npm-shrinkwrap.json b/core/tests/js/npm-shrinkwrap.json index 9b9ccef..e611279 100644 --- a/core/tests/js/npm-shrinkwrap.json +++ b/core/tests/js/npm-shrinkwrap.json @@ -1,4 +1,185 @@ { "name": "js", - "version": "1.0.0" + "version": "1.0.0", + "dependencies": { + "assertion-error": { + "version": "1.0.1", + "from": "assertion-error@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.1.tgz" + }, + "chai": { + "version": "3.5.0", + "from": "chai@>=3.5.0 <4.0.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz" + }, + "charenc": { + "version": "0.0.1", + "from": "charenc@>=0.0.1 <0.1.0", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.1.tgz" + }, + "commander": { + "version": "2.3.0", + "from": "commander@2.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz" + }, + "crypt": { + "version": "0.0.1", + "from": "crypt@>=0.0.1 <0.1.0", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.1.tgz" + }, + "debug": { + "version": "2.2.0", + "from": "debug@2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + }, + "deep-eql": { + "version": "0.1.3", + "from": "deep-eql@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", + "dependencies": { + "type-detect": { + "version": "0.1.1", + "from": "type-detect@0.1.1", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz" + } + } + }, + "diff": { + "version": "1.4.0", + "from": "diff@1.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz" + }, + "escape-string-regexp": { + "version": "1.0.2", + "from": "escape-string-regexp@1.0.2", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz" + }, + "formatio": { + "version": "1.1.1", + "from": "formatio@1.1.1", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz" + }, + "glob": { + "version": "3.2.3", + "from": "glob@3.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.3.tgz" + }, + "graceful-fs": { + "version": "2.0.3", + "from": "graceful-fs@>=2.0.0 <2.1.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz" + }, + "growl": { + "version": "1.8.1", + "from": "growl@1.8.1", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.8.1.tgz" + }, + "inherits": { + "version": "2.0.1", + "from": "inherits@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + }, + "is-buffer": { + "version": "1.1.3", + "from": "is-buffer@>=1.1.1 <1.2.0", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.3.tgz" + }, + "jade": { + "version": "0.26.3", + "from": "jade@0.26.3", + "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "dependencies": { + "commander": { + "version": "0.6.1", + "from": "commander@0.6.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz" + }, + "mkdirp": { + "version": "0.3.0", + "from": "mkdirp@0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz" + } + } + }, + "lolex": { + "version": "1.3.2", + "from": "lolex@1.3.2", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz" + }, + "lru-cache": { + "version": "2.7.3", + "from": "lru-cache@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz" + }, + "md5": { + "version": "2.1.0", + "from": "md5@>=2.1.0 <3.0.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.1.0.tgz" + }, + "minimatch": { + "version": "0.2.14", + "from": "minimatch@>=0.2.11 <0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz" + }, + "minimist": { + "version": "0.0.8", + "from": "minimist@0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" + }, + "mkdirp": { + "version": "0.5.1", + "from": "mkdirp@0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" + }, + "mocha": { + "version": "2.4.5", + "from": "mocha@>=2.4.5 <3.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.4.5.tgz" + }, + "mocha-junit-reporter": { + "version": "1.11.1", + "from": "mocha-junit-reporter@latest", + "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-1.11.1.tgz" + }, + "ms": { + "version": "0.7.1", + "from": "ms@0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "samsam": { + "version": "1.1.2", + "from": "samsam@1.1.2", + "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz" + }, + "sigmund": { + "version": "1.0.1", + "from": "sigmund@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" + }, + "sinon": { + "version": "1.17.3", + "from": "sinon@>=1.17.3 <2.0.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.3.tgz" + }, + "supports-color": { + "version": "1.2.0", + "from": "supports-color@1.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz" + }, + "type-detect": { + "version": "1.0.0", + "from": "type-detect@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz" + }, + "util": { + "version": "0.10.3", + "from": "util@>=0.10.3 <1.0.0", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz" + }, + "xml": { + "version": "1.0.1", + "from": "xml@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz" + } + } } diff --git a/core/tests/js/package.json b/core/tests/js/package.json index d68fc2d..26e6fa3 100644 --- a/core/tests/js/package.json +++ b/core/tests/js/package.json @@ -11,6 +11,7 @@ "dependencies": { "chai": "^3.5.0", "mocha": "^2.4.5", + "mocha-junit-reporter": "^1.11.1", "sinon": "^1.17.3" } } diff --git a/core/tests/js/test/states.js b/core/tests/js/test/states.js index 335b41c..0a6618d 100644 --- a/core/tests/js/test/states.js +++ b/core/tests/js/test/states.js @@ -1,4 +1,4 @@ -var execfile = require("../execfile"); +var execfile = require("execfile"); var sinon = require('sinon'); var chai = require('chai'); var assert = chai.assert;