-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emotion: Custom instance to avoid global conflict
This update adjusts the (custom) Emotion namespace to avoid collision with potential stock instances of Emotion. Tests have been added for this case. A `emotion.cssWithScope` guard + fallback is added to `create-emotion-styled` that defaults to `emotion.css` if that custom function is not available.
- Loading branch information
ItsJonQ
committed
Jul 25, 2018
1 parent
51eb988
commit 221e826
Showing
5 changed files
with
83 additions
and
28 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
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,24 @@ | ||
import createEmotion from '../index' | ||
|
||
describe('createEmotion', () => { | ||
afterEach(() => { | ||
global.__SECRET_EMOTION__ = undefined | ||
global.__SECRET_FANCY_EMOTION__ = undefined | ||
}) | ||
|
||
test('Creats unique global instance of Emotion', () => { | ||
const inst = createEmotion(global) | ||
|
||
expect(global.__SECRET_FANCY_EMOTION__).toBe(inst) | ||
}) | ||
|
||
test('Does not collide with stock instance of Emotion', () => { | ||
const mockEmotion = {} | ||
global.__SECRET_EMOTION__ = mockEmotion | ||
|
||
const inst = createEmotion(global) | ||
|
||
expect(global.__SECRET_EMOTION__).toBe(mockEmotion) | ||
expect(global.__SECRET_FANCY_EMOTION__).toBe(inst) | ||
}) | ||
}) |
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
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