|
1 | 1 | import Vue from 'vue';
|
2 |
| -import AddToCalendar from '../../src/add-to-calendar'; |
| 2 | +import AddToCalendar, { calendars } from '../../src/add-to-calendar'; |
3 | 3 | import AddToCalendarMixin from '../../src/add-to-calendar-mixin';
|
4 | 4 |
|
5 | 5 | describe('AddToCalendar', () => {
|
| 6 | + const event = { |
| 7 | + title: 'VueConf', |
| 8 | + location: 'WROCŁAW, POLAND', |
| 9 | + start: new Date(), |
| 10 | + end: new Date((new Date()).setDate((new Date()).getDate() + 1)), |
| 11 | + details: 'The first Official Vue.js Conference in the world!' |
| 12 | + }; |
| 13 | + |
6 | 14 | const createComponent = (propsData = {}, attr = {}, mixin = AddToCalendarMixin) => {
|
7 | 15 | const Ctor = Vue.extend({
|
8 | 16 | template: `
|
@@ -33,26 +41,44 @@ describe('AddToCalendar', () => {
|
33 | 41 | }).$mount();
|
34 | 42 | };
|
35 | 43 |
|
36 |
| - // Inspect the raw component options |
37 | 44 | it('has a mounted method', () => {
|
38 | 45 | expect(typeof AddToCalendar.mounted).toBe('function');
|
39 | 46 | });
|
40 | 47 |
|
41 |
| - // Evaluate the results of functions in |
42 |
| - // the raw component options |
| 48 | + it('has a valid template', () => { |
| 49 | + expect(typeof AddToCalendarMixin.template).toBe('string'); |
| 50 | + |
| 51 | + const vm = createComponent().$children[0]; |
| 52 | + |
| 53 | + expect(vm.$children[0].$el.text.trim()).toBe('Add to Google calendar'); |
| 54 | + expect(vm.$children[1].$el.text.trim()).toBe('Add to Microsoft live calendar'); |
| 55 | + |
| 56 | + expect(vm.$children[0].$el.href).toContain(calendars.google.url); |
| 57 | + expect(vm.$children[1].$el.href).toContain(calendars.microsoft.url); |
| 58 | + }); |
| 59 | + |
| 60 | + it('has a calendar class computed property', () => { |
| 61 | + expect(typeof AddToCalendarMixin.template).toBe('string'); |
| 62 | + }); |
| 63 | + |
43 | 64 | it('sets the correct default data', () => {
|
44 | 65 | expect(typeof AddToCalendar.data).toBe('function');
|
| 66 | + |
45 | 67 | const defaultData = AddToCalendar.data();
|
46 | 68 | expect(typeof defaultData.calendars).toBe('object');
|
| 69 | + expect(defaultData.calendars).toBe(calendars); |
47 | 70 | });
|
48 | 71 |
|
49 |
| - xit('should set component aliases correctly', () => { |
50 |
| - createComponent(); |
51 |
| - |
52 |
| - // const vm = createComponent(); |
53 |
| - // console.log(vm.components, vm.google); |
54 |
| - }); |
55 |
| - |
56 |
| - xit('should get correct calendar url', () => { |
| 72 | + it('should set url parameters correctly', () => { |
| 73 | + for (const calendar in calendars) { |
| 74 | + expect(typeof calendars[calendar].parameters).toBe('function'); |
| 75 | + expect(typeof calendars[calendar].parameters( |
| 76 | + event.title, |
| 77 | + event.location, |
| 78 | + event.description, |
| 79 | + event.start, |
| 80 | + event.end |
| 81 | + )).toBe('object'); |
| 82 | + } |
57 | 83 | });
|
58 | 84 | });
|
0 commit comments