]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add unit tests for escapeHTML
authorLukas Reschke <lukas@statuscode.ch>
Wed, 28 May 2014 20:14:05 +0000 (22:14 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Wed, 28 May 2014 20:14:05 +0000 (22:14 +0200)
core/js/tests/specs/coreSpec.js

index ccd9f7a128898003adb606154b2d88a028ce3724..fb237bad5df759a6d4619e5b69cf88ed22a7d6e4 100644 (file)
@@ -124,6 +124,17 @@ describe('Core base tests', function() {
                        expect(OC.dirname('/subdir/')).toEqual('/subdir');
                });
        });
+       describe('escapeHTML', function() {
+               it('Returns nothing if no string was given', function() {
+                       expect(escapeHTML('')).toEqual('');
+               });
+               it('Returns a sanitized string if a string containing HTML is given', function() {
+                       expect(escapeHTML('There needs to be a <script>alert(\"Unit\" + \'test\')</script> for it!')).toEqual('There needs to be a &lt;script&gt;alert(&quot;Unit&quot; + &#039;test&#039;)&lt;/script&gt; for it!');
+               });
+               it('Returns the string without modification if no potential dangerous character is passed.', function() {
+                       expect(escapeHTML('This is a good string without HTML.')).toEqual('This is a good string without HTML.');
+               });
+       });
        describe('Link functions', function() {
                var TESTAPP = 'testapp';
                var TESTAPP_ROOT = OC.webroot + '/appsx/testapp';