Skip to content

Commit

Permalink
Add tests for Sass loader
Browse files Browse the repository at this point in the history
  • Loading branch information
尹曰 committed Sep 23, 2015
1 parent 6d76f7a commit 0e518d3
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/build-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ describe('lib/build.js', function() {
assert(dest, 'require-less-extract');
});

it('require sass extract', function*() {
yield build({
debug: true,
cwd: join(fixtures, 'require-sass'),
dest: dest,
extractCSS: true
});
assert(dest, 'require-sass-extract');
});

it('jsx', function*() {
yield build({
debug: true,
Expand Down Expand Up @@ -396,6 +406,30 @@ describe('lib/build.js', function() {

});

describe('custom-loader-sass', function() {

var oldCwd;

before(function() {
oldCwd = process.cwd();
process.chdir(join(fixtures, 'custom-loader-sass'));
});

after(function() {
process.chdir(oldCwd);
});

it('custom-loader-sass', function*() {
yield build({
debug: true,
cwd: join(fixtures, 'custom-loader-sass'),
dest: dest
});
assert(dest, 'custom-loader-sass');
});

});

describe('scripts', function() {

afterEach(function() {
Expand Down
5 changes: 5 additions & 0 deletions test/expected/custom-loader-sass/a.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions test/expected/custom-loader-sass/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/******/ (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] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ // Flag the module as loaded
/******/ module.loaded = 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;

/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";

/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(2);


/***/ },
/* 1 */
/***/ function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

__webpack_require__(1);
console.log(1);



/***/ }
/******/ ]);
10 changes: 10 additions & 0 deletions test/expected/require-sass-extract/a.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions test/expected/require-sass-extract/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/******/ (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] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ // Flag the module as loaded
/******/ module.loaded = 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;

/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";

/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(2);


/***/ },
/* 1 */
/***/ function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {


__webpack_require__(1);
console.log(1);


/***/ }
/******/ ]);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions test/fixtures/custom-loader-sass/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('./a.scss');
console.log(1);

6 changes: 6 additions & 0 deletions test/fixtures/custom-loader-sass/a.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

¥color: #121212;

a {
color: ¥color;
}
7 changes: 7 additions & 0 deletions test/fixtures/custom-loader-sass/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = function(source) {
this.cacheable && this.cacheable();
return source
.replace(//g, '$');
};
11 changes: 11 additions & 0 deletions test/fixtures/custom-loader-sass/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"spm": {
"output": ["a.js"],
"build": {
"loader": {
".scss": "+./foo$"
},
"extractCSS": true
}
}
}
3 changes: 3 additions & 0 deletions test/fixtures/require-sass/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

require('./a.scss');
console.log(1);
8 changes: 8 additions & 0 deletions test/fixtures/require-sass/a.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

@import '~b';

$color: #121212;

a {
color: $color;
}
8 changes: 8 additions & 0 deletions test/fixtures/require-sass/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"spm": {
"output": [
"a.js"
],
"extractCSS": true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/fixtures/require-sass/spm_modules/b/0.1.0/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
b {
color: red;
background: url(b.png);
}
7 changes: 7 additions & 0 deletions test/fixtures/require-sass/spm_modules/b/0.1.0/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "b",
"version": "0.1.0",
"spm": {
"main": "index.css"
}
}

0 comments on commit 0e518d3

Please sign in to comment.