Created
August 15, 2013 04:01
-
-
Save lukelex/6238165 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| describe 'Contexts.ContextManager', -> | |
| reloadContextManager = -> | |
| @contextManager = new Contexts.ContextManager | |
| sampleContext = {id: 'uniqueId'} | |
| differentContext = {id: 'differentId'} | |
| describe '#push', -> | |
| beforeEach reloadContextManager | |
| it 'with different contexts', -> | |
| @contextManager.push sampleContext | |
| (expect => | |
| @contextManager.push differentContext | |
| ).not.toThrow() | |
| it 'with equal contexts', -> | |
| @contextManager.push sampleContext | |
| (expect => | |
| @contextManager.push sampleContext | |
| ).toThrow() | |
| describe '#pop', -> | |
| beforeEach reloadContextManager | |
| it 'should not allow poping an unpushed context', -> | |
| (expect => | |
| @contextManager.pop sampleContext | |
| ).toThrow() | |
| it 'should allow poping a pre-pushed context', -> | |
| @contextManager.push sampleContext | |
| (expect => | |
| @contextManager.pop sampleContext | |
| ).not.toThrow() | |
| it 'should return an undefined context after poping the last one', -> | |
| @contextManager.push sampleContext | |
| @contextManager.pop sampleContext | |
| (expect @contextManager.current()).toBeUndefined() | |
| describe '#isCurrent', -> | |
| beforeEach reloadContextManager | |
| it 'while is the current', -> | |
| @contextManager.push sampleContext | |
| (expect @contextManager.isCurrent sampleContext).toBeTruthy() | |
| it 'while is the current', -> | |
| @contextManager.push sampleContext | |
| (expect @contextManager.isCurrent differentContext).toBeFalsy() | |
| it 'without a current context', -> | |
| (expect @contextManager.isCurrent sampleContext).toBeFalsy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment