test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import postcss from 'postcss';
  2. import { expect } from 'chai';
  3. import plugin from '..';
  4. const test = (input, output, opts, done) => {
  5. postcss([
  6. plugin(opts)
  7. ])
  8. .process(input, { from: '<inline>' })
  9. .then(result => {
  10. expect(result.css).to.eql(output);
  11. expect(result.warnings()).to.be.empty; // eslint-disable-line no-unused-expressions
  12. done();
  13. })
  14. .catch(done);
  15. };
  16. describe('postcss-attribute-case-insensitive', () => {
  17. it('simple', done => {
  18. test(
  19. '[data-foo=test i] { display: block; }',
  20. '[data-foo=test],[data-foo=Test],[data-foo=tEst],[data-foo=TEst],[data-foo=teSt],[data-foo=TeSt],[data-foo=tESt],[data-foo=TESt],[data-foo=tesT],[data-foo=TesT],[data-foo=tEsT],[data-foo=TEsT],[data-foo=teST],[data-foo=TeST],[data-foo=tEST],[data-foo=TEST] { display: block; }',
  21. {},
  22. done
  23. );
  24. });
  25. it('with spaces', done => {
  26. test(
  27. '[foo="a b" i]{}',
  28. '[foo="a b"],[foo="A b"],[foo="a B"],[foo="A B"]{}',
  29. {},
  30. done
  31. );
  32. });
  33. it('not insensitive', done => {
  34. test(
  35. '[foo=a]{}',
  36. '[foo=a]{}',
  37. {},
  38. done
  39. );
  40. });
  41. it('several attributes', done => {
  42. test(
  43. '[foo=a i],[foobar=b],[bar=c i]{}',
  44. '[foobar=b],[foo=a],[foo=A],[bar=c],[bar=C]{}',
  45. {},
  46. done
  47. );
  48. });
  49. });