Skip to content

Commit 4c838e9

Browse files
test: check
1 parent 6dbb901 commit 4c838e9

File tree

2 files changed

+57
-225
lines changed

2 files changed

+57
-225
lines changed
Lines changed: 51 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -1,228 +1,61 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`loader should have same "contenthash" with "sass-loader" and with source maps: errors 1`] = `Array []`;
3+
exports[`loader should have same "contenthash" with "css-loader" and with source maps: errors 1`] = `Array []`;
44

5-
exports[`loader should have same "contenthash" with "sass-loader" and with source maps: module 1`] = `
6-
Object {
7-
"main.a12ab765493c74c80be2.bundle.js": "/******/ (function(modules) { // webpackBootstrap
8-
/******/ // The module cache
9-
/******/ var installedModules = {};
10-
/******/
11-
/******/ // The require function
12-
/******/ function __webpack_require__(moduleId) {
13-
/******/
14-
/******/ // Check if module is in cache
15-
/******/ if(installedModules[moduleId]) {
16-
/******/ return installedModules[moduleId].exports;
17-
/******/ }
18-
/******/ // Create a new module (and put it into the cache)
19-
/******/ var module = installedModules[moduleId] = {
20-
/******/ i: moduleId,
21-
/******/ l: false,
22-
/******/ exports: {}
23-
/******/ };
24-
/******/
25-
/******/ // Execute the module function
26-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27-
/******/
28-
/******/ // Flag the module as loaded
29-
/******/ module.l = true;
30-
/******/
31-
/******/ // Return the exports of the module
32-
/******/ return module.exports;
33-
/******/ }
34-
/******/
35-
/******/
36-
/******/ // expose the modules object (__webpack_modules__)
37-
/******/ __webpack_require__.m = modules;
38-
/******/
39-
/******/ // expose the module cache
40-
/******/ __webpack_require__.c = installedModules;
41-
/******/
42-
/******/ // define getter function for harmony exports
43-
/******/ __webpack_require__.d = function(exports, name, getter) {
44-
/******/ if(!__webpack_require__.o(exports, name)) {
45-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46-
/******/ }
47-
/******/ };
48-
/******/
49-
/******/ // define __esModule on exports
50-
/******/ __webpack_require__.r = function(exports) {
51-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53-
/******/ }
54-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
55-
/******/ };
56-
/******/
57-
/******/ // create a fake namespace object
58-
/******/ // mode & 1: value is a module id, require it
59-
/******/ // mode & 2: merge all properties of value into the ns
60-
/******/ // mode & 4: return value when already ns object
61-
/******/ // mode & 8|1: behave like require
62-
/******/ __webpack_require__.t = function(value, mode) {
63-
/******/ if(mode & 1) value = __webpack_require__(value);
64-
/******/ if(mode & 8) return value;
65-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66-
/******/ var ns = Object.create(null);
67-
/******/ __webpack_require__.r(ns);
68-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70-
/******/ return ns;
71-
/******/ };
72-
/******/
73-
/******/ // getDefaultExport function for compatibility with non-harmony modules
74-
/******/ __webpack_require__.n = function(module) {
75-
/******/ var getter = module && module.__esModule ?
76-
/******/ function getDefault() { return module['default']; } :
77-
/******/ function getModuleExports() { return module; };
78-
/******/ __webpack_require__.d(getter, 'a', getter);
79-
/******/ return getter;
80-
/******/ };
81-
/******/
82-
/******/ // Object.prototype.hasOwnProperty.call
83-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84-
/******/
85-
/******/ // __webpack_public_path__
86-
/******/ __webpack_require__.p = \\"/webpack/public/path/\\";
87-
/******/
88-
/******/
89-
/******/ // Load entry module and return exports
90-
/******/ return __webpack_require__(__webpack_require__.s = \\"./contenthash/basic-sass.js\\");
91-
/******/ })
92-
/************************************************************************/
93-
/******/ ({
94-
95-
/***/ \\"../../src/runtime/api.js\\":
96-
/*!**********************************************************************!*\\\\
97-
!*** /home/evilebottnawi/IdeaProjects/css-loader/src/runtime/api.js ***!
98-
\\\\**********************************************************************/
99-
/*! no static exports found */
100-
/***/ (function(module, exports) {
101-
102-
/*
103-
MIT License http://www.opensource.org/licenses/mit-license.php
104-
Author Tobias Koppers @sokra
105-
*/
106-
// css base code, injected by the css-loader
107-
// eslint-disable-next-line func-names
108-
module.exports = function(useSourceMap) {
109-
const list = [];
110-
111-
// return the list of modules as css string
112-
list.toString = function toString() {
113-
return this.map((item) => {
114-
const content = cssWithMappingToString(item, useSourceMap);
115-
116-
if (item[2]) {
117-
return \`@media \${item[2]} {\${content}}\`;
118-
}
119-
120-
return content;
121-
}).join('');
122-
};
123-
124-
// import a list of modules into the list
125-
// eslint-disable-next-line func-names
126-
list.i = function(modules, mediaQuery) {
127-
if (typeof modules === 'string') {
128-
// eslint-disable-next-line no-param-reassign
129-
modules = [[null, modules, '']];
130-
}
131-
132-
for (let i = 0; i < modules.length; i++) {
133-
const item = [].concat(modules[i]);
134-
135-
if (mediaQuery) {
136-
if (!item[2]) {
137-
item[2] = mediaQuery;
138-
} else {
139-
item[2] = \`\${mediaQuery} and \${item[2]}\`;
140-
}
141-
}
142-
143-
list.push(item);
144-
}
145-
};
146-
147-
return list;
148-
};
149-
150-
function cssWithMappingToString(item, useSourceMap) {
151-
const content = item[1] || '';
152-
// eslint-disable-next-line prefer-destructuring
153-
const cssMapping = item[3];
154-
155-
if (!cssMapping) {
156-
return content;
157-
}
158-
159-
if (useSourceMap && typeof btoa === 'function') {
160-
const sourceMapping = toComment(cssMapping);
161-
const sourceURLs = cssMapping.sources.map(
162-
(source) => \`/*# sourceURL=\${cssMapping.sourceRoot}\${source} */\`
163-
);
164-
165-
return [content]
166-
.concat(sourceURLs)
167-
.concat([sourceMapping])
168-
.join('\\\\n');
169-
}
170-
171-
return [content].join('\\\\n');
172-
}
173-
174-
// Adapted from convert-source-map (MIT)
175-
function toComment(sourceMap) {
176-
// eslint-disable-next-line no-undef
177-
const base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
178-
const data = \`sourceMappingURL=data:application/json;charset=utf-8;base64,\${base64}\`;
179-
180-
return \`/*# \${data} */\`;
181-
}
182-
183-
184-
/***/ }),
185-
186-
/***/ \\"./contenthash/basic-sass.js\\":
187-
/*!***********************************!*\\\\
188-
!*** ./contenthash/basic-sass.js ***!
189-
\\\\***********************************/
190-
/*! exports provided: default */
191-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
192-
193-
\\"use strict\\";
194-
__webpack_require__.r(__webpack_exports__);
195-
/* harmony import */ var _basic_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./basic.scss */ \\"./contenthash/basic.scss\\");
196-
/* harmony import */ var _basic_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_basic_scss__WEBPACK_IMPORTED_MODULE_0__);
197-
198-
199-
__export__ = _basic_scss__WEBPACK_IMPORTED_MODULE_0___default.a;
200-
201-
/* harmony default export */ __webpack_exports__[\\"default\\"] = (_basic_scss__WEBPACK_IMPORTED_MODULE_0___default.a);
202-
203-
204-
/***/ }),
205-
206-
/***/ \\"./contenthash/basic.scss\\":
207-
/*!********************************!*\\\\
208-
!*** ./contenthash/basic.scss ***!
209-
\\\\********************************/
210-
/*! no static exports found */
211-
/***/ (function(module, exports, __webpack_require__) {
5+
exports[`loader should have same "contenthash" with "css-loader" and with source maps: module 1`] = `
6+
Array [
7+
"main.54b9712c1981e48c12c4.bundle.js",
8+
]
9+
`;
10+
11+
exports[`loader should have same "contenthash" with "css-loader" and with source maps: warnings 1`] = `Array []`;
12+
13+
exports[`loader should have same "contenthash" with "css-loader" and without source maps: errors 1`] = `Array []`;
14+
15+
exports[`loader should have same "contenthash" with "css-loader" and without source maps: module 1`] = `
16+
Array [
17+
"main.b38d5f87c88c55a4258e.bundle.js",
18+
]
19+
`;
20+
21+
exports[`loader should have same "contenthash" with "css-loader" and without source maps: warnings 1`] = `Array []`;
22+
23+
exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: errors 1`] = `Array []`;
24+
25+
exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: module 1`] = `
26+
Array [
27+
"main.d77dd6564bc6e6297cd4.bundle.js",
28+
]
29+
`;
30+
31+
exports[`loader should have same "contenthash" with "postcss-loader" and with source maps: warnings 1`] = `Array []`;
21232

213-
// Imports
214-
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(/*! ../../../src/runtime/api.js */ \\"../../src/runtime/api.js\\");
215-
exports = ___CSS_LOADER_API_IMPORT___(true);
216-
// Module
217-
exports.push([module.i, \\"a {\\\\n color: red;\\\\n}\\\\na:hover {\\\\n color: red;\\\\n}\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"./contenthash/basic.scss\\",\\"basic.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAHI;ACEN;ADGE;EACE,UANE;ACKN\\",\\"file\\":\\"basic.scss\\",\\"sourcesContent\\":[\\"$var: red;\\\\n\\\\na {\\\\n color: $var;\\\\n\\\\n &:hover {\\\\n color: $var;\\\\n }\\\\n}\\\\n\\",\\"a {\\\\n color: red;\\\\n}\\\\na:hover {\\\\n color: red;\\\\n}\\"]}]);
218-
// Exports
219-
module.exports = exports;
33+
exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: errors 1`] = `Array []`;
22034

