Skip to content

Commit

Permalink
chore: Add tests for webpack.config.js module exports
Browse files Browse the repository at this point in the history
Adds `npm run test:buildconfig` command, and runs it during `npm test`.

Replaces `;` with `&&` in `package.json` (Windows `cmd.exe` does not support `;`).

Prerequisite for #1994
  • Loading branch information
acdvorak committed Feb 3, 2018
1 parent 2fe4dcd commit 36d8384
Show file tree
Hide file tree
Showing 10 changed files with 1,015 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ rules:
mocha/no-nested-tests: error
mocha/no-pending-tests: error
mocha/no-skipped-tests: error
mocha/valid-suite-description: [error, ^MDC.+]
mocha/valid-suite-description: [error, ^MDC.+|^webpack]
61 changes: 60 additions & 1 deletion closure_externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* @see http://npmjs.com/focus-trap
*/

goog.provide('mdc.thirdparty.focusTrap')
goog.provide('mdc.thirdparty.focusTrap');

/**
* @typedef {{
Expand Down Expand Up @@ -106,3 +106,62 @@ class FocusTrapInstance {
* @param {FocusTrapCreateOptions=} createOptions
*/
mdc.thirdparty.focusTrap.default;

/** @record */
class PathLib {
/**
* @param {string} path
* @param {string=} extension
* @return {string}
*/
basename(path, extension) {}

/**
* @param {string} from
* @param {string} to
* @return {string}
*/
relative(from, to) {}

/**
* @param {...string} paths
* @return {string}
*/
resolve(...paths) {}

/**
* Joins all given path segments together using the platform specific separator as a delimiter, then normalizes the
* resulting this.pathLib_.
*
* Zero-length path segments are ignored. If the joined path string is a zero-length string then '.' will be returned,
* representing the current working directory.
*
* @param {...string} paths
* @return {string}
*/
join(...paths) {}
}

/** @record */
class GlobLib {
/**
* @param {string} pattern
* @param {!Object=} options
* @return {!Array<string>}
*/
sync(pattern, options = undefined) {}
}

