Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 8718865

Browse files
committed
Add tests for form ticket component
Fix some linting issues
1 parent 901eebf commit 8718865

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

src/events/form/form-tickets.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</div>
1010
</template>
1111
<script>
12-
// import { mutations, getters } from '@/events/event-store';
1312
import EventStore from '@/events/event-store';
1413
1514
export default {
@@ -33,15 +32,6 @@
3332
};
3433
},
3534
36-
methods: {
37-
createTicket() {
38-
return {
39-
name: this.label,
40-
type: this.type,
41-
quantity: this.quantity,
42-
};
43-
},
44-
},
4535
computed: {
4636
ticketQuantity: {
4737
get() {

src/users/cd-create-account.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="cd-create-account__info">
66
<p>
77
<i class="fa fa-info-circle"></i>
8-
{{ $t('If you are a parent/guardian and want to book tickets for a child under 13, please fill in your own details.') }} <br/>
8+
{{ $t('If you are a parent/guardian and want to book tickets for a child under 13, please fill in your own details.') }} <br/>
99
{{ $t('We collect this information so we can contact you with updates about the events you\'re booking tickets for.') }}
1010
</p>
1111
</div>
@@ -42,7 +42,7 @@
4242
:proportions="[2, 2, 3]"></vue-dob-picker>
4343
</div>
4444
<p v-if="isUnderage" class="cd-create-account__dob-error text-danger">
45-
{{ $t('Sorry :( Since you are under 13, you\'re not yet allowed to book event tickets yourself.') }}
45+
{{ $t('Sorry :( Since you are under 13, you\'re not yet allowed to book event tickets yourself.') }}
4646
{{ $t('Please ask your parent or guardian to book for you.') }}
4747
</p>
4848
<p class="cd-create-account__dob-error text-danger"
@@ -163,7 +163,9 @@
163163
return false;
164164
}
165165
if (!this.recaptchaResponse) {
166+
/* eslint-disable no-alert */
166167
alert('Please complete the reCAPTCHA');
168+
/* eslint-enable no-alert */
167169
return false;
168170
}
169171
try {
@@ -194,7 +196,9 @@
194196
this.errors.add('registration', 'Nick exists', 'nick-exists');
195197
return;
196198
}
199+
/* eslint-disable no-alert */
197200
alert(err);
201+
/* eslint-enable no-alert */
198202
}
199203
}
200204
},

test/unit/specs/events/cd-event-form.spec.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ describe('Event Form component', () => {
3232

3333
MockEventStore = {
3434
commit: sinon.stub(),
35-
mutations: {
36-
},
3735
getters: {
3836
address: sinon.stub().resolves('123 Fake Street'),
3937
},
@@ -111,10 +109,6 @@ describe('Event Form component', () => {
111109
},
112110
};
113111

114-
MockEventStore.mutations = {
115-
setEvent: sinon.stub(),
116-
};
117-
118112
await vm.$lifecycleMethods.created();
119113

120114
expect(MockDojosService.getDojoById).to.have.been.calledOnce

test/unit/specs/events/event-store.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe('Event Store', () => {
5757
const event = { id: 1, name: 'Event name' };
5858
EventStore.commit('setEvent', event);
5959

60-
console.log(EventStore.state.event);
6160
expect(EventStore.state.event).to.deep.equal({
6261
id: 1,
6362
name: 'Event name',
Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
import vueUnitHelper from 'vue-unit-helper';
2-
import formTicket from '@/events/form/form-tickets';
2+
import formTicket from '!!vue-loader?inject!@/events/form/form-tickets';
33

44
describe('Form Ticket component', () => {
5+
let FormTicketWithMocks;
6+
let MockEventStore;
7+
8+
beforeEach(() => {
9+
MockEventStore = {
10+
commit: sinon.stub(),
11+
getters: {
12+
ticketQuantity: sinon.stub().returns(5),
13+
},
14+
};
15+
16+
FormTicketWithMocks = formTicket({
17+
'@/events/event-store': MockEventStore,
18+
});
19+
});
20+
21+
522
afterEach(() => {
623
sinon.restore();
724
});
825

9-
describe('lifecycle functions', () => {
26+
describe('computed', () => {
27+
describe('ticketQuantity', () => {
28+
it('returns value from event store', () => {
29+
const vm = vueUnitHelper(FormTicketWithMocks);
30+
expect(vm.ticketQuantity).to.eql(5);
31+
});
32+
it('updates value to event store', () => {
33+
const vm = vueUnitHelper(FormTicketWithMocks);
34+
vm.type = 'ticket-type';
35+
vm.ticketQuantity = 6;
36+
expect(MockEventStore.commit).to.have.been.calledOnce
37+
.and.calledWith('updateTicketQuantity', { quantity: 6, type: 'ticket-type' });
38+
});
39+
});
1040
});
11-
12-
// describe('computed', () => {
13-
// describe('tickets', () => {
14-
// it('should reference dom elements', () => {
15-
// const vm = vueUnitHelper(FormTicketWithMocks);
16-
// vm.$refs = {
17-
// youthTickets: 'one',
18-
// mentorTickets: 'two',
19-
// };
20-
// expect(vm.tickets).to.eql(['one', 'two']);
21-
// });
22-
// });
23-
// });
2441
});

0 commit comments

Comments
 (0)