aboutsummaryrefslogtreecommitdiffstats
path: root/test/caldav/templates
diff options
context:
space:
mode:
Diffstat (limited to 'test/caldav/templates')
-rw-r--r--test/caldav/templates/calendar_data_test.js70
-rw-r--r--test/caldav/templates/calendar_filter_test.js53
2 files changed, 123 insertions, 0 deletions
diff --git a/test/caldav/templates/calendar_data_test.js b/test/caldav/templates/calendar_data_test.js
new file mode 100644
index 0000000..9a21926
--- /dev/null
+++ b/test/caldav/templates/calendar_data_test.js
@@ -0,0 +1,70 @@
+requireRequest();
+testSupport.lib('templates/calendar_data');
+
+suite('caldav/templates/calendar_data', function() {
+ var CalendarData;
+ var Template;
+
+ var subject;
+ var template;
+
+ function select() {
+ subject.select('VTODO', ['DTIME']);
+ subject.select('VTODO', ['NAME', { VTIMEZONE: true }]);
+ subject.select('VEVENT', ['NAME', {
+ 'VALARM': ['NAME']
+ }]);
+ }
+
+ suiteSetup(function() {
+ CalendarData = Caldav.require('templates/calendar_data');
+ Template = Caldav.require('template');
+ });
+
+ setup(function() {
+ subject = new CalendarData();
+ template = new Template('root');
+ });
+
+ test('initialization', function() {
+ assert.deepEqual(subject.struct, {});
+ });
+
+ suite('#render', function() {
+ var output;
+ var expected;
+
+ expected = [
+ '<N0:calendar-data>',
+ '<N0:comp name="VCALENDAR">',
+ '<N0:comp name="VTODO">',
+ '<N0:prop name="DTIME" />',
+ '<N0:prop name="NAME" />',
+ '<N0:comp name="VTIMEZONE" />',
+ '</N0:comp>',
+ '<N0:comp name="VEVENT">',
+ '<N0:prop name="NAME" />',
+ '<N0:comp name="VALARM">',
+ '<N0:prop name="NAME" />',
+ '</N0:comp>',
+ '</N0:comp>',
+ '</N0:comp>',
+ '</N0:calendar-data>'
+ ].join('');
+
+ test('without items', function() {
+ var output = subject.render(template);
+ assert.equal(
+ output,
+ '<N0:calendar-data />'
+ );
+ });
+
+ test('output', function() {
+ select();
+ var output = subject.render(template);
+ assert.equal(output, expected);
+ });
+ });
+
+});
diff --git a/test/caldav/templates/calendar_filter_test.js b/test/caldav/templates/calendar_filter_test.js
new file mode 100644
index 0000000..d9ce2ab
--- /dev/null
+++ b/test/caldav/templates/calendar_filter_test.js
@@ -0,0 +1,53 @@
+requireRequest();
+testSupport.lib('templates/calendar_data');
+testSupport.lib('templates/calendar_filter');
+
+suite('caldav/templates/calendar_filter', function() {
+ var CalendarFilter;
+ var Template;
+
+ var subject;
+ var template;
+
+ function filter() {
+ subject.add('VEVENT', true);
+ }
+
+ suiteSetup(function() {
+ CalendarFilter = Caldav.require('templates/calendar_filter');
+ Template = Caldav.require('template');
+ });
+
+ setup(function() {
+ subject = new CalendarFilter();
+ template = new Template('root');
+ });
+
+ test('initialization', function() {
+ assert.deepEqual(subject.struct, {});
+ });
+
+ suite('#render', function() {
+ var output;
+ var expected;
+
+ expected = [
+ '<N0:filter>',
+ '<N0:comp-filter name="VCALENDAR">',
+ '<N0:comp-filter name="VEVENT" />',
+ '</N0:comp-filter>',
+ '</N0:filter>'
+ ].join('');
+
+ setup(function() {
+ filter();
+ });
+
+ test('output', function() {
+ var output = subject.render(template);
+ assert.equal(output, expected);
+ });
+ });
+
+});
+