/** @record */
class FsExtraLib {
/**
* @param {string} path
* @return {boolean}
*/
existsSync(path) {}

/**
* @param {string} path
*/
removeSync(path) {}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
"lint": "npm-run-all --parallel lint:*",
"postinstall": "lerna bootstrap",
"pretest": "npm run lint && node scripts/check-imports.js",
"test": "npm run test:unit && npm run test:closure && npm run test:dependency && npm run build; npm run clean",
"test": "npm run test:buildconfig && npm run test:unit && npm run test:closure && npm run test:dependency && npm run build && npm run clean",
"posttest": "istanbul report --root coverage text-summary && istanbul check-coverage --lines 95 --statements 95 --branches 95 --functions 95",
"test:watch": "karma start --auto-watch",
"test:unit": "karma start --single-run",
"test:closure": "./scripts/closure-test.sh",
"test:dependency": "./scripts/dependency-test.sh"
"test:dependency": "./scripts/dependency-test.sh",
"test:buildconfig": "mocha ./test/build/index.js"
},
"devDependencies": {
"ascii-table": "0.0.9",
Expand Down Expand Up @@ -59,6 +60,7 @@
"istanbul": "^0.4.4",
"istanbul-instrumenter-loader": "^3.0.0",
"json-loader": "^0.5.4",
"json-stringify-safe": "^5.0.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.0",
Expand Down
207 changes: 207 additions & 0 deletions test/build/goldens/build-config-dev-env.golden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
[
{
"name": "js-all",
"entry": "/packages/material-components-web/index.js",
"output": {
"path": "/build",
"publicPath": "/assets/",
"filename": "material-components-web.js",
"libraryTarget": "umd",
"library": "mdc"
},
"devServer": {
"disableHostCheck": true
},
"devtool": "source-map",
"module": {
"rules": [
{
"test": {},
"exclude": {},
"loader": "babel-loader",
"options": {
"cacheDirectory": true
}
}
]
},
"plugins": [
{
"options": {
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/",
"raw": true,
"entryOnly": true
},
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/"
}
]
},
{
"name": "demo-css",
"entry": {
"button": "/demos/button.scss",
"card": "/demos/card.scss",
"checkbox": "/demos/checkbox.scss",
"chips": "/demos/chips.scss",
"common": "/demos/common.scss",
"dialog": "/demos/dialog.scss",
"drawer/drawer": "/demos/drawer/drawer.scss",
"elevation": "/demos/elevation.scss",
"fab": "/demos/fab.scss",
"grid-list": "/demos/grid-list.scss",
"icon-toggle": "/demos/icon-toggle.scss",
"index": "/demos/index.scss",
"layout-grid": "/demos/layout-grid.scss",
"linear-progress": "/demos/linear-progress.scss",
"list": "/demos/list.scss",
"menu": "/demos/menu.scss",
"radio": "/demos/radio.scss",
"ripple": "/demos/ripple.scss",
"select": "/demos/select.scss",
"slider": "/demos/slider.scss",
"snackbar": "/demos/snackbar.scss",
"switch": "/demos/switch.scss",
"tabs": "/demos/tabs.scss",
"text-field": "/demos/text-field.scss",
"theme/theme-baseline": "/demos/theme/theme-baseline.scss",
"theme/theme-black": "/demos/theme/theme-black.scss",
"theme/theme-dark": "/demos/theme/theme-dark.scss",
"theme/theme-white": "/demos/theme/theme-white.scss",
"theme/theme-yellow": "/demos/theme/theme-yellow.scss",
"toolbar/toolbar": "/demos/toolbar/toolbar.scss",
"typography": "/demos/typography.scss"
},
"output": {
"path": "/build",
"publicPath": "/assets/",
"filename": "[name].css.js"
},
"devtool": false,
"module": {
"rules": [
{
"test": {},
"use": [
{
"loader": "/node_modules/extract-text-webpack-plugin/dist/loader.js",
"options": {
"omit": 1,
"remove": true
}
},
{
"loader": "style-loader"
},
{
"loader": "css-loader",
"options": {
"sourceMap": false
}
},
{
"loader": "postcss-loader",
"options": {
"sourceMap": false
}
},
{
"loader": "sass-loader",
"options": {
"sourceMap": false,
"includePaths": [
"/packages/material-components-web/node_modules",
"/packages/mdc-button/node_modules",
"/packages/mdc-card/node_modules",
"/packages/mdc-checkbox/node_modules",
"/packages/mdc-chips/node_modules",
"/packages/mdc-dialog/node_modules",
"/packages/mdc-drag-drop/node_modules",
"/packages/mdc-drawer/node_modules",
"/packages/mdc-elevation/node_modules",
"/packages/mdc-fab/node_modules",
"/packages/mdc-form-field/node_modules",
"/packages/mdc-grid-list/node_modules",
"/packages/mdc-icon-toggle/node_modules",
"/packages/mdc-line-ripple/node_modules",
"/packages/mdc-linear-progress/node_modules",
"/packages/mdc-list/node_modules",
"/packages/mdc-menu/node_modules",
"/packages/mdc-radio/node_modules",
"/packages/mdc-ripple/node_modules",
"/packages/mdc-select/node_modules",
"/packages/mdc-selection-control/node_modules",
"/packages/mdc-slider/node_modules",
"/packages/mdc-snackbar/node_modules",
"/packages/mdc-switch/node_modules",
"/packages/mdc-tabs/node_modules",
"/packages/mdc-textfield/node_modules",
"/packages/mdc-toolbar/node_modules"
]
}
}
]
}
]
},
"plugins": [
{
"filename": "[name].css",
"id": 3,
"options": {}
},
{
"options": {
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/",
"raw": true,
"entryOnly": true
},
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/"
},
{}
]
},
{
"name": "demo-js",
"entry": {
"common": [
"/demos/common.js"
],
"theme/index": [
"/demos/theme/index.js"
]
},
"output": {
"path": "/build",
"publicPath": "/assets/",
"filename": "[name].js",
"libraryTarget": "umd",
"library": [
"demo",
"[name]"
]
},
"devtool": "source-map",
"module": {
"rules": [
{
"test": {},
"exclude": {},
"loader": "babel-loader",
"options": {
"cacheDirectory": true
}
}
]
},
"plugins": [
{
"options": {
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/",
"raw": true,
"entryOnly": true
},
"banner": "/*!\n Material Components for the web\n Copyright (c) 2018 Google Inc.\n License: Apache-2.0\n*/"
}
]
}
]
Loading

0 comments on commit 36d8384

Please sign in to comment.