Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
test to verify ycb accepts falsey config values
Browse files Browse the repository at this point in the history
  • Loading branch information
Isao Yagi committed Apr 26, 2012
1 parent 2935d79 commit ff69faf
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions source/lib/tests/autoload/libs/ycb-tests.js
Expand Up @@ -4,23 +4,23 @@
* See the accompanying LICENSE file for terms.
*/
YUI.add('mojito-ycb-tests', function(Y, NAME) {

var libycb = require(__dirname + '/../../../libs/ycb.js'),
suite = new YUITest.TestSuite(NAME),
A = YUITest.Assert,
OA = YUITest.ObjectAssert,
AA = YUITest.ArrayAssert;

suite.add(new YUITest.TestCase({

name: 'ycb',

setUp: function() {

},

tearDown: function() {

},

'test if we can use the module': function() {
Expand Down Expand Up @@ -49,7 +49,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
flat;

flat = libycb._flattenDimensions(dims[0].dimensions);

//Y.log(JSON.stringify(flat,null,4));

A.isTrue(flat['lang']['en'] === 'en');
Expand Down Expand Up @@ -141,7 +141,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
.concat(readFixtureFile('simple-1.json')[0]);

//Y.log(JSON.stringify(bundle,null,4));

ycb = libycb._processRawBundle(bundle);

//Y.log(JSON.stringify(ycb,null,4));
Expand Down Expand Up @@ -169,7 +169,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
}

//Y.log(JSON.stringify(ycb,null,4));

A.isTrue(false);
},

Expand All @@ -184,7 +184,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
//Y.log(JSON.stringify(bundle,null,4));

ycb = libycb._processRawBundle(bundle);

//Y.log(JSON.stringify(ycb,null,4));

A.isTrue(ycb.settings['*/*/*/*/*/*/*/*/*/*/*'].title_key === 'YRB_YAHOO');
Expand Down Expand Up @@ -224,7 +224,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
ycb = libycb.read(bundle);

//Y.log(JSON.stringify(ycb,null,4));

A.isTrue(ycb.title_key === 'YRB_YAHOO');
A.isTrue(ycb.links.home === 'http://www.yahoo.com');
A.isTrue(ycb.links.mail === 'http://mail.yahoo.com');
Expand Down Expand Up @@ -327,6 +327,36 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {
A.isTrue(ycb.logo === 'yahoo_bt_GB.png');
A.isTrue(ycb.links.home === 'http://gb.yahoo.com');
A.isTrue(ycb.links.mail === 'http://gb.mail.yahoo.com');
},

'test ycb accepts falsey config values': function() {
var bundle,
ycb,
foo = {
settings: [ 'master' ],
title_key: 'YRB_YAHOO',
'data-url': 'http://service.yahoo.com',
logo: 'yahoo.png',
false_ok: false,
zero: 0,
undef: undefined,
links: { home: 'http://www.yahoo.com', mail: 'http://mail.yahoo.com' }
};

bundle = readFixtureFile('dimensions.json').concat([foo]);

ycb = libycb.read(bundle);

A.areEqual(ycb['data-url'], foo['data-url']);

A.isTrue('false_ok' in ycb);
A.areEqual(ycb.false_ok, foo.false_ok);

A.isTrue('undef' in ycb);
A.areEqual(ycb.undef, foo.undef);

A.isTrue('zero' in ycb);
A.areEqual(ycb.zero, foo.zero);
}

}));
Expand All @@ -338,7 +368,7 @@ YUI.add('mojito-ycb-tests', function(Y, NAME) {

return JSON.parse(data);
}

YUITest.TestRunner.add(suite);

}, '0.0.1', {requires: []});

0 comments on commit ff69faf

Please sign in to comment.