Last active
July 23, 2019 17:14
-
-
Save SebDuf/2af240e8666a1f310db22ac0e738ab8f 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
import { shallow } from 'enzyme'; | |
describe('IncomingCalls component', () => { | |
describe('given NO calls', () => { | |
it('should render empty state', async () => { | |
const component = createComponent({ calls: [] }); | |
expect(component.exists(testId('no-incoming-calls'))).toBeTruthy(); | |
}); | |
it('should NOT render call list', async () => { | |
const component = createComponent({ calls: [] }); | |
expect(component.exists(testId('incoming-call-list'))).toBeFalsy(); | |
}); | |
}); | |
describe('given calls', () => { | |
it('should render incoming calls', async () => { | |
const component = createComponent({ calls: [{ id: 'SOME_ID' }] }); | |
expect(component.exists(testId('incoming-call-list'))).toBeTruthy(); | |
}); | |
it('should render all calls', async () => { | |
const calls = [{ id: 'SOME_ID' }]; | |
const component = createComponent({ calls }); | |
expect(component.find(testId('incoming-call-list')).children()).toHaveLength(calls.length) | |
}); | |
it('should NOT render empty state', async () => { | |
const component = createComponent({ calls: [{ id: 'SOME_ID' }] }); | |
expect(component.exists(testId('no-incoming-calls'))).toBeFalsy(); | |
}); | |
}); | |
}); | |
function createComponent(props = {}) { | |
return shallow(<IncomingCalls {...props} />); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment