<commit_before>import test from "tape"
import postcss from "postcss"
import plugin from "../src"

function transform(input, opts = {}, postcssOpts = {}) {
  return postcss()
    .use(plugin(opts))
    .process(input, postcssOpts)
}

test("@custom-selector", function(t) {
  t.equal(
    transform(
      ``
    ).css,
    ``,
    "should works with nothing"
  )

  const undefinedResult = transform(":--undef {}")
  t.ok(
    undefinedResult.messages && undefinedResult.messages.length === 1,
    "should add a message when a custom selectors is undefined"
  )

  t.equal(
    transform(
      `@custom-selector :--foo .bar, .baz;
.foo:--foo {
  margin-top: 16px;
}`,
      {transformMatches: false}
    ).css,
    `.foo:matches(.bar, .baz) {
  margin-top: 16px;
}`,
    "should works be able to limit transformation to :matches()"
  )

  t.equal(
    transform(
      `@custom-selector :--heading h1, h2, h3, h4, h5, h6;

article :--heading + p {}`
    ).css,
    `article h1 + p,
article h2 + p,
article h3 + p,
article h4 + p,
article h5 + p,
article h6 + p {}`,
    "should transform heading"
  )

  t.equal(
    transform(
      `@custom-selector :--foobar .foo, .bar;
@custom-selector :--baz .baz;
@custom-selector :--fizzbuzz .fizz, .buzz;
@custom-selector :--button-types
  .btn-primary,
  .btn-success,
  .btn-info,
  .btn-warning,
  .btn-danger;

:--foobar > :--baz {}

:--fizzbuzz > :--foobar {}

:--button-types, :--button-types:active {}`
    ).css,
    `.foo > .baz,
.bar > .baz {}

.fizz > .foo,
.buzz > .foo,
.fizz > .bar,
.buzz > .bar {}

.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger,
.btn-primary:active,
.btn-success:active,
.btn-info:active,
.btn-warning:active,
.btn-danger:active {}`,
    "should work with a complicated example"
  )

  t.equal(
    transform(
      `/* comment */
@custom-selector :--foo
  /* comment */
  .foo,
  .bar > .baz;


/* comment */
      :--foo + p {
    display: block;
  }`
    ).css,
    `/* comment */


/* comment */
      .foo + p,
      .bar > .baz + p {
    display: block;
  }`,
    "should works with comments"
  )

  t.equal(
    transform(
      `@custom-selector :--pseudo ::before, ::after;

.foo > a:--pseudo img {
  display: block;
}
`
    ).css,
    `.foo > a::before img,
.foo > a::after img {
  display: block;
}
`,
    "should works with pseudo elements"
  )

  t.equal(
    transform(
      `@custom-selector :--foo .foo;

:--foo, :--foo.bar {
  color: white;
}
`
    ).css,
    `.foo,
.foo.bar {
  color: white;
}
`,
    "should works handle multiples combined selectors"
  )

  t.equal(
    transform(
      `@custom-selector :--foo h1, h2, h3;
@custom-selector :--ba-----r h4, h5, h6;

.fo--oo > :--foo {
  margin: auto;
}

:--ba-----r:hover .ba--z {
  display: block;
}
`
    ).css,
    `.fo--oo > h1,
.fo--oo > h2,
.fo--oo > h3 {
  margin: auto;
}

h4:hover .ba--z,
h5:hover .ba--z,
h6:hover .ba--z {
  display: block;<commit_msg>Adding in test for multiple selectors with a pseudo class<commit_after>import test from "tape"
import postcss from "postcss"
import plugin from "../src"

function transform(input, opts = {}, postcssOpts = {}) {
  return postcss()
    .use(plugin(opts))
    .process(input, postcssOpts)
}

test("@custom-selector", function(t) {
  t.equal(
    transform(
      ``
    ).css,
    ``,
    "should works with nothing"
  )

  const undefinedResult = transform(":--undef {}")
  t.ok(
    undefinedResult.messages && undefinedResult.messages.length === 1,
    "should add a message when a custom selectors is undefined"
  )

  t.equal(
    transform(
      `@custom-selector :--foo .bar, .baz;
.foo:--foo {
  margin-top: 16px;
}`,
      {transformMatches: false}
    ).css,
    `.foo:matches(.bar, .baz) {
  margin-top: 16px;
}`,
    "should works be able to limit transformation to :matches()"
  )

  t.equal(
    transform(
      `@custom-selector :--heading h1, h2, h3, h4, h5, h6;

article :--heading + p {}`
    ).css,
    `article h1 + p,
article h2 + p,
article h3 + p,
article h4 + p,
article h5 + p,
article h6 + p {}`,
    "should transform heading"
  )

  t.equal(
    transform(
      `@custom-selector :--foobar .foo, .bar;
@custom-selector :--baz .baz;
@custom-selector :--fizzbuzz .fizz, .buzz;
@custom-selector :--button-types
  .btn-primary,
  .btn-success,
  .btn-info,
  .btn-warning,
  .btn-danger;

:--foobar > :--baz {}

:--fizzbuzz > :--foobar {}

:--button-types, :--button-types:active {}`
    ).css,
    `.foo > .baz,
.bar > .baz {}

.fizz > .foo,
.buzz > .foo,
.fizz > .bar,
.buzz > .bar {}

.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger,
.btn-primary:active,
.btn-success:active,
.btn-info:active,
.btn-warning:active,
.btn-danger:active {}`,
    "should work with a complicated example"
  )

  t.equal(
    transform(
      `/* comment */
@custom-selector :--foo
  /* comment */
  .foo,
  .bar > .baz;


/* comment */
      :--foo + p {
    display: block;
  }`
    ).css,
    `/* comment */


/* comment */
      .foo + p,
      .bar > .baz + p {
    display: block;
  }`,
    "should works with comments"
  )

  t.equal(
    transform(
      `@custom-selector :--pseudo ::before, ::after;

.foo > a:--pseudo img {
  display: block;
}
`
    ).css,
    `.foo > a::before img,
.foo > a::after img {
  display: block;
}
`,
    "should works with pseudo elements"
  )

  t.equal(
    transform(
      `@custom-selector :--foo .foo;

:--foo, :--foo.bar {
  color: white;
}
`
    ).css,
    `.foo,
.foo.bar {
  color: white;
}
`,
    "should works handle multiples combined selectors"
  )

  t.equal(
    transform(
      `@custom-selector :--foo .foo;

:--foo :--foo:hover {
  color: white;
}
`
    ).css,
    `.foo .foo:hover {
  color: white;
}
`,
    "should works handle multiples combined selectors with pseudo classes"
  )

  t.equal(
    transform(
      `@custom-selector :--foo h1, h2, h3;
@custom-selector :--ba-----r h4, h5, h6;

.fo--oo > :--foo {
  margin: auto;
}

:--ba-----r:hover .ba--z {
  display: block;
}
`
    ).css,
    `.fo--oo > h1,
.fo--oo > h2,
.fo--oo > h3 {
  margin: auto;
}

h4:hover .ba--z,
h5:hover .ba--z,
h6:hover .ba--z {
  display: block;
{'fraction_non_alphanumeric': 0.19302818048542109, 'fraction_numerical': 0.009447792800130314, 'mean_word_length': 2.283422459893048, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2041515', 'n_tokens_mistral': 2444, 'n_tokens_neox': 2354, 'n_words': 575}