Permalink
Browse files

Merge branch 'ics-fix' into trunk

  • Loading branch information...
bignall committed Oct 12, 2016
2 parents 1cec616 + cebf106 commit 1222e6257f9d1a683ff51d75101595f0a9e07b29
View
@@ -173,13 +173,14 @@ addtocalendar
}
function buildUrl() {
var urlData = angular.extend(getSanitizedData(), dates);
var urlData = angular.extend(getSanitizedData(), dates),
icsData = angular.extend({}, $scope, dates);
$scope.calendarUrl = {
microsoft: getMicrosoftCalendarUrl(urlData),
google: getGoogleCalendarUrl(urlData),
yahoo: getYahooCalendarUrl(urlData),
icalendar: getIcsCalendar($scope),
icalendar: getIcsCalendar(icsData),
dlIcal: dlIcal
};
}
@@ -192,8 +193,8 @@ addtocalendar
}
function init() {
buildUrl();
setTimesFromFormat();
buildUrl();
}
forEachAttr($attrs, function(key) {
@@ -250,7 +251,8 @@ addtocalendar
className: '@',
btnText: '@',
caret: '@',
hoverText: '@'
hoverText: '@',
format: '@'
},
controller: 'AddtocalendarCtrl',
template: resolveTemplate
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -33,13 +33,14 @@ addtocalendar
}
function buildUrl() {
var urlData = angular.extend(getSanitizedData(), dates);
var urlData = angular.extend(getSanitizedData(), dates),
icsData = angular.extend({}, $scope, dates);
$scope.calendarUrl = {
microsoft: getMicrosoftCalendarUrl(urlData),
google: getGoogleCalendarUrl(urlData),
yahoo: getYahooCalendarUrl(urlData),
icalendar: getIcsCalendar($scope),
icalendar: getIcsCalendar(icsData),
dlIcal: dlIcal
};
}
@@ -52,8 +53,8 @@ addtocalendar
}
function init() {
buildUrl();
setTimesFromFormat();
buildUrl();
}
forEachAttr($attrs, function(key) {
@@ -47,7 +47,8 @@ addtocalendar
className: '@',
btnText: '@',
caret: '@',
hoverText: '@'
hoverText: '@',
format: '@'
},
controller: 'AddtocalendarCtrl',
template: resolveTemplate
View
@@ -17,114 +17,119 @@ describe('AddtocalendarCtrl', function() {
FileSaver = _FileSaver_;
}));
/**
* Yahoo! Calendar
*/
describe('$scope.calendarUrl.yahoo', function() {
it('should return the url to add event to a yahoo calendar', function() {
var $scope = sampleEventFixture;
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
var regex = CalendarRegex.getUrlRegex('calendar.yahoo.com/', {
v: 60,
view: 'd',
type: 20,
TITLE: '(.*)',
ST: CalendarRegex.dateRegex,
DUR: CalendarRegex.militaryHoursRegex,
DESC: '(.*)',
in_loc: '(.*)'
Object.keys(eventFixtures).forEach(function (scope) {
/**
* Yahoo! Calendar
*/
describe('$scope.calendarUrl.yahoo ' + scope, function() {
it('should return the url to add event to a yahoo calendar', function() {
var $scope = eventFixtures[scope];
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
var regex = CalendarRegex.getUrlRegex('calendar.yahoo.com/', {
v: 60,
view: 'd',
type: 20,
TITLE: '(.*)',
ST: CalendarRegex.dateRegex,
DUR: CalendarRegex.militaryHoursRegex,
DESC: '(.*)',
in_loc: '(.*)'
});
var isValidYahooCalendar = regex.test($scope.calendarUrl.yahoo);
expect(isValidYahooCalendar).toEqual(true);
});
var isValidYahooCalendar = regex.test($scope.calendarUrl.yahoo);
expect(isValidYahooCalendar).toEqual(true);
});
});
/**
* Google Calendar
*/
describe('$scope.calendarUrl.google', function() {
var $scope = sampleEventFixture;
it('should return the url to add event to a google calendar', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
});
var regex = CalendarRegex.getUrlRegex('www.google.com/calendar/render', {
action: 'TEMPLATE',
text: '(.*)',
dates: CalendarRegex.dateRegex + '\\/' + CalendarRegex.dateRegex,
details: '(.*)',
location: '(.*)'
/**
* Google Calendar
*/
describe('$scope.calendarUrl.google ' + scope, function() {
var $scope = eventFixtures[scope];
it('should return the url to add event to a google calendar', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
var regex = CalendarRegex.getUrlRegex('www.google.com/calendar/render', {
action: 'TEMPLATE',
text: '(.*)',
dates: CalendarRegex.dateRegex + '\\/' + CalendarRegex.dateRegex,
details: '(.*)',
location: '(.*)'
});
var isValidGoogleCalendar = regex.test($scope.calendarUrl.google);
expect(isValidGoogleCalendar).toEqual(true);
});
var isValidGoogleCalendar = regex.test($scope.calendarUrl.google);
expect(isValidGoogleCalendar).toEqual(true);
});
});
/**
* Windows Live Calendar
*/
describe('$scope.calendarUrl.microsoft', function() {
var $scope = sampleEventFixture;
it('should return the url to add event to a windows live calendar', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
/**
* Windows Live Calendar
*/
describe('$scope.calendarUrl.microsoft ' + scope, function() {
var $scope = eventFixtures[scope];
it('should return the url to add event to a windows live calendar', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
var regex = CalendarRegex.getUrlRegex('calendar.live.com/calendar/calendar.aspx', {
rru: 'addevent',
summary: '(.*)',
dtstart: CalendarRegex.dateRegex,
dtend: CalendarRegex.dateRegex,
description: '(.*)',
location: '(.*)'
});
var isValidMicrosoftCalendar = regex.test($scope.calendarUrl.microsoft);
expect(isValidMicrosoftCalendar).toEqual(true);
});
var regex = CalendarRegex.getUrlRegex('calendar.live.com/calendar/calendar.aspx', {
rru: 'addevent',
summary: '(.*)',
dtstart: CalendarRegex.dateRegex,
dtend: CalendarRegex.dateRegex,
description: '(.*)',
location: '(.*)'
});
var isValidMicrosoftCalendar = regex.test($scope.calendarUrl.microsoft);
expect(isValidMicrosoftCalendar).toEqual(true);
});
});
/**
* iCalendar/Outlook
*/
describe('$scope.calendarUrl.icalendar ' + scope, function() {
var $scope = eventFixtures[scope];
/**
* iCalendar/Outlook
*/
describe('$scope.calendarUrl.icalendar', function() {
var $scope = sampleEventFixture;
it('should return the url and data of an icalendar file', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
it('should return the url and data of an icalendar file', function() {
$controller('AddtocalendarCtrl', {
$scope: $scope,
$attrs: {}
});
var regex = CalendarRegex.getIcsCalendarRegex();
var regex = CalendarRegex.getIcsCalendarRegex();
sinon.stub(FileSaver, 'saveAs');
sinon.stub(FileSaver, 'saveAs');
$scope.calendarUrl.dlIcal();
sinon.spy();
var isValidICalendar = regex.test($scope.calendarUrl.icalendar);
$scope.calendarUrl.dlIcal();
sinon.spy();
var isValidICalendar = regex.test($scope.calendarUrl.icalendar);
expect(isValidICalendar).toEqual(true);
});
expect(isValidICalendar).toEqual(true);
});
});
});
@@ -2,10 +2,21 @@
* angular-addtocalendar
* An AngularJS directive for adding an event to calendar apps.
*/
var sampleEventFixture = {
startDate: '20150704T190000',
endDate: '20150704T210000',
title: 'A sample event!',
description: 'Some interesting description here.',
location: '1 Futurama Pl, New New York'
};
var eventFixtures = {
sampleEventFixture: {
startDate: '20150704T190000',
endDate: '20150704T210000',
title: 'A sample event!',
description: 'Some interesting description here.',
location: '1 Futurama Pl, New New York'
},
alternateFormatFixture: {
startDate: '01/01/2016',
endDate: '01/01/2016',
format: 'MM/DD/YYYY',
title: 'An alternate format event',
description: 'something happening',
location: 'Somewhere out there'
}
};

0 comments on commit 1222e62

Please sign in to comment.