From 6898bd1bfcb843b85fe8064c09325628a7175388 Mon Sep 17 00:00:00 2001 From: Alexander Madyankin Date: Sat, 20 May 2017 14:18:09 +0300 Subject: [PATCH] Update postcss --- package.json | 9 +- test/__snapshots__/test.js.snap | 165 ++++++++++++++++++ test/cases/multiline-expressions.expected.css | 6 - test/cases/multiple-assignment.expected.css | 12 -- test/cases/multiple-properties.expected.css | 8 - test/cases/multiple-selectors.expected.css | 6 - test/cases/multiple-values.expected.css | 6 - .../nested-iteration-parent-vars.expected.css | 8 - test/cases/nested-iteration.expected.css | 34 ---- test/cases/one-value.expected.css | 3 - test/cases/other-variables.expected.css | 6 - test/cases/short-names.expected.css | 3 - test/cases/value-with-index.expected.css | 6 - test/cases/with-in-substring.expected.css | 6 - test/test.js | 9 +- 15 files changed, 172 insertions(+), 115 deletions(-) create mode 100644 test/__snapshots__/test.js.snap delete mode 100644 test/cases/multiline-expressions.expected.css delete mode 100644 test/cases/multiple-assignment.expected.css delete mode 100644 test/cases/multiple-properties.expected.css delete mode 100644 test/cases/multiple-selectors.expected.css delete mode 100644 test/cases/multiple-values.expected.css delete mode 100644 test/cases/nested-iteration-parent-vars.expected.css delete mode 100644 test/cases/nested-iteration.expected.css delete mode 100644 test/cases/one-value.expected.css delete mode 100644 test/cases/other-variables.expected.css delete mode 100644 test/cases/short-names.expected.css delete mode 100644 test/cases/value-with-index.expected.css delete mode 100644 test/cases/with-in-substring.expected.css diff --git a/package.json b/package.json index 4151a2b..84d4891 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "url": "https://github.com/outpunk/postcss-each.git" }, "dependencies": { - "postcss": "^5.0.21", - "postcss-simple-vars": "^2.0.0" + "postcss": "^6.0.1", + "postcss-simple-vars": "^4.0.0" }, "devDependencies": { "babel": "^6.5.2", @@ -26,12 +26,11 @@ "babel-core": "^6.9.1", "babel-plugin-add-module-exports": "^0.2.1", "babel-preset-es2015": "^6.9.0", - "jscs": "^3.0.3", - "mocha": "^2.5.3" + "jscs": "^3.0.3" }, "scripts": { "pretest": "jscs index.js test", - "test": "mocha --compilers js:babel-core/register", + "test": "jest", "transpile": "babel index.js > index.es5.js", "prepublish": "npm run transpile", "postpublish": "rm *.es5.js && git push --follow-tags" diff --git a/test/__snapshots__/test.js.snap b/test/__snapshots__/test.js.snap new file mode 100644 index 0000000..41ed2ef --- /dev/null +++ b/test/__snapshots__/test.js.snap @@ -0,0 +1,165 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`postcss-each doesn't replace other variables 1`] = ` +" + .icon-foo, .foo { + background: url(\\"$(bg).png\\"); + } +.icon-bar, .bar { + background: url(\\"$(bg).png\\"); + } +" +`; + +exports[`postcss-each iterates and assigns multiple values 1`] = ` +" + .icon-a-x-0 { + background: url(\\"a.png\\"); + color: x; + } +.icon-b-y-1 { + background: url(\\"b.png\\"); + color: y; + } +.icon-c-z-2 { + background: url(\\"c.png\\"); + color: z; + } +" +`; + +exports[`postcss-each iterates short names 1`] = ` +" + .icon-foo { + background: url(\\"foo.png\\"); + } +" +`; + +exports[`postcss-each iterates through given values 1`] = ` +" + .icon-foo { + background: url(\\"foo.png\\"); + } +.icon-bar { + background: url(\\"bar.png\\"); + } +" +`; + +exports[`postcss-each iterates through one value 1`] = ` +" + .icon-foo { + background: url(\\"foo.png\\"); + } +" +`; + +exports[`postcss-each iterates value and index 1`] = ` +" + .icon-foo { + background: url(\\"foo_0.png\\"); + } +.icon-bar { + background: url(\\"bar_1.png\\"); + } +" +`; + +exports[`postcss-each performs nested iteration 1`] = ` +" + .icon-foo { + border: abc; + border: xyz + } +.icon-bar { + border: abc; + border: xyz + } +.a { + hello: a; + } +.a-x { + color: purple; + blah: u; + blah: v + } +.a-y { + color: purple; + blah: u; + blah: v + } +.b { + hello: b; + } +.b-x { + color: purple; + blah: u; + blah: v + } +.b-y { + color: purple; + blah: u; + blah: v + } +" +`; + +exports[`postcss-each performs nested iteration with parent's variables 1`] = ` +" + .icon-foo { + border: foo-abc; + border: xyz + } +.icon-bar { + border: bar-abc; + border: xyz + } +" +`; + +exports[`postcss-each respects multiline expressions 1`] = ` +" + .foo { + background: url(\\"foo.png\\") + } +.bar { + background: url(\\"bar.png\\") + } +" +`; + +exports[`postcss-each respects multiple properties 1`] = ` +" + .icon-foo { + background: url(\\"foo.png\\"); + content: \\"foo\\"; + } +.icon-bar { + background: url(\\"bar.png\\"); + content: \\"bar\\"; + } +" +`; + +exports[`postcss-each respects multiple selectors 1`] = ` +" + .icon-foo, .foo { + background: url(\\"foo.png\\"); + } +.icon-bar, .bar { + background: url(\\"bar.png\\"); + } +" +`; + +exports[`postcss-each respects properties with \`in\` substring 1`] = ` +" + .print { + background: url(\\"print.png\\"); + } +.bar { + background: url(\\"bar.png\\"); + } +" +`; diff --git a/test/cases/multiline-expressions.expected.css b/test/cases/multiline-expressions.expected.css deleted file mode 100644 index 86e20be..0000000 --- a/test/cases/multiline-expressions.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.foo { - background: url("foo.png") -} -.bar { - background: url("bar.png") -} diff --git a/test/cases/multiple-assignment.expected.css b/test/cases/multiple-assignment.expected.css deleted file mode 100644 index f2fe5e0..0000000 --- a/test/cases/multiple-assignment.expected.css +++ /dev/null @@ -1,12 +0,0 @@ -.icon-a-x-0 { - background: url("a.png"); - color: x -} -.icon-b-y-1 { - background: url("b.png"); - color: y -} -.icon-c-z-2 { - background: url("c.png"); - color: z -} diff --git a/test/cases/multiple-properties.expected.css b/test/cases/multiple-properties.expected.css deleted file mode 100644 index 7a65827..0000000 --- a/test/cases/multiple-properties.expected.css +++ /dev/null @@ -1,8 +0,0 @@ -.icon-foo { - background: url("foo.png"); - content: "foo" -} -.icon-bar { - background: url("bar.png"); - content: "bar" -} diff --git a/test/cases/multiple-selectors.expected.css b/test/cases/multiple-selectors.expected.css deleted file mode 100644 index 7ecac77..0000000 --- a/test/cases/multiple-selectors.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.icon-foo, .foo { - background: url("foo.png") -} -.icon-bar, .bar { - background: url("bar.png") -} diff --git a/test/cases/multiple-values.expected.css b/test/cases/multiple-values.expected.css deleted file mode 100644 index a85d927..0000000 --- a/test/cases/multiple-values.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.icon-foo { - background: url("foo.png") -} -.icon-bar { - background: url("bar.png") -} diff --git a/test/cases/nested-iteration-parent-vars.expected.css b/test/cases/nested-iteration-parent-vars.expected.css deleted file mode 100644 index d20a35d..0000000 --- a/test/cases/nested-iteration-parent-vars.expected.css +++ /dev/null @@ -1,8 +0,0 @@ -.icon-foo { - border: foo-abc; - border: xyz -} -.icon-bar { - border: bar-abc; - border: xyz -} diff --git a/test/cases/nested-iteration.expected.css b/test/cases/nested-iteration.expected.css deleted file mode 100644 index 22859d0..0000000 --- a/test/cases/nested-iteration.expected.css +++ /dev/null @@ -1,34 +0,0 @@ -.icon-foo { - border: abc; - border: xyz -} -.icon-bar { - border: abc; - border: xyz -} -.a { - hello: a -} -.a-x { - color: purple; - blah: u; - blah: v -} -.a-y { - color: purple; - blah: u; - blah: v -} -.b { - hello: b -} -.b-x { - color: purple; - blah: u; - blah: v -} -.b-y { - color: purple; - blah: u; - blah: v -} diff --git a/test/cases/one-value.expected.css b/test/cases/one-value.expected.css deleted file mode 100644 index f3b14d4..0000000 --- a/test/cases/one-value.expected.css +++ /dev/null @@ -1,3 +0,0 @@ -.icon-foo { - background: url("foo.png") -} diff --git a/test/cases/other-variables.expected.css b/test/cases/other-variables.expected.css deleted file mode 100644 index 801decd..0000000 --- a/test/cases/other-variables.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.icon-foo, .foo { - background: url("$(bg).png") -} -.icon-bar, .bar { - background: url("$(bg).png") -} diff --git a/test/cases/short-names.expected.css b/test/cases/short-names.expected.css deleted file mode 100644 index f3b14d4..0000000 --- a/test/cases/short-names.expected.css +++ /dev/null @@ -1,3 +0,0 @@ -.icon-foo { - background: url("foo.png") -} diff --git a/test/cases/value-with-index.expected.css b/test/cases/value-with-index.expected.css deleted file mode 100644 index 3e18a89..0000000 --- a/test/cases/value-with-index.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.icon-foo { - background: url("foo_0.png") -} -.icon-bar { - background: url("bar_1.png") -} diff --git a/test/cases/with-in-substring.expected.css b/test/cases/with-in-substring.expected.css deleted file mode 100644 index 5860572..0000000 --- a/test/cases/with-in-substring.expected.css +++ /dev/null @@ -1,6 +0,0 @@ -.print { - background: url("print.png") -} -.bar { - background: url("bar.png") -} diff --git a/test/test.js b/test/test.js index 3a4eb22..9c6921a 100644 --- a/test/test.js +++ b/test/test.js @@ -21,9 +21,9 @@ const cases = { 'nested-iteration-parent-vars': 'performs nested iteration with parent\'s variables', }; -function test(input, expected, opts, done) { +function test(input, opts, done) { const result = postcss([plugin(opts)]).process(input); - assert.equal(result.css, expected); + expect(result.css).toMatchSnapshot(); }; function css(name) { @@ -44,9 +44,6 @@ describe('postcss-each', () => { for (let caseName in cases) { const description = cases[caseName]; - - it(description, () => { - test(css(caseName), css(caseName + '.expected')); - }); + it(description, () => test(css(caseName))); } });