Skip to content

classd tag doesn't act as promised in README #1

@mattvalleycodes

Description

@mattvalleycodes

The below code is copy/pasted from README:

const classes = classd`container padding-${{
    lg: width > 1280, 
    md: width > 960 && width < 1280,
    sm: width <= 960
}} margin-0 ${width > 960 && 'blue'} ${width < 960 && 'red'}`;
console.log(classes); // => 'container padding-md margin-0 blue'

padding-md is generated as the result of padding-${{md: width > 960 && width < 1280 }}. In reality, I get padding md!

Node.js example

> const classd = require("classd").default;
undefined
> classd`foo-${{bar: true}}`;
'foo- bar' 
>

Unit test

and below test should technically speaking pass but it fails.

    it.only ('should use the provided prefix', function () {
        return assert.equal(
            classd`button--${{ blue: true }}`,
            'button--blue'
        );
    });

with the below error:

    1) should use the provided prefix


  0 passing (6ms)
  1 failing

  1) classd
       should use the provided prefix:

      AssertionError [ERR_ASSERTION]: 'button-- blue' == 'button--blue'
      + expected - actual

      -button-- blue
      +button--blue

      at Context.<anonymous> (tests/classd.js:95:23)
      at processImmediate (internal/timers.js:456:21)



npm ERR! Test failed.  See above for more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions