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

Commit 779a2f5

Browse files
test: more (#23)
1 parent be42ea4 commit 779a2f5

File tree

6 files changed

+142
-7
lines changed

6 files changed

+142
-7
lines changed

test/__snapshots__/loader.test.js.snap

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,121 @@ exports[`null-loader should works 1`] = `
104104
//# sourceMappingURL=main.js.map"
105105
`;
106106

107-
exports[`null-loader should works: errors 1`] = `Array []`;
107+
exports[`null-loader should works as inline loader 1`] = `
108+
"/******/ (function(modules) { // webpackBootstrap
109+
/******/ // The module cache
110+
/******/ var installedModules = {};
111+
/******/
112+
/******/ // The require function
113+
/******/ function __webpack_require__(moduleId) {
114+
/******/
115+
/******/ // Check if module is in cache
116+
/******/ if(installedModules[moduleId]) {
117+
/******/ return installedModules[moduleId].exports;
118+
/******/ }
119+
/******/ // Create a new module (and put it into the cache)
120+
/******/ var module = installedModules[moduleId] = {
121+
/******/ i: moduleId,
122+
/******/ l: false,
123+
/******/ exports: {}
124+
/******/ };
125+
/******/
126+
/******/ // Execute the module function
127+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
128+
/******/
129+
/******/ // Flag the module as loaded
130+
/******/ module.l = true;
131+
/******/
132+
/******/ // Return the exports of the module
133+
/******/ return module.exports;
134+
/******/ }
135+
/******/
136+
/******/
137+
/******/ // expose the modules object (__webpack_modules__)
138+
/******/ __webpack_require__.m = modules;
139+
/******/
140+
/******/ // expose the module cache
141+
/******/ __webpack_require__.c = installedModules;
142+
/******/
143+
/******/ // define getter function for harmony exports
144+
/******/ __webpack_require__.d = function(exports, name, getter) {
145+
/******/ if(!__webpack_require__.o(exports, name)) {
146+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
147+
/******/ }
148+
/******/ };
149+
/******/
150+
/******/ // define __esModule on exports
151+
/******/ __webpack_require__.r = function(exports) {
152+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
153+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
154+
/******/ }
155+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
156+
/******/ };
157+
/******/
158+
/******/ // create a fake namespace object
159+
/******/ // mode & 1: value is a module id, require it
160+
/******/ // mode & 2: merge all properties of value into the ns
161+
/******/ // mode & 4: return value when already ns object
162+
/******/ // mode & 8|1: behave like require
163+
/******/ __webpack_require__.t = function(value, mode) {
164+
/******/ if(mode & 1) value = __webpack_require__(value);
165+
/******/ if(mode & 8) return value;
166+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
167+
/******/ var ns = Object.create(null);
168+
/******/ __webpack_require__.r(ns);
169+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
170+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
171+
/******/ return ns;
172+
/******/ };
173+
/******/
174+
/******/ // getDefaultExport function for compatibility with non-harmony modules
175+
/******/ __webpack_require__.n = function(module) {
176+
/******/ var getter = module && module.__esModule ?
177+
/******/ function getDefault() { return module['default']; } :
178+
/******/ function getModuleExports() { return module; };
179+
/******/ __webpack_require__.d(getter, 'a', getter);
180+
/******/ return getter;
181+
/******/ };
182+
/******/
183+
/******/ // Object.prototype.hasOwnProperty.call
184+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
185+
/******/
186+
/******/ // __webpack_public_path__
187+
/******/ __webpack_require__.p = \\"\\";
188+
/******/
189+
/******/
190+
/******/ // Load entry module and return exports
191+
/******/ return __webpack_require__(__webpack_require__.s = \\"./inline-loader.js\\");
192+
/******/ })
193+
/************************************************************************/
194+
/******/ ({
195+
196+
/***/ \\"../../src/index.js!./foo.js\\":
197+
/***/ (function(module, exports) {
198+
199+
// empty (null-loader)
200+
201+
/***/ }),
202+
203+
/***/ \\"./inline-loader.js\\":
204+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
205+
206+
\\"use strict\\";
207+
__webpack_require__.r(__webpack_exports__);
208+
/* harmony import */ var _src_index_js_foo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(\\"../../src/index.js!./foo.js\\");
209+
/* harmony import */ var _src_index_js_foo__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_src_index_js_foo__WEBPACK_IMPORTED_MODULE_0__);
210+
// eslint-disable-next-line
211+
212+
213+
/* harmony default export */ __webpack_exports__[\\"default\\"] = (_src_index_js_foo__WEBPACK_IMPORTED_MODULE_0___default.a);
214+
215+
216+
/***/ })
217+
218+
/******/ });
219+
//# sourceMappingURL=main.js.map"
220+
`;
221+
222+
exports[`null-loader should works as inline loader: errors 1`] = `Array []`;
108223

109-
exports[`null-loader should works: warnings 1`] = `Array []`;
224+
exports[`null-loader should works as inline loader: warnings 1`] = `Array []`;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`validation with empty options 1`] = `Array []`;
3+
exports[`validation with empty options: errors 1`] = `Array []`;
44

5-
exports[`validation with empty options 2`] = `Array []`;
5+
exports[`validation with empty options: warnings 1`] = `Array []`;
66

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

9-
exports[`validation without options 1`] = `Array []`;
9+
exports[`validation without options: errors 1`] = `Array []`;
1010

11-
exports[`validation without options 2`] = `Array []`;
11+
exports[`validation without options: warnings 1`] = `Array []`;

test/fixtures/inline-loader.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line
2+
import foo from '../../src/index.js!./foo';
3+
4+
export default foo;

test/helpers/compiler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const output = (config) => {
3232
),
3333
filename: '[name].js',
3434
chunkFilename: '[name].chunk.js',
35+
pathinfo: typeof config.pathinfo !== 'undefined' ? config.pathinfo : true,
3536
};
3637
};
3738

test/loader.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,19 @@ describe('null-loader', () => {
1717

1818
expect(stats.compilation.assets['main.js'].source()).toMatchSnapshot();
1919
});
20+
21+
it.only('should works as inline loader', async () => {
22+
const config = {
23+
pathinfo: false,
24+
devtool: false,
25+
};
26+
27+
const stats = await webpack('inline-loader.js', config);
28+
const { warnings, errors } = stats.toJson();
29+
30+
expect(warnings).toMatchSnapshot('warnings');
31+
expect(errors).toMatchSnapshot('errors');
32+
33+
expect(stats.compilation.assets['main.js'].source()).toMatchSnapshot();
34+
});
2035
});

test/validation.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('validation', () => {
3030
expect(errors).toMatchSnapshot('errors');
3131
});
3232

33-
it.only('with unknown options', async () => {
33+
it('with unknown options', async () => {
3434
const config = {
3535
loader: {
3636
test: /\.js$/,

0 commit comments

Comments
 (0)