-
Notifications
You must be signed in to change notification settings - Fork 31
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
1 parent
a1c9a4f
commit 8667085
Showing
4 changed files
with
203 additions
and
56 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { isShorthand } = require('../isShorthand'); | ||
|
||
test('margin is shorthand for margin-top', () => { | ||
expect(isShorthand('margin', 'margin-top')).toBe(true); | ||
}); | ||
|
||
test('margin-top is not shorthand for margin', () => { | ||
expect(isShorthand('margin-top', 'margin')).toBe(false); | ||
}); | ||
|
||
test('margin-block is shorthand for margin-top', () => { | ||
expect(isShorthand('margin-block', 'margin-top')).toBe(true); | ||
}); | ||
|
||
test('margin-top is not shorthand for margin-block', () => { | ||
expect(isShorthand('margin-top', 'margin-block')).toBe(false); | ||
}); | ||
|
||
test('border-inline is shorthand for border-top-color', () => { | ||
expect(isShorthand('border-inline', 'border-top-color')).toBe(true); | ||
}); | ||
|
||
test('border-top-color is not shorthand for border-inline', () => { | ||
expect(isShorthand('border-top-color', 'border-inline')).toBe(false); | ||
}); |
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,19 @@ | ||
const shorthandData = require('./shorthandData'); | ||
|
||
exports.isShorthand = function isShorthand(a, b) { | ||
if (!shorthandData[a]) { | ||
return false; | ||
} | ||
|
||
if (shorthandData[a].includes(b)) { | ||
return true; | ||
} | ||
|
||
for (const longhand of shorthandData[a]) { | ||
if (isShorthand(longhand, b)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
}; |
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