summaryrefslogtreecommitdiffstats
path: root/toolkit/components/microformats/test/module-tests/text-test.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/microformats/test/module-tests/text-test.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/microformats/test/module-tests/text-test.js')
-rw-r--r--toolkit/components/microformats/test/module-tests/text-test.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/toolkit/components/microformats/test/module-tests/text-test.js b/toolkit/components/microformats/test/module-tests/text-test.js
new file mode 100644
index 000000000..f1f2e775c
--- /dev/null
+++ b/toolkit/components/microformats/test/module-tests/text-test.js
@@ -0,0 +1,56 @@
+/*
+Unit test for text
+*/
+
+assert = chai.assert;
+
+// Tests the private Modules.text object
+// Modules.text is unit tested as it has an interface access by other modules
+
+
+describe('Modules.text', function() {
+
+
+ it('parse', function(){
+ var html = '\n <a href="http://glennjones.net">Glenn\n Jones \n</a> \n',
+ node = document.createElement('div');
+
+ node.innerHTML = html;
+ assert.equal( Modules.text.parse( document, node, 'whitespacetrimmed' ), 'Glenn\n Jones' );
+ assert.equal( Modules.text.parse( document, node, 'whitespace' ), '\n Glenn\n Jones \n \n' );
+ assert.equal( Modules.text.parse( document, node, 'normalised' ), 'Glenn Jones' );
+
+ // exclude tags
+ node.innerHTML = '<script>test</script>text';
+ assert.equal( Modules.text.parse( document, node, 'normalised' ), 'text' );
+
+ // block level
+ node.innerHTML = '<p>test</p>text';
+ //assert.equal( Modules.text.parse( document, node, 'normalised' ), 'test text' );
+
+ // node with no text data
+ node = document.createComment('test comment');
+ assert.equal( Modules.text.parse( document, node, 'normalised' ), '' );
+
+ });
+
+
+ it('parseText', function(){
+ var text = '\n <a href="http://glennjones.net">Glenn\n Jones \n</a> \n';
+
+ // create DOM context first
+ Modules.domUtils.getDOMContext( {} );
+
+ assert.equal( Modules.text.parseText( document, text, 'whitespacetrimmed' ), 'Glenn\n Jones' );
+ assert.equal( Modules.text.parseText( document, text, 'whitespace' ), '\n Glenn\n Jones \n \n' );
+ assert.equal( Modules.text.parseText( document, text, 'normalised' ), 'Glenn Jones' );
+ });
+
+
+ it('formatText', function(){
+ assert.equal( Modules.text.formatText( document, null, 'whitespacetrimmed' ), '' );
+ });
+
+
+
+});