summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js b/www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js
new file mode 100644
index 00000000..b8dce290
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/qunit/smw/data/ext.smw.dataItem.uri.test.js
@@ -0,0 +1,90 @@
+/**
+ * QUnit tests
+ *
+ * @since 1.9
+ *
+ * @file
+ * @ingroup SMW
+ *
+ * @licence GNU GPL v2 or later
+ * @author mwjames
+ */
+( function ( $, mw, smw ) {
+ 'use strict';
+
+ QUnit.module( 'ext.smw.dataItem.uri', QUnit.newMwEnvironment() );
+
+ var pass = 'Passes because ';
+
+ // Data provider
+ var testCases = [
+ { test: [ '' ], expected: [ null, null ] } ,
+ { test: [ 'http://fooBar/test' ], expected: [ 'http://fooBar/test', '<a href=\"http://fooBar/test\">http://fooBar/test</a>' ] }
+ ];
+
+ /**
+ * Test accessibility
+ *
+ * @since: 1.9
+ */
+ QUnit.test( 'instance', function ( assert ) {
+ assert.expect( 1 );
+
+ var result = new smw.dataItem.uri( 'http://foo.com/test/' );
+ assert.ok( result instanceof Object, pass + 'the smw.dataItem.uri instance was accessible' );
+
+ } );
+
+ /**
+ * Test type
+ *
+ * @since: 1.9
+ */
+ QUnit.test( 'getDIType', function ( assert ) {
+ assert.expect( 1 );
+
+ var result = new smw.dataItem.uri( 'http://foo.com/test/' );
+ assert.equal( result.getDIType(), '_uri', pass + 'returned _uri' );
+
+ } );
+
+ /**
+ * Test getUri
+ *
+ * @since: 1.9
+ */
+ QUnit.test( 'getUri', function ( assert ) {
+ assert.expect( 2 );
+
+ var result;
+
+ $.map( testCases, function ( testCase ) {
+ result = new smw.dataItem.uri( testCase.test[0] );
+ assert.equal( result.getUri(), testCase.expected[0] , pass + 'returned ' + testCase.expected[0] );
+ } );
+
+ } );
+
+ /**
+ * Test getHtml
+ *
+ * @since: 1.9
+ */
+ QUnit.test( 'getHtml', function ( assert ) {
+ assert.expect( 4 );
+
+ var result;
+
+ $.map( testCases, function ( testCase ) {
+ result = new smw.dataItem.uri( testCase.test[0] );
+ assert.equal( result.getHtml(), testCase.expected[0] , pass + 'returned ' + testCase.expected[0] );
+ } );
+
+ $.map( testCases, function ( testCase ) {
+ result = new smw.dataItem.uri( testCase.test[0] );
+ assert.equal( result.getHtml( true ), testCase.expected[1] , pass + 'returned ' + testCase.expected[1] );
+ } );
+
+ } );
+
+}( jQuery, mediaWiki, semanticMediaWiki ) );