mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
- mochitest folder is renamed browser. - unit folder is rename xpcshell. - all the file and folder for mocha are put in a node folder. We take this as an opportunity to revist our stub-generating mochitests. Previously we had 2 tests for each kind of stubs, one for check, the other one for updating. It was not ideal when you wanted to update all the stubs at once because you add either to mention every 5 files, or unskip the update test files. We now merge the update and the check files in a single test. By default, the test that the stubs are up to date, and if you pass the --setenv WEBCONSOLE_STUBS_UPDATE=true param, it will update the stubs. This allow us to move the function that actually generate the stub in the test file, and have a helper file for multi-purpose functions. Because these tests are failing on TRY, let's disabled them so we can land the test re-organization (we'll re-enable them in Bug 1572667). Differential Revision: https://phabricator.services.mozilla.com/D41344
59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
"use strict";
|
|
|
|
const { createFactory } = require("devtools/client/shared/vendor/react");
|
|
// Test utils.
|
|
const expect = require("expect");
|
|
const { render } = require("enzyme");
|
|
const Provider = createFactory(require("react-redux").Provider);
|
|
|
|
const ConsoleOutput = createFactory(
|
|
require("devtools/client/webconsole/components/Output/ConsoleOutput")
|
|
);
|
|
const serviceContainer = require("devtools/client/webconsole/test/node/fixtures/serviceContainer");
|
|
const { setupStore } = require("devtools/client/webconsole/test/node/helpers");
|
|
const { initialize } = require("devtools/client/webconsole/actions/ui");
|
|
const {
|
|
getInitialMessageCountForViewport,
|
|
} = require("devtools/client/webconsole/utils/messages.js");
|
|
|
|
const MESSAGES_NUMBER = 100;
|
|
function getDefaultProps(initialized) {
|
|
const store = setupStore(
|
|
Array.from({ length: MESSAGES_NUMBER })
|
|
// Alternate message so we don't trigger the repeat mechanism.
|
|
.map((_, i) => (i % 2 ? "new Date(0)" : "console.log(NaN)"))
|
|
);
|
|
|
|
if (initialized) {
|
|
store.dispatch(initialize());
|
|
}
|
|
|
|
return {
|
|
store,
|
|
serviceContainer,
|
|
};
|
|
}
|
|
|
|
describe("ConsoleOutput component:", () => {
|
|
it("Render only the last messages that fits the viewport when non-initialized", () => {
|
|
// We need to wrap the ConsoleApiElement in a Provider in order for the
|
|
// ObjectInspector to work.
|
|
const rendered = render(
|
|
Provider({ store: setupStore() }, ConsoleOutput(getDefaultProps(false)))
|
|
);
|
|
const messagesNumber = rendered.find(".message").length;
|
|
expect(messagesNumber).toBe(getInitialMessageCountForViewport(window));
|
|
});
|
|
|
|
it("Render every message when initialized", () => {
|
|
// We need to wrap the ConsoleApiElement in a Provider in order for the
|
|
// ObjectInspector to work.
|
|
const rendered = render(
|
|
Provider({ store: setupStore() }, ConsoleOutput(getDefaultProps(true)))
|
|
);
|
|
expect(rendered.find(".message").length).toBe(MESSAGES_NUMBER);
|
|
});
|
|
});
|