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
// Before | |
function getUserFriends(state): Friends[] { | |
return state.me.friends; | |
} | |
// After | |
function getUserFriends(state): Friends[] { | |
const friends = []; | |
// Please never do this; it's only to illustrate the point |
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
{ | |
me: { | |
id: 'bf6e74fe-9d41-4082-a48c-a2ce6d771da2', | |
firstName: 'Sébastien', | |
friendCount: 1, | |
friend-1: { | |
id: '7ccc3ebc-9310-426b-8e56-8d58f0a7ce2c', | |
firstName: 'Peppa' | |
} | |
} |
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
{ | |
user: { | |
id: 'bf6e74fe-9d41-4082-a48c-a2ce6d771da2', | |
firstName: 'Sébastien', | |
friends: [ | |
{ | |
id: '7ccc3ebc-9310-426b-8e56-8d58f0a7ce2c', | |
firstName: 'Peppa' | |
} | |
] |
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
cy.visit('http://www.google.com'); | |
cy.title().should('eq', 'Google'); | |
cy.get('input[type=text]').type('nightwatch'); | |
cy.get('button[name=btnG]').click(); | |
cy.contains('The Night Watch'); |
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
client. | |
url('http://www.google.com') | |
.waitForElementVisible('body', 1000) | |
.assert.title('Google') | |
.assert.visible('input[type=text]') | |
.setValue('input[type=text]', 'nightwatch') | |
.waitForElementVisible('button[name=btnG]', 1000) | |
.click('button[name=btnG]') | |
.pause(1000) | |
.assert.containsText('#main', 'The Night Watch') |
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
export function testId(id: string) { | |
return `[data-testid="${id}"]`; | |
} |
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
Show hidden characters
{ | |
"env": { | |
"production": { | |
"plugins": [ | |
[ | |
"react-remove-properties", | |
{ | |
"properties": [ | |
"data-testid" | |
] |
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(); | |
}); |
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
export function IncomingCalls({ calls }: Props) { | |
return ( | |
<div> | |
<p> | |
Incoming Calls | |
</p> | |
{calls.length > 0 ? | |
<div data-testid="incoming-call-list"> | |
{calls.map(call => <CallCard key={call.id} call={call} />)} |