Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

test: more #23

Merged
merged 1 commit into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 117 additions & 2 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,121 @@ exports[`null-loader should works 1`] = `
//# sourceMappingURL=main.js.map"
`;

exports[`null-loader should works: errors 1`] = `Array []`;
exports[`null-loader should works as inline loader 1`] = `
"/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = \\"\\";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = \\"./inline-loader.js\\");
/******/ })
/************************************************************************/
/******/ ({

/***/ \\"../../src/index.js!./foo.js\\":
/***/ (function(module, exports) {

// empty (null-loader)

/***/ }),

/***/ \\"./inline-loader.js\\":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

\\"use strict\\";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _src_index_js_foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(\\"../../src/index.js!./foo.js\\");
/* harmony import */ var _src_index_js_foo__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_src_index_js_foo__WEBPACK_IMPORTED_MODULE_0__);
// eslint-disable-next-line


/* harmony default export */ __webpack_exports__[\\"default\\"] = (_src_index_js_foo__WEBPACK_IMPORTED_MODULE_0___default.a);


/***/ })

/******/ });
//# sourceMappingURL=main.js.map"
`;

exports[`null-loader should works as inline loader: errors 1`] = `Array []`;

exports[`null-loader should works: warnings 1`] = `Array []`;
exports[`null-loader should works as inline loader: warnings 1`] = `Array []`;
8 changes: 4 additions & 4 deletions test/__snapshots__/validation.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`validation with empty options 1`] = `Array []`;
exports[`validation with empty options: errors 1`] = `Array []`;

exports[`validation with empty options 2`] = `Array []`;
exports[`validation with empty options: warnings 1`] = `Array []`;

exports[`validation with unknown options: warnings 1`] = `Array []`;

exports[`validation without options 1`] = `Array []`;
exports[`validation without options: errors 1`] = `Array []`;

exports[`validation without options 2`] = `Array []`;
exports[`validation without options: warnings 1`] = `Array []`;
4 changes: 4 additions & 0 deletions test/fixtures/inline-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line
import foo from '../../src/index.js!./foo';

export default foo;
1 change: 1 addition & 0 deletions test/helpers/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const output = (config) => {
),
filename: '[name].js',
chunkFilename: '[name].chunk.js',
pathinfo: typeof config.pathinfo !== 'undefined' ? config.pathinfo : true,
};
};

Expand Down
15 changes: 15 additions & 0 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,19 @@ describe('null-loader', () => {

expect(stats.compilation.assets['main.js'].source()).toMatchSnapshot();
});

it.only('should works as inline loader', async () => {
const config = {
pathinfo: false,
devtool: false,
};

const stats = await webpack('inline-loader.js', config);
const { warnings, errors } = stats.toJson();

expect(warnings).toMatchSnapshot('warnings');
expect(errors).toMatchSnapshot('errors');

expect(stats.compilation.assets['main.js'].source()).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion test/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('validation', () => {
expect(errors).toMatchSnapshot('errors');
});

it.only('with unknown options', async () => {
it('with unknown options', async () => {
const config = {
loader: {
test: /\.js$/,
Expand Down