]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added better tests for functions to check their results as well as their existence.
authorsecretrobotron <secretrobotron@gmail.com>
Thu, 17 Mar 2011 17:19:38 +0000 (13:19 -0400)
committersecretrobotron <secretrobotron@gmail.com>
Thu, 17 Mar 2011 17:19:38 +0000 (13:19 -0400)
test/butter_test.html

index 29e73c631c1d5c4c2b7bf6b274ba29b9c7e4a4da..1e4c4dc376e1399bb4a1742b25c4943c1e7e020d 100644 (file)
               return Popcorn.getTrackEvents !== undefined;
             }
           },
+          {
+            title: 'Popcorn.getTrackEvents(popcorn) returns correct results',
+            test: function() {
+              var results = Popcorn.getTrackEvents(popcorn);
+              for (var i in results) {
+                if (results[i].start === 1 && results[i].end === 2) {
+                  return true;
+                } //if
+              } //for
+              return false;
+            }
+          },
           {
             title: 'Popcorn.getTrackEvents exists',
             test: function() {
               return popcorn['notValid'] === undefined;
             }
           },
+          {
+            title: 'p[validPluginName] is expected plugin',
+            test: function() {
+              return popcorn['test'] === plugin['test'];
+            }
+          },
           {
             title: 'Popcorn.registry must be a list',
             test: function() {
             }
           },
           {
-            title: 'popcorn.getLastTrackEventId exists',
+            title: 'popcorn.getLastTrackEventId exists and works',
             test: function() {
-              return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object';
+              var exists = popcorn.getLastTrackEventId !== undefined;
+              var works = popcorn.getLastTrackEventId() !== undefined;
+              return exists && works;
             }
           },
           {
-            title: 'popcorn.getTrackEvents exists',
+            title: 'popcorn.getTrackEvents exists and works',
             test: function() {
-              return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object';
+              console.log(popcorn.getTrackEvents());
+              var exists = popcorn.getTrackEvents !== undefined;
+              var works = popcorn.getTrackEvents();
+              return exists && works;
             }
           },
           {
-            title: 'popcorn.removeTrackEvent exists',
+            title: 'popcorn.getTrackEvents === Popcorn.getTrackEvents(popcorn)',
             test: function() {
-              return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object';
+              console.log(popcorn.getTrackEvents());
+              var exists = popcorn.getTrackEvents !== undefined;
+              var tracks1 = popcorn.getTrackEvents();
+              var tracks2 = Popcorn.getTrackEvents(popcorn);
+              var works = tracks1.length === tracks2.length && tracks1[0] === tracks2[0];
+              return exists && works;
             }
           },
           {
-            title: 'popcorn.listen exists',
+            title: 'popcorn.listen exists && works',
             test: function() {
-              return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object';
+              var exists = popcorn.listen !== undefined;
+              popcorn.listen('ended', function(){});
+              for (var i in popcorn.data.events['ended']) {
+                return exists && true;
+              } //for
+              return false;
+            }
+          },
+          {
+            title: 'popcorn.removeTrackEvent exists and works',
+            test: function() {
+              var exists = popcorn.removeTrackEvent !== undefined;
+              popcorn.removeTrackEvent(popcorn.getLastTrackEventId());
+              var works = popcorn.getTrackEvents().length === 0;
+              return exists && works;
             }
           },
         ];