35+
exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: module 1`] = `
36+
Array [
37+
"main.f8e62206a43c13393798.bundle.js",
38+
]
39+
`;
22140

222-
/***/ })
41+
exports[`loader should have same "contenthash" with "postcss-loader" and without source maps: warnings 1`] = `Array []`;
42+
43+
exports[`loader should have same "contenthash" with "sass-loader" and with source maps: errors 1`] = `Array []`;
22344

224-
/******/ });",
225-
}
45+
exports[`loader should have same "contenthash" with "sass-loader" and with source maps: module 1`] = `
46+
Array [
47+
"main.a12ab765493c74c80be2.bundle.js",
48+
]
22649
`;
22750

22851
exports[`loader should have same "contenthash" with "sass-loader" and with source maps: warnings 1`] = `Array []`;
52+
53+
exports[`loader should have same "contenthash" with "sass-loader" and without source maps: errors 1`] = `Array []`;
54+
55+
exports[`loader should have same "contenthash" with "sass-loader" and without source maps: module 1`] = `
56+
Array [
57+
"main.9ae036ace8bbbebbd185.bundle.js",
58+
]
59+
`;
60+
61+
exports[`loader should have same "contenthash" with "sass-loader" and without source maps: warnings 1`] = `Array []`;

test/loader.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
getExecutedCode,
1212
getModuleSource,
1313
getWarnings,
14-
readsAssets,
1514
} from './helpers/index';
1615

1716
describe('loader', () => {
@@ -310,7 +309,7 @@ describe('loader', () => {
310309
expect(getErrors(stats)).toMatchSnapshot('errors');
311310
});
312311

313-
it('should have same "contenthash" with "css-loader" and without source maps', async () => {
312+
it.only('should have same "contenthash" with "css-loader" and without source maps', async () => {
314313
const compiler = getCompiler(
315314
'./contenthash/basic-css.js',
316315
{},
@@ -343,7 +342,7 @@ describe('loader', () => {
343342
expect(getErrors(stats)).toMatchSnapshot('errors');
344343
});
345344

346-
it('should have same "contenthash" with "css-loader" and with source maps', async () => {
345+
it.only('should have same "contenthash" with "css-loader" and with source maps', async () => {
347346
const compiler = getCompiler(
348347
'./contenthash/basic-css.js',
349348
{},
@@ -376,7 +375,7 @@ describe('loader', () => {
376375
expect(getErrors(stats)).toMatchSnapshot('errors');
377376
});
378377

379-
it('should have same "contenthash" with "postcss-loader" and without source maps', async () => {
378+
it.only('should have same "contenthash" with "postcss-loader" and without source maps', async () => {
380379
const compiler = getCompiler(
381380
'./contenthash/basic-postcss.js',
382381
{},
@@ -419,7 +418,7 @@ describe('loader', () => {
419418
expect(getErrors(stats)).toMatchSnapshot('errors');
420419
});
421420

422-
it('should have same "contenthash" with "postcss-loader" and with source maps', async () => {
421+
it.only('should have same "contenthash" with "postcss-loader" and with source maps', async () => {
423422
const compiler = getCompiler(
424423
'./contenthash/basic-postcss.js',
425424
{},
@@ -462,7 +461,7 @@ describe('loader', () => {
462461
expect(getErrors(stats)).toMatchSnapshot('errors');
463462
});
464463

465-
it('should have same "contenthash" with "sass-loader" and without source maps', async () => {
464+
it.only('should have same "contenthash" with "sass-loader" and without source maps', async () => {
466465
const compiler = getCompiler(
467466
'./contenthash/basic-sass.js',
468467
{},
@@ -559,7 +558,7 @@ describe('loader', () => {
559558
);
560559
const stats = await compile(compiler);
561560

562-
expect(readsAssets(compiler, stats)).toMatchSnapshot('module');
561+
expect(Object.keys(stats.compilation.assets)).toMatchSnapshot('module');
563562
expect(getWarnings(stats)).toMatchSnapshot('warnings');
564563
expect(getErrors(stats)).toMatchSnapshot('errors');
565564
});

0 commit comments

Comments
 (0)