/**
 * menu.js shall not be called directly.  xxxMenu.js files shall require this file
 * to extend each particular menu's functionality
 *
 * e.g.
 * ```js
 * module.exports = function(client, config) {
 *     return require('./menu.js')(client, config, menuMap);
 * };
 */

"use strict";
module.exports = function(client, config, menuMap) {
    var me = {};

    // put menuMap in public scope
    me.menuMap = menuMap;

    me.findLink = function(text) {
        var findTextRecursive = function(obj) {
            var children;
            if (obj.text === text) {
                return true;
            }
            if (obj.children) {
                return obj.children.some(findTextRecursive);
            }
            return false;
        };
        return menuMap.filter(findTextRecursive);
    };

    me.clickNested = function(text, done) {
        // Get top level menu item
        var parent = me.findLink(text)[0];
        // Ensure that top level menu item can be located
        if (!parent) {
            throw new Error('could not locate menu item with text `' + text + '`.  Was it added to the menu map file?');
        }

        // hover over top level menu item before clicking on child
        return client.moveToObject('=' + parent.text, 10, 10)
            .click('=' + text)
            .waitForPaginationComplete(done);
    };

    return me;
};

@@ -283,16 +283,45 @@
 trict%22;%0A
+%0Avar _ = require('lodash');%0A%0A
 module.e
@@ -876,24 +876,56 @@
 xt, done) %7B%0A
+        done = done %7C%7C _.noop;%0A%0A
         // G
@@ -1363,16 +1363,16 @@
 + text)%0A
-
         
@@ -1402,16 +1402,111 @@
 omplete(
+)%0A            .click('#pageHeader') // Close the menu by clicking the banner%0A            .call(
 done);%0A 

Fix nav menu's `clickNested` clicking bug and callback.