import fs from "fs";
import postcss from "postcss";
import chai, {expect} from "chai";
import chaiAsPromised from "chai-as-promised";

import ornithopter, {createComposedProperty} from "postcss-ornithopter";

chai.use(chaiAsPromised);

const processor = postcss([ornithopter]);

describe("postcss-ornithopter", function () {
  describe("scratchpad", function () {
    ["linear-color"].forEach(refname => {
      it(`should transpile ${refname}`, function (done) {
        const from = `tests/reference/postcss/${refname}.postcss.css`;
        const to = `tests/reference/postcss/${refname}.css`;

        const input = fs.readFileSync(from, "utf-8");
        const output = fs.readFileSync(to, "utf-8");

        expect(processor.process(input, {from, to})
                        .then(result => result.css)).to.eventually
                                                    .eq(output)
                                                    .notify(done);
      });
    });
  });

  it("should create the composed property data structure", function () {
    expect(createComposedProperty({prop: 'color',
                                   value: 'red green'})).to.deep
                                                        .equal(['color',
                                                                ['red', 'green']]);
  });
});

@@ -149,22 +149,18 @@
 opter, %7B
-create
+to
 Composed
@@ -1053,22 +1053,18 @@
  expect(
-create
+to
 Composed
@@ -1080,36 +1080,32 @@
 %7Bprop: 'color',%0A
-    
                 
@@ -1201,20 +1201,16 @@
         
-    
 .equal(%5B
@@ -1210,36 +1210,32 @@
 equal(%5B'color',%0A
-    
                 

Fix toComposedProperty test