We are the owners of a vegan-friendly store and would like you to create a visual representation of our inventory.
There are two main task described in the sections below.
| test('when the user submits a valid form should register the user', () => { | |
| /* | |
| * preconditions | |
| */ | |
| expect(getFormSubmitButton(wrapper).attributes('disabled')).toBe(undefined) | |
| expect($auth.registerUser).toHaveBeenCalledWith({ email: validEmail }) | |
| expect(wrapper.emitted()['register-update'][0]).toBe(registerUserResponse) | |
| }) |
| describe('when the user submits a valid form', () => { | |
| beforeEach(() => { | |
| /* | |
| * preconditions | |
| */ | |
| }) | |
| it('should enable the submit button', () => { | |
| expect(getFormSubmitButton(wrapper).attributes('disabled')).toBe(undefined) | |
| }) |
| describe('handleFormSubmit', () => { | |
| beforeEach(() => { … }) | |
| it('button disabled attribute is false', { ... }) | |
| it('is calling $auth.registerUser', () => { ... }) | |
| it('is calling $emit("register-update", ...)', { ... }) | |
| }) |
| describe('when the user submits a valid form', () => { | |
| beforeEach(() => { ... }) | |
| it('should enable the submit button', { ... }) | |
| it('should register the user by calling external API', () => { ... }) | |
| it('should emit the "register-update" event', { ... }) | |
| }) |
| import { createLocalVue, shallowMount } from '@vue/test-utils' | |
| import { createBuilder, testData } from './RegistrationFormComponent.builder.js' | |
| import RegistrationForm from './RegistrationForm.vue' | |
| import { byTestId } from '@/utils/testUtils.js' | |
| const localVue = createLocalVue() | |
| const validEmail = 'somename@example.com' | |
| const invalidEmail = 'invalid email' | |
| const registerUserResponse = { status: 200 } |