mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
add more plugin tests
This commit is contained in:
30
Gruntfile.js
30
Gruntfile.js
@@ -252,20 +252,44 @@ module.exports = function (grunt) {
|
||||
outfile: 'tmp/browser/test-runner-post-processor.html'
|
||||
}
|
||||
},
|
||||
postProcessorPLugin: {
|
||||
postProcessorPlugin: {
|
||||
src: ['test/browser/less/postProcessorPlugin/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-postProcessorPlugin-options.js',
|
||||
specs: 'test/browser/runner-postProcessorPlugin.js',
|
||||
outfile: 'tmp/browser/test-runner-post-processor-plugin.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
preProcessorPlugin: {
|
||||
src: ['test/browser/less/preProcessorPlugin/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-preProcessorPlugin-options.js',
|
||||
specs: 'test/browser/runner-preProcessorPlugin.js',
|
||||
outfile: 'tmp/browser/test-runner-pre-processor-plugin.html'
|
||||
}
|
||||
},
|
||||
visitorPlugin: {
|
||||
src: ['test/browser/less/visitorPlugin/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-VisitorPlugin-options.js',
|
||||
specs: 'test/browser/runner-VisitorPlugin.js',
|
||||
outfile: 'tmp/browser/test-runner-visitor-plugin.html'
|
||||
}
|
||||
},
|
||||
filemanagerPlugin: {
|
||||
src: ['test/browser/less/filemanagerPlugin/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-filemanagerPlugin-options.js',
|
||||
specs: 'test/browser/runner-filemanagerPlugin.js',
|
||||
outfile: 'tmp/browser/test-runner-filemanager-plugin.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'saucelabs-jasmine': {
|
||||
all: {
|
||||
options: {
|
||||
urls: ["post-processor-plugin","post-processor", "global-vars", "modify-vars", "production", "rootpath-relative",
|
||||
urls: ["filemanager-plugin","visitor-plugin","pre-processor-plugin","post-processor-plugin","post-processor", "global-vars", "modify-vars", "production", "rootpath-relative",
|
||||
"rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
|
||||
].map(function(testName) {
|
||||
return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
|
||||
|
||||
7
dist/less.js
vendored
7
dist/less.js
vendored
@@ -446,8 +446,11 @@ module.exports = function(options, logger) {
|
||||
};
|
||||
|
||||
FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) {
|
||||
|
||||
console.log('loading...' + currentDirectory + filename);
|
||||
|
||||
if (currentDirectory && !this.isPathAbsolute(filename)) {
|
||||
filename = currentDirectory + filename;
|
||||
filename = ;
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
@@ -9846,4 +9849,4 @@ if (typeof Promise === 'undefined') {
|
||||
require('./polyfill-done.js');
|
||||
|
||||
},{"./lib/core.js":89,"./lib/es6-extensions.js":90,"./polyfill-done.js":92,"asap":91}]},{},[2])(2)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = function(window, options) {
|
||||
|
||||
var typePattern = /^text\/(x-)?less$/;
|
||||
|
||||
function postProcessCSS(styles) {
|
||||
function postProcessCSS(styles) { // deprecated, use a plugin for postprocesstasks
|
||||
if (options.postProcessor && typeof options.postProcessor === 'function') {
|
||||
styles = options.postProcessor.call(styles, styles) || styles;
|
||||
}
|
||||
|
||||
3
test/browser/css/filemanagerPlugin/filemanager.css
Normal file
3
test/browser/css/filemanagerPlugin/filemanager.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.test {
|
||||
color: red;
|
||||
}
|
||||
3
test/browser/css/preProcessorPlugin/preProcessor.css
Normal file
3
test/browser/css/preProcessorPlugin/preProcessor.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.test {
|
||||
color: red;
|
||||
}
|
||||
3
test/browser/css/visitorPlugin/visitor.css
Normal file
3
test/browser/css/visitorPlugin/visitor.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.test {
|
||||
color: red;
|
||||
}
|
||||
1
test/browser/less/filemanagerPlugin/colors.test
Normal file
1
test/browser/less/filemanagerPlugin/colors.test
Normal file
@@ -0,0 +1 @@
|
||||
//@color: red;
|
||||
4
test/browser/less/filemanagerPlugin/filemanager.less
Normal file
4
test/browser/less/filemanagerPlugin/filemanager.less
Normal file
@@ -0,0 +1,4 @@
|
||||
@import "test.test";
|
||||
.test {
|
||||
color: red;
|
||||
}
|
||||
3
test/browser/less/preProcessorPlugin/preProcessor.less
Normal file
3
test/browser/less/preProcessorPlugin/preProcessor.less
Normal file
@@ -0,0 +1,3 @@
|
||||
.test {
|
||||
color: @color;
|
||||
}
|
||||
4
test/browser/less/visitorPlugin/visitor.less
Normal file
4
test/browser/less/visitorPlugin/visitor.less
Normal file
@@ -0,0 +1,4 @@
|
||||
.test {
|
||||
color: red;
|
||||
-some-aribitrary-property: value;
|
||||
}
|
||||
29
test/browser/runner-VisitorPlugin-options.js
Normal file
29
test/browser/runner-VisitorPlugin-options.js
Normal file
@@ -0,0 +1,29 @@
|
||||
RemoveProperty = function(less) {
|
||||
this._visitor = new less.visitors.Visitor(this);
|
||||
};
|
||||
|
||||
RemoveProperty.prototype = {
|
||||
isReplacing: true,
|
||||
run: function (root) {
|
||||
return this._visitor.visit(root);
|
||||
},
|
||||
visitRule: function (ruleNode, visitArgs) {
|
||||
if (ruleNode.name != '-some-aribitrary-property')
|
||||
{
|
||||
return ruleNode;
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var VisitorPlugin = {
|
||||
install: function(less, pluginManager) {
|
||||
pluginManager.addVisitor( new RemoveProperty(less));
|
||||
}
|
||||
};
|
||||
|
||||
var less = {logLevel: 4,
|
||||
errorReporting: "console",
|
||||
plugins: [VisitorPlugin]};
|
||||
3
test/browser/runner-VisitorPlugin.js
Normal file
3
test/browser/runner-VisitorPlugin.js
Normal file
@@ -0,0 +1,3 @@
|
||||
describe("less.js Visitor Plugin", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
29
test/browser/runner-filemanagerPlugin-options.js
Normal file
29
test/browser/runner-filemanagerPlugin-options.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var plugin = function(less) {
|
||||
|
||||
var FileManager = less.FileManager;
|
||||
|
||||
function TestFileManager() {
|
||||
};
|
||||
|
||||
TestFileManager = new FileManager();
|
||||
|
||||
TestFileManager.loadFile = function (filename, currentDirectory, options, environment, callback) {
|
||||
if (filename.match(/.*\.test$/)) {
|
||||
return less.environment.fileManagers[0].loadFile("colors.test", currentDirectory, options, environment, callback);
|
||||
}
|
||||
return less.environment.fileManagers[0].loadFile(filename, currentDirectory, options, environment, callback);
|
||||
};
|
||||
|
||||
return TestFileManager;
|
||||
};
|
||||
|
||||
var AddFilePlugin = {
|
||||
install: function(less, pluginManager) {
|
||||
less.environment.addFileManager(new plugin(less));
|
||||
}
|
||||
};
|
||||
|
||||
var less = {logLevel: 4,
|
||||
errorReporting: "console",
|
||||
plugins: [AddFilePlugin]
|
||||
};
|
||||
3
test/browser/runner-filemanagerPlugin.js
Normal file
3
test/browser/runner-filemanagerPlugin.js
Normal file
@@ -0,0 +1,3 @@
|
||||
describe("less.js filemanager Plugin", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
@@ -1,3 +1,3 @@
|
||||
describe("less.js postProcessor", function() {
|
||||
describe("less.js postProcessor (deprecated)", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
|
||||
22
test/browser/runner-preProcessorPlugin-options.js
Normal file
22
test/browser/runner-preProcessorPlugin-options.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var preProcessor = function() {};
|
||||
|
||||
preProcessor.prototype = {
|
||||
process : function (src, extra) {
|
||||
var injected = '@color: red;\n';
|
||||
var ignored = extra.imports.contentsIgnoredChars;
|
||||
var fileInfo = extra.fileInfo;
|
||||
ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;
|
||||
ignored[fileInfo.filename] += injected.length;
|
||||
return injected + src;
|
||||
}
|
||||
};
|
||||
|
||||
var preProcessorPlugin = {
|
||||
install: function(less, pluginManager) {
|
||||
pluginManager.addPreProcessor( new preProcessor());
|
||||
}
|
||||
};
|
||||
|
||||
var less = {logLevel: 4,
|
||||
errorReporting: "console",
|
||||
plugins: [preProcessorPlugin]};
|
||||
3
test/browser/runner-preProcessorPlugin.js
Normal file
3
test/browser/runner-preProcessorPlugin.js
Normal file
@@ -0,0 +1,3 @@
|
||||
describe("less.js preProcessor Plugin", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
Reference in New Issue
Block a user