Skip to content

Commit

Permalink
test: add nesting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 23, 2018
1 parent 03d039f commit 440b4f3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ __Motto of `nano-css` is simple__: *create the smallest possible CSS-in-JS libra
- __`@media` queries__ and __animation `@keyframes`__ are supported
- __Auto-prefixes__ your styles
- Can __extract CSS__ into external style sheet
- __100% test coverage__ for [recommended setup](./docs/Installation.md#recommended-setup)
- __Public domain__ — [Unlicense license](./LICENSE)


## Reference
Expand Down Expand Up @@ -56,20 +58,6 @@ __Motto of `nano-css` is simple__: *create the smallest possible CSS-in-JS libra
- [Server-side rendering](./docs/SSR.md)


## Installation

<pre>
npm i <a href="https://www.npmjs.com/package/nano-css">nano-css</a> --save
</pre>

Read more about [*Installation*](./docs/Installation.md).


## License

[Unlicense](./LICENSE) &mdash; public domain.


[npm-url]: https://www.npmjs.com/package/nano-css
[npm-badge]: https://img.shields.io/npm/v/nano-css.svg
[travis-url]: https://travis-ci.org/streamich/nano-css
Expand Down
47 changes: 47 additions & 0 deletions addon/__tests__/nesting.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable */
'use strict';

var env = require('./env');
var create = require('../../index').create;
var addonNesting = require('../../addon/nesting').addon;

function createNano (config) {
var nano = create(config);

addonNesting(nano);

return nano;
};

describe('nesting', function () {
it('installs without crashing', function () {
var nano = createNano();
});

it('prepends selectors if no & operand', function () {
var nano = createNano();

nano.putRaw = jest.fn();

nano.put('.foo', {
'.one,.two': {
color: 'tomato'
}
});

expect(nano.putRaw.mock.calls[0][0].includes('.foo .one,.foo .two')).toBe(true);
});
/*
it('expands & operand after', () => {
expect(interpolateSelectors(['.one', '#two'], '.test &')).toBe('.test .one,.test #two');
});
it('expands & operand before', () => {
expect(interpolateSelectors(['.test'], '&:hover')).toBe('.test:hover');
});
it('expands & operand before and preserves spaces', () => {
expect(interpolateSelectors(['.one', '.two'], '& .test')).toBe('.one .test,.two .test');
});
*/
});
2 changes: 1 addition & 1 deletion addon/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.addon = function (renderer) {
if (process.env.NODE_ENV === 'production') {
console.warn(
'You are using nano-css "validate" in production. ' +
'This addon is suggested to be used only in development.'
'This addon is meant to be used only in development.'
);
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"fastest-stable-stringify": "^1.0.1",
"stylis": "3.5.0",
"inline-style-prefixer": "^4.0.0",
"rtl-css-js": "^1.9.0"
"rtl-css-js": "^1.9.0",
"csstree-validator": "^1.3.1"
},
"devDependencies": {
"@types/react": "16.0.40",
Expand Down

0 comments on commit 440b4f3

Please sign in to comment.