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

Commit 5aea0ce

Browse files
committed
Add the files
1 parent 41dc90a commit 5aea0ce

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

src/events/form/form-tickets.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div>
3+
<label for="quantity">{{ $t(label) }}</label>
4+
<input type="number" v-model="quantity" name="quantity" />
5+
</div>
6+
7+
</template>
8+
<script>
9+
export default {
10+
name: 'form-ticket',
11+
props: [
12+
'label',
13+
'default-quantity',
14+
],
15+
data() {
16+
return {
17+
quantity: null,
18+
};
19+
},
20+
methods: {
21+
createTicket() {
22+
console.log('TODO');
23+
},
24+
},
25+
created() {
26+
this.quantity = this.defaultQuantity;
27+
},
28+
};
29+
30+
</script>
31+
<style scoped lang="less">
32+
33+
</style>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import vueUnitHelper from 'vue-unit-helper';
2+
import formTicket from '!!vue-loader?inject!@/events/form/form-tickets';
3+
4+
describe('Form Ticket component', () => {
5+
let sandbox;
6+
let FormTicketWithMocks;
7+
8+
beforeEach(() => {
9+
sandbox = sinon.sandbox.create();
10+
FormTicketWithMocks = formTicket();
11+
});
12+
13+
afterEach(() => {
14+
sandbox.restore();
15+
});
16+
17+
describe.only('lifecycle functions', () => {
18+
describe('created', () => {
19+
it('sets default quantity', () => {
20+
// ARRANGE
21+
const vm = vueUnitHelper(FormTicketWithMocks);
22+
expect(vm.quantity).to.be.null;
23+
vm.defaultQuantity = 42;
24+
25+
// ACT
26+
vm.$lifecycleMethods.created();
27+
28+
// ASSERT
29+
expect(vm.quantity).to.equal(42);
30+
});
31+
});
32+
});
33+
34+
// describe('computed', () => {
35+
// describe('tickets', () => {
36+
// it('should reference dom elements', () => {
37+
// const vm = vueUnitHelper(FormTicketWithMocks);
38+
// vm.$refs = {
39+
// youthTickets: 'one',
40+
// mentorTickets: 'two',
41+
// };
42+
// expect(vm.tickets).to.eql(['one', 'two']);
43+
// });
44+
// });
45+
// });
46+
//
47+
// describe.only('methods', () => {
48+
// describe('save', () => {
49+
// it('should reference dom elements', async () => {
50+
// const vm = vueUnitHelper(FormTicketWithMocks);
51+
// const createTicket = sandbox.stub();
52+
// const event = {
53+
// preventDefault: sandbox.stub(),
54+
// };
55+
//
56+
// vm.tickets = [
57+
// { createTicket },
58+
// { createTicket },
59+
// ];
60+
// await vm.save(event);
61+
// expect(event.preventDefault).to.have.been.calledOnce;
62+
// expect(createTicket).to.have.been.calledTwice;
63+
// });
64+
// });
65+
// });
66+
});

0 commit comments

Comments
 (0)