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

Commit

Permalink
Merge pull request #389 from mridgway/acTests
Browse files Browse the repository at this point in the history
Finished up porting ac addon tests to Arrow
  • Loading branch information
mridgway committed Aug 15, 2012
2 parents e821655 + 669bb3f commit 8b0904d
Show file tree
Hide file tree
Showing 19 changed files with 2,185 additions and 93 deletions.
3 changes: 2 additions & 1 deletion source/lib/app/addons/ac/output-adapter.common.js
Expand Up @@ -352,5 +352,6 @@ YUI.add('mojito-output-adapter-addon', function(Y, NAME) {
'json-stringify',
'event-custom-base',
'mojito-view-renderer',
'mojito-util'
'mojito-util',
'mojito-perf'
]});
2 changes: 1 addition & 1 deletion source/lib/app/addons/ac/url.common.js
Expand Up @@ -126,7 +126,7 @@ YUI.add('mojito-url-addon', function(Y, NAME) {
Y.namespace('mojito.addons.ac').url = UrlAcAddon;

}, '0.1.0', {requires: [
'querystring-stringify-simple',
'querystring',
'mojito-route-maker',
'mojito-util'
]});
3 changes: 2 additions & 1 deletion source/lib/app/autoload/action-context.common.js
Expand Up @@ -333,5 +333,6 @@ YUI.add('mojito-action-context', function(Y, NAME) {
'mojito-assets-addon',
'mojito-cookie-addon',
'mojito-params-addon',
'mojito-composite-addon'
'mojito-composite-addon',
'mojito-perf'
]});
118 changes: 47 additions & 71 deletions tests/base/mojito-test.js
Expand Up @@ -12,83 +12,59 @@
/*
* Baseline Mojito client testing harness.
*/

/*
*/
YUI.add('mojito', function(Y, NAME) {
Y.namespace('mojito');
Y.namespace('mojito.addons.ac');
});

/*
*/
YUI.add('mojito-meta-addon', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-composite-addon', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-params-addon', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-config-addon', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-http-addon', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-client-store', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-dispatcher', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-loader', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-logger', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-mojit-proxy', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-output-handler', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-resource-store-adapter', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-route-maker', function(Y, NAME) {
});

