summaryrefslogtreecommitdiff
path: root/node_modules/postcss-unroot/test
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:58:02 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:58:02 +0800
commitfee47f6414cc3ae9a88f3ee0ed20f1d6f2d9f556 (patch)
tree2b99dd57fc676a3819ef3cc46ac43df0043c2bb3 /node_modules/postcss-unroot/test
parent0379526e20e1ff212df23e6326741aa9c06df204 (diff)
added plugin from postcss: postcss-fixes rucksack-css
Diffstat (limited to 'node_modules/postcss-unroot/test')
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.actual.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.copy.actual.css6
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.copy.expect.css6
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.expect.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.warn.actual.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/basic.warn.expect.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/class.actual.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/class.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/class.expect.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/svg.actual.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/svg.css3
-rw-r--r--node_modules/postcss-unroot/test/fixtures/svg.expect.css3
-rw-r--r--node_modules/postcss-unroot/test/index.js83
14 files changed, 128 insertions, 0 deletions
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.actual.css b/node_modules/postcss-unroot/test/fixtures/basic.actual.css
new file mode 100644
index 00000000..2c0cc73b
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.actual.css
@@ -0,0 +1,3 @@
+html {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.copy.actual.css b/node_modules/postcss-unroot/test/fixtures/basic.copy.actual.css
new file mode 100644
index 00000000..e062ae5d
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.copy.actual.css
@@ -0,0 +1,6 @@
+html {
+ color: red;
+}
+:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.copy.expect.css b/node_modules/postcss-unroot/test/fixtures/basic.copy.expect.css
new file mode 100644
index 00000000..e062ae5d
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.copy.expect.css
@@ -0,0 +1,6 @@
+html {
+ color: red;
+}
+:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.css b/node_modules/postcss-unroot/test/fixtures/basic.css
new file mode 100644
index 00000000..b5c5c477
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.css
@@ -0,0 +1,3 @@
+:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.expect.css b/node_modules/postcss-unroot/test/fixtures/basic.expect.css
new file mode 100644
index 00000000..2c0cc73b
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.expect.css
@@ -0,0 +1,3 @@
+html {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.warn.actual.css b/node_modules/postcss-unroot/test/fixtures/basic.warn.actual.css
new file mode 100644
index 00000000..b5c5c477
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.warn.actual.css
@@ -0,0 +1,3 @@
+:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/basic.warn.expect.css b/node_modules/postcss-unroot/test/fixtures/basic.warn.expect.css
new file mode 100644
index 00000000..b5c5c477
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/basic.warn.expect.css
@@ -0,0 +1,3 @@
+:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/class.actual.css b/node_modules/postcss-unroot/test/fixtures/class.actual.css
new file mode 100644
index 00000000..586a912b
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/class.actual.css
@@ -0,0 +1,3 @@
+html.foo {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/class.css b/node_modules/postcss-unroot/test/fixtures/class.css
new file mode 100644
index 00000000..5dfd4d4e
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/class.css
@@ -0,0 +1,3 @@
+:root.foo {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/class.expect.css b/node_modules/postcss-unroot/test/fixtures/class.expect.css
new file mode 100644
index 00000000..586a912b
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/class.expect.css
@@ -0,0 +1,3 @@
+html.foo {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/svg.actual.css b/node_modules/postcss-unroot/test/fixtures/svg.actual.css
new file mode 100644
index 00000000..7ad6e896
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/svg.actual.css
@@ -0,0 +1,3 @@
+svg {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/svg.css b/node_modules/postcss-unroot/test/fixtures/svg.css
new file mode 100644
index 00000000..9ac9f497
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/svg.css
@@ -0,0 +1,3 @@
+svg:root {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/fixtures/svg.expect.css b/node_modules/postcss-unroot/test/fixtures/svg.expect.css
new file mode 100644
index 00000000..7ad6e896
--- /dev/null
+++ b/node_modules/postcss-unroot/test/fixtures/svg.expect.css
@@ -0,0 +1,3 @@
+svg {
+ color: red;
+}
diff --git a/node_modules/postcss-unroot/test/index.js b/node_modules/postcss-unroot/test/index.js
new file mode 100644
index 00000000..a421357c
--- /dev/null
+++ b/node_modules/postcss-unroot/test/index.js
@@ -0,0 +1,83 @@
+var tests = {
+ 'postcss-unroot': {
+ 'basic': {
+ message: 'supports basic usage'
+ },
+ 'basic:copy': {
+ message: 'supports "copy" usage',
+ options: {
+ method: 'copy'
+ }
+ },
+ 'basic:warn': {
+ message: 'supports "warn" usage',
+ options: {
+ method: 'warn'
+ },
+ warning: 1
+ },
+ 'svg': {
+ message: 'supports usage with <svg>'
+ },
+ 'class': {
+ message: 'supports usage with class'
+ }
+ }
+};
+
+var debug = true;
+var dir = './test/fixtures/';
+
+var fs = require('fs');
+var path = require('path');
+var plugin = require('../');
+var test = require('tape');
+
+Object.keys(tests).forEach(function (name) {
+ var parts = tests[name];
+
+ test(name, function (t) {
+ var fixtures = Object.keys(parts);
+
+ t.plan(fixtures.length * 2);
+
+ fixtures.forEach(function (fixture) {
+ var message = parts[fixture].message;
+ var options = parts[fixture].options;
+ var warning = parts[fixture].warning || 0;
+ var warningMsg = message + ' (# of warnings)';
+
+ var baseName = fixture.split(':')[0];
+ var testName = fixture.split(':').join('.');
+
+ var inputPath = path.resolve(dir + baseName + '.css');
+ var expectPath = path.resolve(dir + testName + '.expect.css');
+ var actualPath = path.resolve(dir + testName + '.actual.css');
+
+ var inputCSS = '';
+ var expectCSS = '';
+
+ try {
+ inputCSS = fs.readFileSync(inputPath, 'utf8');
+ } catch (error) {
+ fs.writeFileSync(inputPath, inputCSS);
+ }
+
+ try {
+ expectCSS = fs.readFileSync(expectPath, 'utf8');
+ } catch (error) {
+ fs.writeFileSync(expectPath, expectCSS);
+ }
+
+ plugin.process(inputCSS, options).then(function (result) {
+ var actualCSS = result.css;
+
+ if (debug) fs.writeFileSync(actualPath, actualCSS);
+
+ t.equal(actualCSS, expectCSS, message);
+
+ t.equal(result.warnings().length, warning, warningMsg);
+ });
+ });
+ });
+});