All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.buoyant.admin.js.spec.RouterSummarySpec.js Maven / Gradle / Ivy

There is a newer version: 1.7.5
Show newest version
"use strict";

define([
  'jQuery',
  'lodash',
  'src/router_summary',
  'src/metrics_collector',
  'spec/fixtures/metrics',
  'template/compiled_templates'
], function($, _, RouterSummary, MetricsCollector, metricsJson, templates) {
  describe("RouterSummary", function() {
    var $container;
    var $summaryEl;
    var $routerStatsEl;

    var updatedMetrics = _.merge({}, metricsJson, {
      rt: {
        multiplier: {
          "service": {
            "svc": {
              "retries": {
                "total": {
                  "counter": 481
                }
              }
            }
          },
          client: {
            "$/inet/127.1/9030": {
              "retries": {
                "requeues": {
                  "counter": 100
                }
              }
            }
          },
          server: {
            "0.0.0.0/4116": {
              "requests": {
                counter: 1234
              }
            }
          }
        }
      }
    });

    function extractRenderedValue($parent, dataKey) {
      return $($parent.find("div[data-key='" + dataKey + "']")[0]).text().trim();
    }

    beforeEach(function () {
      $container = $("
"); var containers = templates.router_container({ routers: ["multiplier"] }); $container.html(containers); $summaryEl = $($container.find(".summary")[0]); $routerStatsEl = $($container.find(".router-stats")[0]); }); afterEach(function () { $summaryEl.remove(); $summaryEl = null; $routerStatsEl.remove(); $routerStatsEl = null; $container.remove(); $container = null; }); it("updates summary stats correctly", function() { var collector = MetricsCollector(metricsJson); RouterSummary(collector, $summaryEl, $routerStatsEl, "multiplier", null); var summaryStats = $summaryEl.find(".router-summary-stat"); expect(summaryStats.length).toBe(5); expect(extractRenderedValue(summaryStats, "requests")).toBe("0"); expect(extractRenderedValue(summaryStats, "retries")).toBe("0"); collector.__update__(updatedMetrics); summaryStats = $summaryEl.find(".router-summary-stat"); expect(extractRenderedValue(summaryStats, "requests")).toBe("853"); expect(extractRenderedValue(summaryStats, "retries")).toBe("581"); // 481 + 100 }); }); });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy