зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1751851 - [devtools] Remove unused getFramework selector. r=bomsy
Only this jest test was using it. The react component is using this one instead: https://searchfox.org/mozilla-central/source/devtools/client/debugger/src/actions/sources/symbols.js#26-28 which depends on tabs reducer's framework attribute, which uses the ast's getSymbols selector: https://searchfox.org/mozilla-central/source/devtools/client/debugger/src/components/shared/SourceIcon.js#44 https://searchfox.org/mozilla-central/source/devtools/client/debugger/src/utils/tabs.js#35-38 Differential Revision: https://phabricator.services.mozilla.com/D136853
This commit is contained in:
Родитель
bab524b387
Коммит
f92cb088f2
|
@ -8,12 +8,11 @@ import {
|
|||
selectors,
|
||||
actions,
|
||||
makeSource,
|
||||
makeOriginalSource,
|
||||
waitForState,
|
||||
} from "../../utils/test-head";
|
||||
|
||||
import readFixture from "./helpers/readFixture";
|
||||
const { getSymbols, isSymbolsLoading, getFramework } = selectors;
|
||||
const { getSymbols, isSymbolsLoading } = selectors;
|
||||
|
||||
const mockCommandClient = {
|
||||
sourceContents: async ({ source }) => ({
|
||||
|
@ -28,16 +27,6 @@ const mockCommandClient = {
|
|||
getSourceActorBreakableLines: async () => [],
|
||||
};
|
||||
|
||||
const sourceMaps = {
|
||||
getOriginalSourceText: async id => ({
|
||||
id,
|
||||
text: sourceTexts[id],
|
||||
contentType: "text/javascript",
|
||||
}),
|
||||
getGeneratedRangesForOriginal: async () => [],
|
||||
getOriginalLocations: async items => items,
|
||||
};
|
||||
|
||||
const sourceTexts = {
|
||||
"base.js": "function base(boo) {}",
|
||||
"foo.js": "function base(boo) { return this.bazz; } outOfScope",
|
||||
|
@ -89,38 +78,5 @@ describe("ast", () => {
|
|||
expect(baseSymbols).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("frameworks", () => {
|
||||
it("should detect react components", async () => {
|
||||
const store = createStore(mockCommandClient, {}, sourceMaps);
|
||||
const { cx, dispatch, getState } = store;
|
||||
|
||||
const genSource = await dispatch(
|
||||
actions.newGeneratedSource(makeSource("reactComponent.js"))
|
||||
);
|
||||
|
||||
const source = await dispatch(
|
||||
actions.newOriginalSource(makeOriginalSource(genSource))
|
||||
);
|
||||
|
||||
await dispatch(actions.loadSourceText({ cx, source }));
|
||||
const loadedSource = selectors.getSourceFromId(getState(), source.id);
|
||||
await dispatch(actions.setSymbols({ cx, source: loadedSource }));
|
||||
|
||||
expect(getFramework(getState(), source)).toBe("React");
|
||||
});
|
||||
|
||||
it("should not give false positive on non react components", async () => {
|
||||
const store = createStore(mockCommandClient);
|
||||
const { cx, dispatch, getState } = store;
|
||||
const base = await dispatch(
|
||||
actions.newGeneratedSource(makeSource("base.js"))
|
||||
);
|
||||
await dispatch(actions.loadSourceText({ cx, source: base }));
|
||||
await dispatch(actions.setSymbols({ cx, source: base }));
|
||||
|
||||
expect(getFramework(getState(), base)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,13 +79,6 @@ export function hasSymbols(state, source) {
|
|||
return !symbols.loading;
|
||||
}
|
||||
|
||||
export function getFramework(state, source) {
|
||||
const symbols = getSymbols(state, source);
|
||||
if (symbols && !symbols.loading) {
|
||||
return symbols.framework;
|
||||
}
|
||||
}
|
||||
|
||||
export function isSymbolsLoading(state, source) {
|
||||
const symbols = getSymbols(state, source);
|
||||
if (!symbols) {
|
||||
|
|
|
@ -21,4 +21,11 @@ add_task(async function() {
|
|||
text: "size: 1",
|
||||
expression: "_this.fields;"
|
||||
});
|
||||
|
||||
info("Verify that the file is flagged as a React module");
|
||||
const sourceTab = findElementWithSelector(dbg, ".source-tab.active");
|
||||
ok(
|
||||
sourceTab.querySelector(".source-icon.react"),
|
||||
"Source tab has a React icon"
|
||||
);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче