devtools/client/webconsole/new-console-output/test/components/test_evaluation-result.html
author Lin Clark <lclark@mozilla.com>
Tue, 26 Jul 2016 12:35:42 -0400
changeset 309155 568a9228a15209e3db9970bb6e822050c8e8ce19
parent 304591 5b767b7a32d4090e16bee287de2ed73fe910a7b0
permissions -rw-r--r--
Bug 1289258 - Part 2 - Add mocha test for search. r=bgrins MozReview-Commit-ID: RoAVWKb0qC

<!DOCTYPE HTML>
<html lang="en">
<head>
  <meta charset="utf8">
  <title>Test for EvaluationResult component</title>
  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript;version=1.8" src="head.js"></script>
  <!-- Any copyright is dedicated to the Public Domain.
     - http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p>Test for EvaluationResult component</p>

<script type="text/javascript;version=1.8">
window.onload = Task.async(function* () {
  const { prepareMessage } = require("devtools/client/webconsole/new-console-output/utils/messages");
  const {
    EvaluationResult
  } = require("devtools/client/webconsole/new-console-output/components/message-types/evaluation-result");

  yield testDate();

  SimpleTest.finish()

  /**
   * Test that evaluation result correctly outputs date results.
   */
  function testDate() {
    const testCommand = testCommands.get("new Date()");
    const packet = yield getPacket(testCommand.command, testCommand.commandType);
    const message = prepareMessage(packet);
    const props = {
      message
    };
    const rendered = renderComponent(EvaluationResult, props);

    const queryPathBase = "div.message.cm-s-mozilla span.message-body-wrapper.message-body.devtools-monospace span .objectBox";

    const preview = rendered.querySelectorAll(queryPathBase);
    is(preview[0].textContent, testCommand.expectedText, "EvaluationResult outputs expected text");
  }
});

</script>
</body>
</html>