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
describe('when try to log out user', () => { | |
describe('and when is user logged in', () => { | |
beforeEach(async () => { | |
// ... | |
isUserLoggedIn = createStub().resolves(true); | |
logOutAction = createSpy(); | |
// ... | |
}); | |
it('should log user out', () => { |
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
describe('when try to log out user', () => { | |
describe('and when is user logged in', () => { | |
beforeEach(async () => { | |
// ... | |
isUserLoggedIn = jest.fn().mockImplementation(() => new Promise((resolve) => resolve(true))); | |
logOutAction = jest.fn(); | |
// ... | |
}); | |
it('should log user out', () => { |
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
test('render Markdown in preview mode', () => { | |
const wrapper = shallow( | |
<MarkdownEditor value="*Hello* Jest!" /> | |
); | |
expect(wrapper).toMatchSnapshot(); | |
wrapper.find('[name="toggle-preview"]').simulate('click'); | |
expect(wrapper).toMatchSnapshot(); |
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
it('renders correctly', () => { | |
const signUpComponent = renderer | |
.create(<SignUp/>) | |
.toJSON(); | |
expect(tree).toMatchSnapshot(); | |
}); |
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
describe('Last name input', () => { | |
describe('when it changed', () => { | |
beforeEach(() => { | |
componentWrapper.find('#lastName').simulate('change', { target: { value: 'Duan' } }); | |
}); | |
it('should display changed value', () => { | |
expect(componentWrapper.find('#lastName').props().value).toEqual('Duan'); | |
}); | |
}); |
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
function login(requestBody) { | |
return requestPromise.post({ | |
uri: `${API_BASE_URL}/api/new/cool/auth?${requestBody.formQuery}&random="value"`, | |
body: {somethingNew: requestBody.newStaff, username: requestBody.username}, | |
json: true, | |
resolveWithFullResponse: true, | |
simple: 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
function requestAdapter(expressRequest) { | |
return request; | |
} | |
function responseAdapter(expressResponse) { | |
return { | |
send: (statusCode, data, headers) => { | |
expressResponse.status(statusCode); | |
if (headers) { |
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
const {INTERNAL_SERVER_ERROR, OK } = require('http-status-codes'); | |
async function login(request, response, loginAction) { | |
try { | |
const actionResult = await loginAction(request.body); | |
handleResponse(request, response, actionResult); | |
} catch (e) { | |
sendInternalServerError(response); | |
} | |
} |
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
const response = await requestPromise.post({ | |
uri: `${API_BASE_URL}/api/new/cool/auth?${req.body.formQuery}&some="garbage"`, | |
body: {somethingNew: req.body.newStaff, username: req.body.username}, | |
json: true, | |
resolveWithFullResponse: true, | |
simple: 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
const response = await requestPromise.post({ | |
uri: `${API_BASE_URL}/api/oauth2/auth?${req.body.formQuery}`, | |
body: req.body, | |
json: true, | |
strictSSL: false, | |
resolveWithFullResponse: true, | |
simple: false, | |
}); |
NewerOlder