index.js 896 B

1234567891011121314151617181920212223242526272829303132
  1. import test from 'ava'
  2. import stylelint from 'stylelint'
  3. import { correctOrder, incorrectOrder } from './_fixtures'
  4. import config from '..'
  5. const runStylelint = async (code) => {
  6. let data = await stylelint.lint({
  7. code,
  8. config,
  9. })
  10. return data.results[0]
  11. }
  12. test('with incorrect property order', async (t) => {
  13. await runStylelint(incorrectOrder).then((output) => {
  14. t.truthy(output.errored, 'indicates linting errors')
  15. t.is(
  16. output.warnings[0].text.trim(),
  17. 'Expected "box-sizing" to come before "background-color" (order/properties-order)',
  18. 'indicates a properties-order error',
  19. )
  20. })
  21. })
  22. test('with correct property order', async (t) => {
  23. await runStylelint(correctOrder).then((output) => {
  24. t.falsy(output.errored, 'indicates no errors')
  25. t.is(output.warnings.length, 0)
  26. })
  27. })