From 36e295af3b1c05c59d97826430a7a7f16c1e303e Mon Sep 17 00:00:00 2001 From: Lasse Boisen Andersen Date: Sat, 28 Nov 2015 01:00:44 +0100 Subject: [PATCH 1/3] fixed bug with field checking on book --- src/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.js b/src/main.js index 37d03a7e..4d04f01c 100644 --- a/src/main.js +++ b/src/main.js @@ -174,10 +174,10 @@ function TimekitBooking() { rootTarget.removeClass('bookingjs-small'); } - if (config.bookingFields.comment.enabled === true) { height += 84; } - if (config.bookingFields.phone.enabled === true) { height += 48; } - if (config.bookingFields.voip.enabled === true) { height += 48; } - if (config.bookingFields.location.enabled === true) { height += 48; } + if (config.bookingFields.comment.enabled) { height += 84; } + if (config.bookingFields.phone.enabled) { height += 48; } + if (config.bookingFields.voip.enabled) { height += 48; } + if (config.bookingFields.location.enabled) { height += 48; } return { height: height, @@ -347,10 +347,10 @@ function TimekitBooking() { participants: [config.email, data.email] }; - if (data.location.enabled) { args.where = data.location; } - if (data.phone.enabled) { args.description += 'Phone: ' + data.phone + '\n'; } - if (data.voip.enabled) { args.description += 'VoIP: ' + data.voip + '\n'; } - if (data.comment.enabled) { args.description += 'Comment: ' + data.comment + '\n'; } + if (config.bookingFields.location.enabled) { args.where = data.location; } + if (config.bookingFields.phone.enabled) { args.description += config.bookingFields.phone.placeholder + ': ' + data.phone + '\n'; } + if (config.bookingFields.voip.enabled) { args.description += config.bookingFields.voip.placeholder + ': ' + data.voip + '\n'; } + if (config.bookingFields.comment.enabled) { args.description += config.bookingFields.comment.placeholder + ': ' + data.comment + '\n'; } $.extend(true, args, config.timekitCreateEvent); From e162808bc670cf2cb2b04cbd46818f412b262414 Mon Sep 17 00:00:00 2001 From: Lasse Boisen Andersen Date: Sat, 28 Nov 2015 01:00:59 +0100 Subject: [PATCH 2/3] added test for booking flow --- test/basicInteractions.spec.js | 38 ++++++++++++++++++++++++++++++++++ test/utils/mockAjax.js | 9 ++++++++ 2 files changed, 47 insertions(+) diff --git a/test/basicInteractions.spec.js b/test/basicInteractions.spec.js index 504c20e6..5bfc8c73 100644 --- a/test/basicInteractions.spec.js +++ b/test/basicInteractions.spec.js @@ -47,4 +47,42 @@ describe('Basic interaction', function() { }); + it('should be able to book an event', function(done) { + + createWidget(); + + setTimeout(function() { + + interact.clickEvent(); + + setTimeout(function() { + + var name = 'Joe Test'; + var email = 'test@timekit.io'; + var comment = 'This is a test'; + + $('.input-name').val(name); + $('.input-email').val(email); + $('.input-comment').val(comment); + $('.bookingjs-form-button').click(); + + expect($('.bookingjs-form').hasClass('loading')).toBe(true); + + setTimeout(function() { + + expect($('.bookingjs-form').hasClass('success')).toBe(true); + expect($('.bookingjs-form-success-message')).toBeVisible(); + + var successMessage = $('.bookingjs-form-success-message').html(); + var contains = successMessage.indexOf(email) > -1; + expect(contains).toBe(true); + + done(); + + }, 100); + }, 500); + }, 500); + + }); + }); diff --git a/test/utils/mockAjax.js b/test/utils/mockAjax.js index fd943448..4f4923f5 100644 --- a/test/utils/mockAjax.js +++ b/test/utils/mockAjax.js @@ -23,4 +23,13 @@ module.exports = function() { responseText: '{"data":{"timezone":"America\/Los_Angeles","utc_offset":-8}}' }); + jasmine.Ajax.stubRequest( + 'https://api.timekit.io/v2/events' + ).andReturn({ + status: 201, + statusText: 'HTTP/1.1 201 Created', + contentType: 'application/json', + responseText: '{"meta":{"message":"Event created"}}' + }); + }; \ No newline at end of file From 95330e1ab237553270373d6149257075b330a5e1 Mon Sep 17 00:00:00 2001 From: Lasse Boisen Andersen Date: Sat, 28 Nov 2015 01:08:21 +0100 Subject: [PATCH 3/3] added basic test for closing booking page --- test/basicInteractions.spec.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/basicInteractions.spec.js b/test/basicInteractions.spec.js index 5bfc8c73..a0c5fdaf 100644 --- a/test/basicInteractions.spec.js +++ b/test/basicInteractions.spec.js @@ -47,6 +47,33 @@ describe('Basic interaction', function() { }); + it('should be able to close the booking page', function(done) { + + createWidget(); + + setTimeout(function() { + + interact.clickEvent(); + + setTimeout(function() { + + expect($('.bookingjs-bookpage')).toBeInDOM(); + expect($('.bookingjs-bookpage')).toBeVisible(); + + $('.bookingjs-bookpage-close').click(); + + setTimeout(function() { + + expect($('.bookingjs-bookpage').length).toBe(0); + + done(); + + }, 500); + }, 500); + }, 500); + + }); + it('should be able to book an event', function(done) { createWidget(); @@ -79,7 +106,7 @@ describe('Basic interaction', function() { done(); - }, 100); + }, 200); }, 500); }, 500);