From 3fa67416e1729d599d4ea611680e1c0ab300b3b0 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Tue, 4 Dec 2018 23:56:13 +0100 Subject: [PATCH] test: add test for imports via AMD --- .gitignore | 4 ++-- package-lock.json | 6 ++++++ package.json | 4 +++- test/bundle/index.html | 36 ++++++++++++++++++++++++++++++++++++ test/bundle/test_bundle.js | 14 ++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 test/bundle/index.html create mode 100644 test/bundle/test_bundle.js diff --git a/.gitignore b/.gitignore index 3cd765410..603b54a9d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ _build .customizer bower_components -bundle -build/* +./bundle +./build/* /docs2/public/* _yardoc coverage diff --git a/package-lock.json b/package-lock.json index d3494430c..8eba57770 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13740,6 +13740,12 @@ } } }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", + "dev": true + }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", diff --git a/package.json b/package.json index 99b09fe85..aa0ad3221 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,14 @@ "homepage": "http://foundation.zurb.com/sites", "scripts": { "start": "gulp", - "test": "npm run test:sass && npm run test:javascript:units", + "test": "npm run test:sass && npm run test:javascript:units && npm run test:bundle", "test:ci": "npm run test:sass && npm run test:javascript:ci", "test:sass": "mocha test/sass/test_sass.js --colors", "test:javascript:transpile": "gulp sass:foundation --color && gulp test:transpile-js --color", "test:javascript:units": "npm run test:javascript:transpile && mocha-headless-chrome -a ignore-resource-errors -a no-sandbox -f test/javascript/index.html", "test:javascript:browserstack": "npm run test:javascript:transpile && browserstack-runner", "test:javascript:ci": "npm run test:javascript:transpile && mocha-headless-chrome -a ignore-resource-errors -a no-sandbox -f test/javascript/index.html && browserstack-runner", + "test:bundle": "mocha-headless-chrome -a ignore-resource-errors -a no-sandbox -f test/bundle/index.html", "test:visual": "gulp test --color", "lockdeps": "npm i && rimraf yarn.lock && yarn import && rimraf shrinkwrap.yaml && pnpm import", "relockdeps": "rimraf package-lock.json && npm run lockdeps", @@ -85,6 +86,7 @@ "parker": "^1.0.0-alpha.0", "prettyjson": "^1.1.3", "require-dir": "^1.0.0", + "requirejs": "^2.3.6", "rimraf": "^2.6.1", "rollup": "^0.65.2", "rollup-plugin-babel": "^4.0.3", diff --git a/test/bundle/index.html b/test/bundle/index.html new file mode 100644 index 000000000..1f286819b --- /dev/null +++ b/test/bundle/index.html @@ -0,0 +1,36 @@ + + + + + Mocha + + + + + + + + + + + + + +
+ + + + + diff --git a/test/bundle/test_bundle.js b/test/bundle/test_bundle.js new file mode 100644 index 000000000..33d6d298a --- /dev/null +++ b/test/bundle/test_bundle.js @@ -0,0 +1,14 @@ +describe('Foundation bundle', function() { + + it('can be imported via AMD', function (done) { + + require(['../../_build/assets/js/foundation'], function(foundation) { + foundation.Foundation.should.be.an('object'); + done(); + }, function (err) { + if (err) throw err; + }); + + }); + +}); -- 2.47.2