Skip to content

Commit

Permalink
Add assert.expect calls to all QUnit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianheine committed Jan 7, 2016
1 parent b11215f commit d50da58
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 57 deletions.
2 changes: 2 additions & 0 deletions tests/lib/globeCoordinate/globeCoordinate.Formatter.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define( [
QUnit.module( 'globeCoordinate.Formatter.js' );

QUnit.test( 'Formatting', function( assert ) {
assert.expect( 8 );
var decimalTexts = {
'1, 1': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),
'-10, -1.5': new GlobeCoordinate( { latitude: -10, longitude: -1.5, precision: 0.1 } ),
Expand Down Expand Up @@ -51,6 +52,7 @@ define( [
} );

QUnit.test( 'precisionText()', function( assert ) {
assert.expect( 4 );
var precisions = {
1: '±1°',
0.016666666666666666: 'to an arcminute',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ define( [
QUnit.module( 'globeCoordinate.GlobeCoordinate.js' );

QUnit.test( 'Basic checks', function( assert ) {
assert.expect( 12 );
var c;

assert.throws(
Expand Down Expand Up @@ -94,6 +95,7 @@ define( [
} );

QUnit.test( 'Strict (in)equality', function( assert ) {
assert.expect( 121 );
var gcDefs = [
{ latitude: 0, longitude: 0, precision: 1 },
{ latitude: -3, longitude: 2, precision: 1 },
Expand Down Expand Up @@ -135,6 +137,7 @@ define( [
} );

QUnit.test( 'Loose equality', function( assert ) {
assert.expect( 7 );
var gcDefs = [
{ latitude: 0, longitude: 0, precision: 1 },
{ latitude: 0.01, longitude: 0, precision: 1 },
Expand All @@ -157,6 +160,7 @@ define( [
} );

QUnit.test( 'Loose inequality', function( assert ) {
assert.expect( 4 );
var c1 = new globeCoordinate.GlobeCoordinate(
{ latitude: 0, longitude: 0, precision: 1 / 3600 }
),
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/globeCoordinate/globeCoordinate.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ define( [
QUnit.module( 'globeCoordinate.js' );

QUnit.test( 'Applying precision', function( assert ) {
assert.expect( 70 );

$.each( precisions, function( precision, expected ) {
$.each( values, function( i, value ) {
Expand All @@ -179,6 +180,7 @@ define( [
} );

QUnit.test( 'Converting to degree', function( assert ) {
assert.expect( 70 );

$.each( precisions, function( precision, expected ) {
$.each( values, function( i, value ) {
Expand All @@ -199,6 +201,7 @@ define( [
} );

QUnit.test( 'iso6709()', function( assert ) {
assert.expect( 10 );

$.each( iso6709representations, function( iso6709string, gcDef ) {
assert.equal(
Expand Down
106 changes: 50 additions & 56 deletions tests/src/dataValues.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,73 +12,67 @@ define( [

QUnit.module( 'dataValues.js' );

QUnit.test(
'getDataValues',
function( assert ) {
var dvs = dv.getDataValues();
QUnit.test( 'getDataValues', function( assert ) {
var dvs = dv.getDataValues();
assert.expect( dvs.length * 2 + 1 );

assert.ok( $.isArray( dvs ), 'Returns an array' );
assert.ok( $.isArray( dvs ), 'Returns an array' );

for ( var i = 0, s = dvs.length; i < s; i++ ) {
assert.ok(
typeof dvs[i] === 'string',
'Returned DV type "' + dvs[i] + '" is a string'
);
for ( var i = 0, s = dvs.length; i < s; i++ ) {
assert.ok(
typeof dvs[i] === 'string',
'Returned DV type "' + dvs[i] + '" is a string'
);

assert.ok(
dv.hasDataValue( dvs[i] ),
'Returned DV type "' + dvs[i] + '" is present according to hasDataValue'
);
}
assert.ok(
dv.hasDataValue( dvs[i] ),
'Returned DV type "' + dvs[i] + '" is present according to hasDataValue'
);
}
);
} );

QUnit.test(
'hasDataValue',
function( assert ) {
// Already partially tested in getDataValues
QUnit.test( 'hasDataValue', function( assert ) {
assert.expect( 2 );
// Already partially tested in getDataValues

assert.strictEqual(
dv.hasDataValue( 'in your code, being silly' ),
false,
'Non existing DV type is not present'
);
assert.strictEqual(
dv.hasDataValue( 'in your code, being silly' ),
false,
'Non existing DV type is not present'
);

var dvs = dv.getDataValues();
var dvs = dv.getDataValues();

assert.strictEqual(
dv.hasDataValue( dvs.pop() ),
true,
'Existing DV type is present'
);
}
);
assert.strictEqual(
dv.hasDataValue( dvs.pop() ),
true,
'Existing DV type is present'
);
} );

QUnit.test(
'newDataValue',
function( assert ) {
// This test needs dv.MonolingualTextValue to be loaded and registered
QUnit.test( 'newDataValue', function( assert ) {
assert.expect( 2 );
// This test needs dv.MonolingualTextValue to be loaded and registered

var dataValue = dv.newDataValue(
'monolingualtext',
{
'language': 'en',
'text': '~=[,,_,,]:3'
}
);
var dataValue = dv.newDataValue(
'monolingualtext',
{
'language': 'en',
'text': '~=[,,_,,]:3'
}
);

assert.strictEqual(
dataValue.getText(),
'~=[,,_,,]:3',
'Value was constructed and the text was set correctly'
);
assert.strictEqual(
dataValue.getText(),
'~=[,,_,,]:3',
'Value was constructed and the text was set correctly'
);

assert.strictEqual(
dataValue.getLanguageCode(),
'en',
'Value was constructed and the language code was set correctly'
);
}
);
assert.strictEqual(
dataValue.getLanguageCode(),
'en',
'Value was constructed and the language code was set correctly'
);
} );

} );
2 changes: 1 addition & 1 deletion tests/src/valueParsers/valueParsers.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@

};

}( valueParsers, dataValues, util, jQuery, QUnit ) );
}( valueParsers, dataValues, util, jQuery, QUnit ) );

0 comments on commit d50da58

Please sign in to comment.