diff options
Diffstat (limited to 'node_modules/postcss-unmq/test')
6 files changed, 161 insertions, 0 deletions
diff --git a/node_modules/postcss-unmq/test/fixtures/basic.actual.css b/node_modules/postcss-unmq/test/fixtures/basic.actual.css new file mode 100644 index 00000000..5db6ce73 --- /dev/null +++ b/node_modules/postcss-unmq/test/fixtures/basic.actual.css @@ -0,0 +1,14 @@ +a { + + min-width: 30em +} + +a { + + min-width: 60em +} + +a { + + line-height: 2 +} diff --git a/node_modules/postcss-unmq/test/fixtures/basic.css b/node_modules/postcss-unmq/test/fixtures/basic.css new file mode 100644 index 00000000..178e89a7 --- /dev/null +++ b/node_modules/postcss-unmq/test/fixtures/basic.css @@ -0,0 +1,35 @@ +@media screen and (min-width: 30em) { + a { + min-width: 30em; + } +} + +@media screen and (min-width: 60em) { + a { + min-width: 60em; + } +} + +@media screen and (max-width: 30em) { + a { + max-width: 30em; + } +} + +@media screen and (max-width: 60em) { + a { + max-width: 60em; + } +} + +@media screen and (min-aspect-ratio: 1) { + a { + line-height: 2; + } +} + +@media screen and (max-aspect-ratio: 1) { + a { + line-height: .5; + } +} diff --git a/node_modules/postcss-unmq/test/fixtures/basic.expect.css b/node_modules/postcss-unmq/test/fixtures/basic.expect.css new file mode 100644 index 00000000..5db6ce73 --- /dev/null +++ b/node_modules/postcss-unmq/test/fixtures/basic.expect.css @@ -0,0 +1,14 @@ +a { + + min-width: 30em +} + +a { + + min-width: 60em +} + +a { + + line-height: 2 +} diff --git a/node_modules/postcss-unmq/test/fixtures/basic.width.actual.css b/node_modules/postcss-unmq/test/fixtures/basic.width.actual.css new file mode 100644 index 00000000..5f7eab91 --- /dev/null +++ b/node_modules/postcss-unmq/test/fixtures/basic.width.actual.css @@ -0,0 +1,14 @@ +a { + + max-width: 30em +} + +a { + + max-width: 60em +} + +a { + + line-height: .5 +} diff --git a/node_modules/postcss-unmq/test/fixtures/basic.width.expect.css b/node_modules/postcss-unmq/test/fixtures/basic.width.expect.css new file mode 100644 index 00000000..5f7eab91 --- /dev/null +++ b/node_modules/postcss-unmq/test/fixtures/basic.width.expect.css @@ -0,0 +1,14 @@ +a { + + max-width: 30em +} + +a { + + max-width: 60em +} + +a { + + line-height: .5 +} diff --git a/node_modules/postcss-unmq/test/index.js b/node_modules/postcss-unmq/test/index.js new file mode 100644 index 00000000..51c2a125 --- /dev/null +++ b/node_modules/postcss-unmq/test/index.js @@ -0,0 +1,70 @@ +var tests = { + 'postcss-unmq': { + 'basic': { + message: 'supports basic usage' + }, + 'basic:width': { + message: 'supports "width: 320" option', + options: { + width: 320 + } + } + } +}; + +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); + }); + }); + }); +}); |
