How to use the wilson/application.any function in wilson

To help you get started, we’ve selected a few wilson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisdickinson / wilson / tests / application.js View on Github external
function(assert) {
        "ApplicationInstance.setupForwardDependencies adds resolver functions to external apps";
        var randomTag = 'random'+Math.random(),
            randomName = 'randomName'+Math.random(),
            externalApps = {};

        externalApps[randomName] = application.any(randomTag);

        var app_dict = {
                'app1':application.app({'provides':[randomTag]}).instantiate('app1')
            },
            externalApps
            ourAppOptions = {
                'external_apps':externalApps,
                'models':{'FakeModel':models.model({'someDep':models.ForeignKey(models.dep(randomName, randomName))})}
            };
            app = application.app(ourAppOptions),
            appInstance = app.instantiate(randomName+Math.random());

        appInstance.setupForwardDependencies(app_dict);

        assert.equal(app_dict.app1.resolvers[randomName].length, 1);
        assert.isInstance(app_dict.app1.resolvers[randomName][0], Function);
github chrisdickinson / wilson / tests / application.js View on Github external
function(assert) {
        "Any returns undefined if the app does not provides the correct tag";
        var randomTag = 'rand-'+Math.random(),
            otherTag = 'otherrand-'+Math.random(),
            mockObject = {
                'app':{
                    'provides':[randomTag],
                }
            };
        assert.strictEqual(undefined, application.any(otherTag)(mockObject));
    },
    function(assert) {
github chrisdickinson / wilson / tests / application.js View on Github external
function(assert) {
        "Selection functions return functions that take application instances";
        var randomTag = 'rand-'+Math.random();
        assert.isInstance(application.any(randomTag), Function);
        assert.isInstance(application.primary(randomTag), Function);
        assert.isInstance(application.specific(randomTag), Function);
    },
    function(assert) {
github chrisdickinson / wilson / tests / application.js View on Github external
function(assert) {
        "ApplicationInstance.resolveAppDependency returns an app out of an object_literal if the matching function okays it";
        var randomTag = 'random'+Math.random(),
            app_dict = {
                'app1':application.app({'provides':[randomTag]}).instantiate('app1')
            },
            appInstance = application.app({}).instantiate(Math.random()),
            result = appInstance.resolveAppDependency(application.any(randomTag), app_dict);
        assert.strictEqual(app_dict.app1, result);
    },
    function(assert) {
github chrisdickinson / wilson / tests / application.js View on Github external
function(assert) {
        "Any returns an app instance if an app provides the correct tag";
        var randomTag = 'rand-'+Math.random(),
            mockObject = {
                'app':{
                    'provides':[randomTag],
                }
            };
        assert.strictEqual(mockObject, application.any(randomTag)(mockObject));
    },
    function(assert) {