1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* 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.text', QUnit.newMwEnvironment() );
var pass = 'Passes because ';
/**
* Test accessibility
*
* @since: 1.9
*/
QUnit.test( 'instance', 4, function ( assert ) {
var result = new smw.dataItem.text( 'foo' );
assert.ok( result instanceof Object, pass + 'the smw.dataItem.text instance was accessible' );
QUnit.raises( function() {
new smw.dataItem.text( {} );
}, pass + 'an error was raised due to the wrong type' );
QUnit.raises( function() {
new smw.dataItem.text( [] );
}, pass + 'an error was raised due to the wrong type' );
QUnit.raises( function() {
new smw.dataItem.text( 3 );
}, pass + 'an error was raised due to the wrong type' );
} );
/**
* Test type
*
* @since: 1.9
*/
QUnit.test( 'getDIType', 2, function ( assert ) {
var result;
result = new smw.dataItem.text( 'foo' );
assert.equal( result.getDIType(), '_txt', pass + 'getDIType() returned _txt' );
result = new smw.dataItem.text( 'bar', '_str' );
assert.equal( result.getDIType(), '_str', pass + 'getDIType() returned _str' );
} );
/**
* Test getText
*
* @since: 1.9
*/
QUnit.test( 'getText', 2, function ( assert ) {
var result;
var testString = 'Lorem ipsum dolor sit ...';
result = new smw.dataItem.text( testString );
assert.equal( result.getText(), testString, pass + 'getText() returned ' + testString );
assert.equal( result.getString(), testString, pass + 'getString() returned ' + testString );
} );
}( jQuery, mediaWiki, semanticMediaWiki ) );
|