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
| // Implementation: | |
| const callIfArray = (arr, cb) => Array.isArray(arr) ? cb(arr) : arr; | |
| const flattenRec = (arr) => arr.reduce( | |
| (acc, curr) => acc.concat(callIfArray(curr, flattenRec)), | |
| [] | |
| ); | |
| const flattenArray = (arr) => callIfArray(arr, flattenRec); | |
| // Testing: | |
| const tests = [ |
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
| <script> | |
| import { validateEmail } from './validateEmail.js' | |
| export default { | |
| name: 'RegistrationForm', | |
| props: { | |
| termsAndConditions: { | |
| type: Boolean, | |
| default: false | |
| } |
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
| <script> | |
| import { validateEmail } from './validateEmail.js' | |
| export default { | |
| name: 'RegistrationForm', | |
| props: { | |
| termsAndConditions: { | |
| type: Boolean, | |
| default: false | |
| } |
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
| it('when the user submits it should call "handleFormSubmit" method', () => { | |
| expect(wrapper.vm.handleFormSubmit).toHaveBeenCalled() | |
| }) |
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
| it('should display the required fields form errors', () => { | |
| expect(getFormErrorElem(wrapper).text()).toBe('Invalid Email.') | |
| }) |
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
| it('when the user submits it should emit the "register-update" event', () => { | |
| const eventArgs = wrapper.emitted()['register-update'][0] | |
| expect(eventArgs).toBe(registerUserResponse) | |
| }) |
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
| it('when the user submits it should call external API', () => { | |
| expect($auth.registerUser).toHaveBeenCalledWith({ | |
| email: validEmail | |
| }) | |
| }) |
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
| it('should display the required fields form errors', () => { | |
| expect(wrapper.vm.errorMsg).toBe('Invalid Email.') | |
| }) |
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
| it('mounts properly', () => { ... }) | |
| it('when the user submits a form should register the user by calling external API', | |
| () => { ... }) | |
| it('renders properly', () => { ... }) | |
| it('when the form is loaded should make the submit button disabled', () => { ... }) | |
| it('should log the appropriate error', () => { ... }) |
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('when the user submits a valid form', () => { | |
| beforeEach(() => { ... }) | |
| it('should enable the submit button', () => { ... }) | |
| it('should register the user by calling external API', () => { ... }) | |
| }) | |
| describe('when the user submits an invalid form', () => { | |
| beforeEach(() => { ... }) | |
| it('should disable the submit button', () => { ... }) |
OlderNewer