import config from "../"
import postcss from "postcss"
import stylelint from "stylelint"
import test from "tape"

test("basic properties of config", t => {
  t.ok(isObject(config.rules), "rules is object")
  t.end()
})

function isObject(obj) {
  return typeof obj === "object" && obj !== null
}

const css = (
`a {
\ttop: .2em;
}

`)

postcss()
  .use(stylelint(config))
  .process(css)
  .then(checkResult)
  .catch(e => console.log(e.stack))

function checkResult(result) {
  const { messages } = result
  test("expected warnings", t => {
    t.equal(messages.length, 1, "flags one warning")
    t.ok(messages.every(m => m.type === "warning"), "message of type warning")
    t.ok(messages.every(m => m.plugin === "stylelint"), "message of plugin stylelint")
    t.equal(messages[0].text, "Expected a leading zero (number-leading-zero)", "correct warning text")
    t.end()
  })
}

@@ -22,38 +22,8 @@
 ./%22%0A
-import postcss from %22postcss%22%0A
 impo
@@ -303,62 +303,59 @@
 %60)%0A%0A
-postcss()%0A  .use(stylelint(config))%0A  .process(css)
+stylelint.lint(%7B%0A  code: css,
 %0A  
+config: config,%0A%7D)%0A
 .the
@@ -373,42 +373,60 @@
 lt)%0A
-  
 .catch(
-e =%3E console.log(e
+function (err) %7B%0A  console.error(err
 .stack)
+%0A%7D
 )%0A%0Af
@@ -449,17 +449,51 @@
 ult(
-result) %7B
+data) %7B%0A  const %7B errored, results %7D = data
 %0A  c
@@ -499,23 +499,23 @@
 const %7B 
-message
+warning
 s %7D = re
@@ -518,16 +518,20 @@
 = result
+s%5B0%5D
 %0A  test(
@@ -568,218 +568,81 @@
   t.
-equal(messages.length, 1, %22flags one warning%22)%0A    t.ok(messages.every(m =%3E m.type === %22warning%22), %22message of type warning%22)%0A    t.ok(messages.every(m =%3E m.plugin === %22stylelint%22), %22message of plugin stylelint
+ok(errored, %22errored%22)%0A    t.equal(warnings.length, 1, %22flags one warning
 %22)%0A 
@@ -656,15 +656,15 @@
 ual(
-message
+warning
 s%5B0%5D

Use stylelint standalone API in test