mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Merge autoland to mozilla-central a=merge
This commit is contained in:
commit
26b1c19df1
@ -1,102 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* eslint-env node, mocha */
|
||||
|
||||
"use strict";
|
||||
|
||||
const expect = require("expect");
|
||||
const { mount } = require("enzyme");
|
||||
const { createFactory } = require("devtools/client/shared/vendor/react");
|
||||
const { configureStore } = require("devtools/client/netmonitor/store");
|
||||
const Provider = createFactory(require("devtools/client/shared/vendor/react-redux").Provider);
|
||||
const Actions = require("devtools/client/netmonitor/actions/index");
|
||||
const FilterButtons = createFactory(require("devtools/client/netmonitor/components/filter-buttons"));
|
||||
|
||||
const expectDefaultTypes = {
|
||||
all: true,
|
||||
html: false,
|
||||
css: false,
|
||||
js: false,
|
||||
xhr: false,
|
||||
fonts: false,
|
||||
images: false,
|
||||
media: false,
|
||||
flash: false,
|
||||
ws: false,
|
||||
other: false,
|
||||
};
|
||||
|
||||
// unit test
|
||||
describe("FilterButtons component:", () => {
|
||||
const store = configureStore();
|
||||
const wrapper = mount(FilterButtons({ store }));
|
||||
|
||||
asExpected(wrapper, expectDefaultTypes, "by default");
|
||||
});
|
||||
|
||||
// integration test with redux store, action, reducer
|
||||
describe("FilterButtons::enableFilterOnly:", () => {
|
||||
const expectXHRTypes = {
|
||||
all: false,
|
||||
html: false,
|
||||
css: false,
|
||||
js: false,
|
||||
xhr: true,
|
||||
fonts: false,
|
||||
images: false,
|
||||
media: false,
|
||||
flash: false,
|
||||
ws: false,
|
||||
other: false,
|
||||
};
|
||||
|
||||
const store = configureStore();
|
||||
const wrapper = mount(Provider(
|
||||
{ store },
|
||||
FilterButtons()
|
||||
));
|
||||
|
||||
store.dispatch(Actions.enableRequestFilterTypeOnly("xhr"));
|
||||
asExpected(wrapper, expectXHRTypes, `when enableFilterOnly("xhr") is called`);
|
||||
});
|
||||
|
||||
// integration test with redux store, action, reducer
|
||||
describe("FilterButtons::toggleFilter:", () => {
|
||||
const expectXHRJSTypes = {
|
||||
all: false,
|
||||
html: false,
|
||||
css: false,
|
||||
js: true,
|
||||
xhr: true,
|
||||
fonts: false,
|
||||
images: false,
|
||||
media: false,
|
||||
flash: false,
|
||||
ws: false,
|
||||
other: false,
|
||||
};
|
||||
|
||||
const store = configureStore();
|
||||
const wrapper = mount(Provider(
|
||||
{ store },
|
||||
FilterButtons()
|
||||
));
|
||||
|
||||
store.dispatch(Actions.toggleRequestFilterType("xhr"));
|
||||
store.dispatch(Actions.toggleRequestFilterType("js"));
|
||||
asExpected(wrapper, expectXHRJSTypes, "when xhr, js is toggled");
|
||||
});
|
||||
|
||||
function asExpected(wrapper, expectTypes, description) {
|
||||
for (let type of Object.keys(expectTypes)) {
|
||||
let checked = expectTypes[type] ? "checked" : "not checked";
|
||||
let className = expectTypes[type] ?
|
||||
"devtools-button checked" : "devtools-button";
|
||||
it(`'${type}' button is ${checked} ${description}`, () => {
|
||||
expect(wrapper.find(`.requests-list-filter-${type}-button`).html())
|
||||
.toBe(`<button class="` + className +
|
||||
`" data-key="${type}">netmonitor.toolbar.filter.${type}</button>`);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { createStore } = require("devtools/client/shared/vendor/redux");
|
||||
|
||||
// Current mockup does not support any middleware
|
||||
module.exports = () => createStore;
|
20
devtools/client/netmonitor/test/fixtures/l10n.js
vendored
20
devtools/client/netmonitor/test/fixtures/l10n.js
vendored
@ -1,20 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// @TODO Load the actual strings from netmonitor.properties instead.
|
||||
class L10n {
|
||||
getStr(str) {
|
||||
switch (str) {
|
||||
default:
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
getFormatStr(str) {
|
||||
return this.getStr(str);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = L10n;
|
@ -1,10 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const LocalizationHelper = require("devtools/client/netmonitor/test/fixtures/l10n");
|
||||
|
||||
module.exports = {
|
||||
LocalizationHelper
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const requireHacker = require("require-hacker");
|
||||
|
||||
requireHacker.global_hook("default", path => {
|
||||
switch (path) {
|
||||
// For Enzyme
|
||||
case "react-dom":
|
||||
return `const React = require('devtools/client/shared/vendor/react-dev'); module.exports = React`;
|
||||
case "react-dom/server":
|
||||
return `const React = require('devtools/client/shared/vendor/react-dev'); module.exports = React`;
|
||||
case "react-addons-test-utils":
|
||||
return `const TestUtils = require('devtools/client/shared/vendor/react-dom-test-utils'); module.exports = TestUtils`;
|
||||
// Use react-dev. This would be handled by browserLoader in Firefox.
|
||||
case "react":
|
||||
case "devtools/client/shared/vendor/react":
|
||||
return `const React = require('devtools/client/shared/vendor/react-dev'); module.exports = React`;
|
||||
// For Rep's use of AMD
|
||||
case "devtools/client/shared/vendor/react.default":
|
||||
return `const React = require('devtools/client/shared/vendor/react-dev'); module.exports = React`;
|
||||
}
|
||||
|
||||
// Some modules depend on Chrome APIs which don't work in mocha. When such a module
|
||||
// is required, replace it with a mock version.
|
||||
switch (path) {
|
||||
case "devtools/shared/l10n":
|
||||
return `module.exports = require("devtools/client/netmonitor/test/fixtures/localization-helper")`;
|
||||
case "devtools/client/shared/redux/create-store":
|
||||
return `module.exports = require("devtools/client/netmonitor/test/fixtures/create-store")`;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
Loading…
Reference in New Issue
Block a user