/*
*/
YUI.add('mojito-tunnel-client', function(Y, NAME) {
/* AC ADDONS */
YUI.add('mojito-analytics-addon', function(Y, NAME) {});
YUI.add('mojito-assets-addon', function(Y, NAME) {});
YUI.add('mojito-carrier-addon', function(Y, NAME) {});
YUI.add('mojito-composite-addon', function(Y, NAME) {});
YUI.add('mojito-config-addon', function(Y, NAME) {});
YUI.add('mojito-cookie-addon', function(Y, NAME) {});
YUI.add('mojito-deploy-addon', function(Y, NAME) {});
YUI.add('mojito-device-addon', function(Y, NAME) {});
YUI.add('mojito-http-addon', function(Y, NAME) {});
YUI.add('mojito-i13n-addon', function(Y, NAME) {});
YUI.add('mojito-intl-addon', function(Y, NAME) {});
YUI.add('mojito-meta-addon', function(Y, NAME) {});
YUI.add('mojito-output-adapter-addon', function(Y, NAME) {});
YUI.add('mojito-params-addon', function(Y, NAME) {});
YUI.add('mojito-partial-addon', function(Y, NAME) {});
YUI.add('mojito-url-addon', function(Y, NAME) {});

/* RS ADDONS */
YUI.add('addon-rs-config', function(Y, NAME) {});
YUI.add('addon-rs-selector', function(Y, NAME) {});
YUI.add('addon-rs-url', function(Y, NAME) {});
YUI.add('addon-rs-yui', function(Y, NAME) {});

/* VIEW ENGINE ADDONS */
YUI.add('mojito-hb', function(Y, NAME) {});
YUI.add('mojito-mu', function(Y, NAME) {});

/* AUTOLOAD */
YUI.add('mojito-action-context', function(Y, NAME) {});
YUI.add('mojito-controller-context', function(Y, NAME) {});
YUI.add('mojito-dispatcher', function(Y, NAME) {});
YUI.add('mojito-loader', function(Y, NAME) {});
YUI.add('mojito-logger', function(Y, NAME) {});
YUI.add('mojito-mojit-proxy', function(Y, NAME) {});
YUI.add('mojito-output-handler', function(Y, NAME) {});
YUI.add('mojito-perf', function(Y, NAME) {
Y.namespace('mojito').perf = {
mark: function () {}
};
});
YUI.add('mojito-resource-store-adapter', function(Y, NAME) {});
YUI.add('mojito-rest-lib', function(Y, NAME) {});
YUI.add('mojito-route-maker', function(Y, NAME) {});
YUI.add('mojito-client-store', function(Y, NAME) {});
YUI.add('mojito-tunnel-client', function(Y, NAME) {});
YUI.add('mojito-util', function(Y, NAME) {});
YUI.add('mojito-view-renderer', function(Y, NAME) {});

/*
* Add a mojito-test module containing the mocking support we want for other
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/app/addons/ac/test-assets.common.js
Expand Up @@ -8,7 +8,7 @@
/*jslint anon:true, sloppy:true, nomen:true, node:true*/
/*global YUI*/

YUI().use('mojito-assets-addon', 'test', function(Y, NAME) {
YUI().use('mojito-assets-addon', 'test', 'array-extras', function(Y, NAME) {

var suite = new Y.Test.Suite('mojito-assets-addon tests'),
cases = {},
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/lib/app/addons/ac/test-deploy.server.js
Expand Up @@ -8,7 +8,7 @@
javascript error: require is not defined at 17, url: http://localhost:4459/arrow/static/Users/isao/Repos/mojito/myfork/source/lib/app/addons/ac/deploy.server.js
*/
YUI().use('mojito-deploy-addon', 'test', function(Y) {
YUI().use('mojito-deploy-addon', 'test', 'json-parse', function(Y) {
var suite = new Y.Test.Suite('mojito-deploy-addon tests'),
cases = {},
A = Y.Assert,
Expand All @@ -26,7 +26,7 @@ YUI().use('mojito-deploy-addon', 'test', function(Y) {
addon = null;
},

'YUI_config should use application.json yui.config': function() {
'test YUI_config should use application.json yui.config': function() {

var realRouteMaker = Y.mojito.RouteMaker;
Y.mojito.RouteMaker = function() {};
Expand Down Expand Up @@ -99,7 +99,7 @@ YUI().use('mojito-deploy-addon', 'test', function(Y) {
},


'application.json should honor yui.config.fetchCSS=false': function() {
'test application.json should honor yui.config.fetchCSS=false': function() {

var realLoader = Y.mojito.Loader;
Y.mojito.Loader = function () {};
Expand Down
90 changes: 90 additions & 0 deletions tests/unit/lib/app/addons/ac/test-device.server.js
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/

YUI().use('mojito-device-addon', 'test', function (Y) {

/**
* Creates the action context Mock
* */
function getAC() {
var ac = {
http : {
req : {
device : {
get : function () {
this.getCalled = true;
return "iPhone";
}
}
},
getRequest : function () {
return this.req;
}
}
};

return ac;
}

/**
* Creates the command Mock
* */
function getCommand() {
return {
instance : {
config : {
}
}
};
}

var suite = new Y.Test.Suite('mojito-device-addon tests'),
A = Y.Assert,
OA = Y.ObjectAssert,
Mock = Y.Mock;

suite.add(new Y.Test.Case({

name: 'device Add-on',

setUp: function() {
},
tearDown: function() {
},
'test add-on functions' : function () {

var command = getCommand(),
ac = getAC(),
addon = new Y.mojito.addons.ac.device(command, {}, ac);

A.isFunction(addon.get);
A.isFunction(ac.device.get);
},
'test add-on calls get function' : function () {
var command = getCommand(),
ac = getAC(),
addon = new Y.mojito.addons.ac.device(command, {}, ac);

A.areEqual("iPhone", ac.device.get("Make"));
A.isTrue(ac.http.req.device.getCalled);
},
'test add-on is available if catalog is not available' : function () {
var command = getCommand(),
ac = getAC();

// Overwrite the request with the empty object
ac.http.req = {};
var addon = new Y.mojito.addons.ac.device(command, {}, ac);

A.isFunction(addon.get);
A.isFunction(ac.device.get);
A.areEqual(undefined, ac.device.get("Make"));
}
}));

Y.Test.Runner.add(suite);

});

0 comments on commit 8b0904d

Please sign in to comment.