Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
const isLessVariable = require('../isLessVariable'); | ||
const less = require('postcss-less'); | ||
|
||
describe('isLessVariable', () => { | ||
it('is less variable', () => { | ||
lessAtRules('@var: 10px;', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it('is less variable with function', () => { | ||
lessAtRules('@hover-color: darken(@color, 10%);', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it('@charset is not a less variable', () => { | ||
lessAtRules('@charset UTF-8;', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
it('@import is not a less variable', () => { | ||
lessAtRules('@import url("some-styles.css");', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
it('@media is not a less variable', () => { | ||
lessAtRules('@media (min-width: 100px) {};', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
it('detached ruleset is not a less variable', () => { | ||
lessAtRules('@detached-ruleset: { margin: 0 };', (atRule) => { | ||
expect(isLessVariable(atRule)).toBeFalsy(); | ||
}); | ||
}); | ||
}); | ||
|
||
function lessAtRules(css, cb) { | ||
less.parse(css).walkAtRules(cb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* @flow */ | ||
'use strict'; | ||
|
||
const hasBlock = require('./hasBlock'); | ||
|
||
module.exports = function(atRule /*: Object*/) /*: boolean*/ { | ||
return atRule.type === 'atrule' && atRule.variable && !hasBlock(atRule); | ||
}; |