mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
chore: fix test
This commit is contained in:
parent
9b42b45cfb
commit
c5c33be00f
6 changed files with 15 additions and 15 deletions
|
@ -9,7 +9,7 @@ import { IProps } from './types';
|
|||
|
||||
const NotFound = ({ pkg }: IProps) => (
|
||||
<Wrapper>
|
||||
<h1>Error 404 -{pkg}</h1>
|
||||
<h1>Error 404 - {pkg}</h1>
|
||||
<hr />
|
||||
<p>Oops, The package you are trying to access does not exist.</p>
|
||||
</Wrapper>
|
||||
|
|
|
@ -46,9 +46,9 @@ describe('App', () => {
|
|||
});
|
||||
|
||||
test('toggleLoginModal: should toggle the value in state', () => {
|
||||
const { toggleLoginModal } = wrapper.instance();
|
||||
const { handleToggleLoginModal } = wrapper.instance();
|
||||
expect(wrapper.state().showLoginModal).toBeFalsy();
|
||||
toggleLoginModal();
|
||||
handleToggleLoginModal();
|
||||
expect(wrapper.state('showLoginModal')).toBeTruthy();
|
||||
expect(wrapper.state('error')).toEqual({});
|
||||
});
|
||||
|
@ -74,9 +74,9 @@ describe('App', () => {
|
|||
expect(wrapper.state('isUserLoggedIn')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('doLogin - login the user successfully', async () => {
|
||||
const { doLogin } = wrapper.instance();
|
||||
await doLogin('sam', '1234');
|
||||
test('handleDoLogin - login the user successfully', async () => {
|
||||
const { handleDoLogin } = wrapper.instance();
|
||||
await handleDoLogin('sam', '1234');
|
||||
const result = {
|
||||
username: 'sam',
|
||||
token: 'TEST_TOKEN'
|
||||
|
@ -88,9 +88,9 @@ describe('App', () => {
|
|||
expect(wrapper.state('user')).toEqual(result);
|
||||
});
|
||||
|
||||
test('doLogin - authentication failure', async () => {
|
||||
const { doLogin } = wrapper.instance();
|
||||
await doLogin('sam', '12345');
|
||||
test('handleDoLogin - authentication failure', async () => {
|
||||
const { handleDoLogin } = wrapper.instance();
|
||||
await handleDoLogin('sam', '12345');
|
||||
console.log(API_ERROR.BAD_USERNAME_PASSWORD);
|
||||
const result = {
|
||||
description: 'bad username/password, access denied',
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g efsnl070\\"><div class=\\"css-hzfs9b efsnl071\\"><div class=\\"css-4kqzh2 efsnl072\\">Made with<span class=\\"css-1so4oe0 efsnl077\\">♥</span>on<span class=\\"css-1ie354y efsnl074\\"><svg class=\\"efsnl075 css-10ih290 ej4jd2o0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-e8kfuf efsnl076\\"><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Pakistan</title><use xlink:href=\\"[object Object]#pakistan\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-zxlexh efsnl073\\">Powered by<span class=\\"efsnl079 css-i15wza ej4jd2o1\\" title=\\"Verdaccio\\"><img src=\\"[object Object]\\" alt=\\"Verdaccio\\" class=\\"css-1ncdhax ej4jd2o2\\"></span>/ 4.0.0-alpha.3</div></div></div>"`;
|
||||
exports[`<Footer /> component should load the initial state of Footer component 1`] = `"<div class=\\"css-i0nj2g efsnl070\\"><div class=\\"css-hzfs9b efsnl071\\"><div class=\\"css-4kqzh2 efsnl072\\">Made with<span class=\\"css-1so4oe0 efsnl077\\">♥</span>on<span class=\\"css-1ie354y efsnl074\\"><svg class=\\"efsnl075 css-10ih290 ej4jd2o0\\"><title>Earth</title><use xlink:href=\\"[object Object]#earth\\"></use></svg><span class=\\"css-e8kfuf efsnl076\\"><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Spain</title><use xlink:href=\\"[object Object]#spain\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Nicaragua</title><use xlink:href=\\"[object Object]#nicaragua\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>India</title><use xlink:href=\\"[object Object]#india\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Brazil</title><use xlink:href=\\"[object Object]#brazil\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Pakistan</title><use xlink:href=\\"[object Object]#pakistan\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>China</title><use xlink:href=\\"[object Object]#china\\"></use></svg><svg class=\\"efsnl078 css-f1ndto ej4jd2o0\\"><title>Austria</title><use xlink:href=\\"[object Object]#austria\\"></use></svg></span></span></div><div class=\\"css-zxlexh efsnl073\\">Powered by<span class=\\"efsnl079 css-i15wza ej4jd2o1\\" title=\\"Verdaccio\\"><img alt=\\"Verdaccio\\" src=\\"[object Object]\\" class=\\"css-1ncdhax ej4jd2o2\\"></span>/ 4.0.0-alpha.3</div></div></div>"`;
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
exports[`<LoginModal /> should load the component in default state 1`] = `"<div class=\\"MuiModal-root-13 MuiDialog-root-1 MuiDialog-scrollPaper-2\\" role=\\"dialog\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-15\\" aria-hidden=\\"true\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiPaper-root-17 MuiPaper-elevation24-43 MuiPaper-rounded-18 MuiDialog-paper-4 MuiDialog-paperScrollPaper-5 MuiDialog-paperWidthXs-7 MuiDialog-paperFullWidth-11\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"document\\" tabindex=\\"-1\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-44\\"><h2 class=\\"MuiTypography-root-45 MuiTypography-title-51\\">Login</h2></div><div class=\\"MuiDialogContent-root-71\\"><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98 MuiInputBase-inputType-116 MuiInput-inputType-101\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-120 dialog-footer\\"><button tabindex=\\"0\\" class=\\"MuiButtonBase-root-148 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-123\\">Cancel</span><span class=\\"MuiTouchRipple-root-151\\"></span></button><button tabindex=\\"-1\\" class=\\"MuiButtonBase-root-148 MuiButtonBase-disabled-149 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-disabled-142 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-123\\">Login</span></button></div></form></div></div>"`;
|
||||
|
||||
exports[`<LoginModal /> should load the component with props 1`] = `"<div class=\\"MuiModal-root-13 MuiDialog-root-1 MuiDialog-scrollPaper-2\\" role=\\"dialog\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-15\\" aria-hidden=\\"true\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiPaper-root-17 MuiPaper-elevation24-43 MuiPaper-rounded-18 MuiDialog-paper-4 MuiDialog-paperScrollPaper-5 MuiDialog-paperWidthXs-7 MuiDialog-paperFullWidth-11\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"document\\" tabindex=\\"-1\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-44\\"><h2 class=\\"MuiTypography-root-45 MuiTypography-title-51\\">Login</h2></div><div class=\\"MuiDialogContent-root-71\\"><div class=\\"MuiTypography-root-45 MuiTypography-body1-54 MuiPaper-root-17 MuiPaper-elevation6-25 MuiSnackbarContent-root-158 loginError\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message-159\\"><div id=\\"client-snackbar\\" class=\\"loginErrorMsg\\"><svg class=\\"MuiSvgIcon-root-161 loginIcon\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98 MuiInputBase-inputType-116 MuiInput-inputType-101\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-120 dialog-footer\\"><button tabindex=\\"0\\" class=\\"MuiButtonBase-root-148 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-123\\">Cancel</span><span class=\\"MuiTouchRipple-root-151\\"></span></button><button tabindex=\\"-1\\" class=\\"MuiButtonBase-root-148 MuiButtonBase-disabled-149 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-disabled-142 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-123\\">Login</span></button></div></form></div></div>"`;
|
||||
exports[`<LoginModal /> should load the component with props 1`] = `"<div class=\\"MuiModal-root-13 MuiDialog-root-1 MuiDialog-scrollPaper-2\\" role=\\"dialog\\" id=\\"login--form-container\\"><div class=\\"MuiBackdrop-root-15\\" aria-hidden=\\"true\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\"></div><div class=\\"MuiPaper-root-17 MuiPaper-elevation24-43 MuiPaper-rounded-18 MuiDialog-paper-4 MuiDialog-paperScrollPaper-5 MuiDialog-paperWidthXs-7 MuiDialog-paperFullWidth-11\\" style=\\"opacity: 1; -webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\\" role=\\"document\\" tabindex=\\"-1\\"><form novalidate=\\"\\"><div class=\\"MuiDialogTitle-root-44\\"><h2 class=\\"MuiTypography-root-45 MuiTypography-title-51\\">Login</h2></div><div class=\\"MuiDialogContent-root-71\\"><div class=\\"MuiTypography-root-45 MuiTypography-body1-54 MuiPaper-root-17 MuiPaper-elevation6-25 MuiSnackbarContent-root-158 loginError\\" role=\\"alertdialog\\"><div class=\\"MuiSnackbarContent-message-159\\"><div class=\\"loginErrorMsg\\" id=\\"client-snackbar\\"><svg class=\\"MuiSvgIcon-root-161 loginIcon\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\\"></path></svg><span><div><strong>Error Title</strong></div><div>Error Description</div></span></div></div></div><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"username\\">Username<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98\\" id=\\"login--form-username\\" placeholder=\\"Your username\\" required=\\"\\" type=\\"text\\" value=\\"\\"></div></div><div class=\\"MuiFormControl-root-72 MuiFormControl-fullWidth-75\\" style=\\"margin-top: 8px;\\"><label class=\\"MuiFormLabel-root-83 MuiFormLabel-required-88 MuiInputLabel-root-76 MuiInputLabel-formControl-77 MuiInputLabel-animated-80\\" data-shrink=\\"false\\" for=\\"password\\">Password<span class=\\"MuiFormLabel-asterisk-89\\"> *</span></label><div class=\\"MuiInputBase-root-103 MuiInput-root-90 MuiInput-underline-94 MuiInputBase-formControl-104 MuiInput-formControl-91\\"><input aria-invalid=\\"false\\" class=\\"MuiInputBase-input-113 MuiInput-input-98 MuiInputBase-inputType-116 MuiInput-inputType-101\\" id=\\"login--form-password\\" placeholder=\\"Your strong password\\" required=\\"\\" type=\\"password\\" value=\\"\\"></div></div></div><div class=\\"MuiDialogActions-root-120 dialog-footer\\"><button tabindex=\\"0\\" class=\\"MuiButtonBase-root-148 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"button\\" id=\\"login--form-cancel\\"><span class=\\"MuiButton-label-123\\">Cancel</span><span class=\\"MuiTouchRipple-root-151\\"></span></button><button tabindex=\\"-1\\" class=\\"MuiButtonBase-root-148 MuiButtonBase-disabled-149 MuiButton-root-122 MuiButton-text-124 MuiButton-flat-127 MuiButton-disabled-142 MuiButton-colorInherit-143 MuiDialogActions-action-121\\" type=\\"submit\\" disabled=\\"\\" id=\\"login--form-submit\\"><span class=\\"MuiButton-label-123\\">Login</span></button></div></form></div></div>"`;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<NotFound /> component should load the component in default state 1`] = `"<div class=\\"css-24p7uw e1gvymku0\\"><h1>Error 404 - test</h1><hr><p>Oops, The package you are trying to access does not exist.</p></div>"`;
|
||||
exports[`<NotFound /> component should load the component in default state 1`] = `"<div class=\\"css-24p7uw e1gvymku0\\"><h1>Error 404 -test</h1><hr><p>Oops, The package you are trying to access does not exist.</p></div>"`;
|
||||
|
||||
exports[`<NotFound /> component should set html from props 1`] = `"<div class=\\"css-24p7uw e1gvymku0\\"><h1>Error 404 - verdaccio</h1><hr/><p>Oops, The package you are trying to access does not exist.</p></div>"`;
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('<Header /> component with logged in state', () => {
|
|||
props = {
|
||||
username: 'test user',
|
||||
handleLogout: jest.fn(),
|
||||
toggleLoginModal: jest.fn(),
|
||||
onToggleLoginModal: jest.fn(),
|
||||
scope: 'test scope',
|
||||
withoutSearch: true,
|
||||
};
|
||||
|
@ -57,7 +57,7 @@ describe('<Header /> component with logged out state', () => {
|
|||
beforeEach(() => {
|
||||
props = {
|
||||
handleLogout: jest.fn(),
|
||||
toggleLoginModal: jest.fn(),
|
||||
onToggleLoginModal: jest.fn(),
|
||||
scope: 'test scope',
|
||||
withoutSearch: true,
|
||||
};
|
||||
|
@ -97,6 +97,6 @@ describe('<Header /> component with logged out state', () => {
|
|||
const { handleToggleLogin } = wrapper.instance();
|
||||
handleToggleLogin();
|
||||
expect(wrapper.state('anchorEl')).toBeNull();
|
||||
expect(props.toggleLoginModal).toHaveBeenCalled();
|
||||
expect(props.onToggleLoginModal).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue