-
-
Notifications
You must be signed in to change notification settings - Fork 389
Fix added nested rules order #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| import expect from 'expect.js' | ||
| import {stripIndent} from 'common-tags' | ||
| import jssNested from 'jss-nested' | ||
| import {create} from '../../src' | ||
| import StyleSheet from '../../src/StyleSheet' | ||
| import {createGenerateClassName} from '../utils' | ||
| import PluginsRegistry from '../../src/PluginsRegistry' | ||
| import { | ||
| createGenerateClassName, | ||
| getCssFromSheet, | ||
| removeWhitespace | ||
| } from '../utils' | ||
|
|
||
| describe('Integration: plugins', () => { | ||
| let jss | ||
|
|
@@ -416,4 +421,29 @@ describe('Integration: plugins', () => { | |
| `) | ||
| }) | ||
| }) | ||
|
|
||
| describe('jss-nested', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test actually belongs to jss-nested
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alternatively we could describe the same scenario using plugins api instead of jss-nested plugin
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this test should be here because it tests the way how rules apply in some cases, so the same scenario instead of jss-nested looks better for me |
||
| let sheet | ||
|
|
||
| beforeEach(() => { | ||
| jss.use(jssNested()) | ||
|
|
||
| sheet = jss.createStyleSheet({}, { | ||
| link: true, | ||
| }).attach() | ||
|
|
||
| sheet.addRule('b', {color: 'green'}) | ||
| sheet.addRule('a', { | ||
| '&:hover': { | ||
| '& $b': { | ||
| color: 'red', | ||
| }, | ||
| }, | ||
| }) | ||
| }) | ||
|
|
||
| it('should save the added nested rules order', () => { | ||
| expect(getCssFromSheet(sheet)).to.be(removeWhitespace(sheet.toString())) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we only use DOM based tests in functional tests, is DOM really needed here or sheet.toString() + comparing with result would be enough?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I think we can replace expect with the exact result |
||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why this is not breaking anything else. You are reverting the order of added rules for all addRule calls. Maybe there is a missing test which ensures the right order.
We have actually an
options.indexwhich is set in jss-nested in order to have the control over the order. Maybe jss-nested sets the wrong index?