Bug 1305788 - Part 2: Remove mocha unit testing of actions. r=me

MozReview-Commit-ID: AGCvvLdztDc
This commit is contained in:
Lin Clark 2016-10-02 15:16:48 -07:00
Родитель 071543fff5
Коммит 92c289047a
5 изменённых файлов: 2 добавлений и 183 удалений

Просмотреть файл

@ -1,54 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const actions = require("devtools/client/webconsole/new-console-output/actions/index");
const {
FILTER_TEXT_SET,
FILTER_TOGGLE,
FILTERS_CLEAR,
MESSAGE_LEVEL
} = require("devtools/client/webconsole/new-console-output/constants");
const expect = require("expect");
describe("Filter actions:", () => {
describe("filterTextSet", () => {
it("creates expected action", () => {
const action = actions.filterTextSet("test");
const expected = {
type: FILTER_TEXT_SET,
text: "test"
};
expect(action).toEqual(expected);
});
});
describe("filterToggle", () => {
it("creates expected action", () => {
const action = actions.filterToggle(MESSAGE_LEVEL.ERROR);
const expected = {
type: FILTER_TOGGLE,
filter: "error"
};
expect(action).toEqual(expected);
});
});
describe("filterTextApply", () => {
});
describe("filtersClear", () => {
it("creates expected action", () => {
const action = actions.filtersClear();
const expected = {
type: FILTERS_CLEAR
};
expect(action).toEqual(expected);
});
});
});

Просмотреть файл

@ -1,88 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { thunk } = require("devtools/client/shared/redux/middleware/thunk");
const configureStore = require("redux-mock-store").default;
const { getRepeatId } = require("devtools/client/webconsole/new-console-output/utils/messages");
const { stubPackets, stubPreparedMessages } = require("devtools/client/webconsole/new-console-output/test/fixtures/stubs/index");
const { setupActions } = require("devtools/client/webconsole/new-console-output/test/helpers");
const constants = require("devtools/client/webconsole/new-console-output/constants");
const mockStore = configureStore([ thunk ]);
const expect = require("expect");
let actions;
describe("Message actions:", () => {
beforeEach(()=>{
actions = setupActions();
});
describe("messageAdd", () => {
it("dispatches expected action given a packet", () => {
const packet = stubPackets.get("console.log('foobar', 'test')");
const store = mockStore({});
store.dispatch(actions.messageAdd(packet));
const actualActions = store.getActions();
expect(actualActions.length).toEqual(1);
const addAction = actualActions[0];
const {message} = addAction;
const expectedAction = {
type: constants.MESSAGE_ADD,
message: stubPreparedMessages.get("console.log('foobar', 'test')")
};
expect(message.toJS()).toEqual(expectedAction.message.toJS());
});
it("dispatches expected actions given a console.clear packet", () => {
const packet = stubPackets.get("console.clear()");
const store = mockStore({});
store.dispatch(actions.messageAdd(packet));
const actualActions = store.getActions();
expect(actualActions.length).toEqual(1);
const [clearAction, addAction] = actualActions[0].actions;
expect(clearAction.type).toEqual(constants.MESSAGES_CLEAR);
const {message} = addAction;
const expectedAction = {
type: constants.MESSAGE_ADD,
message: stubPreparedMessages.get("console.clear()")
};
expect(addAction.type).toEqual(constants.MESSAGE_ADD);
expect(message.toJS()).toEqual(expectedAction.message.toJS());
});
it("dispatches expected action given a console.table packet", () => {
const packet = stubPackets.get("console.table(['a', 'b', 'c'])");
const store = mockStore({});
store.dispatch(actions.messageAdd(packet));
const expectedActions = store.getActions();
expect(expectedActions.length).toEqual(1);
const addAction = expectedActions[0];
const {message} = addAction;
const expected = {
type: constants.MESSAGE_ADD,
message: stubPreparedMessages.get("console.table(['a', 'b', 'c'])")
};
expect(message.toJS()).toEqual(expected.message.toJS());
});
});
describe("messagesClear", () => {
it("creates expected action", () => {
const action = actions.messagesClear();
const expected = {
type: constants.MESSAGES_CLEAR,
};
expect(action).toEqual(expected);
});
});
});

Просмотреть файл

@ -1,23 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const actions = require("devtools/client/webconsole/new-console-output/actions/index");
const {
FILTER_BAR_TOGGLE
} = require("devtools/client/webconsole/new-console-output/constants");
const expect = require("expect");
describe("UI actions:", () => {
describe("filterBarToggle", () => {
it("creates expected action", () => {
const action = actions.filterBarToggle();
const expected = {
type: FILTER_BAR_TOGGLE
};
expect(action).toEqual(expected);
});
});
});

Просмотреть файл

@ -3,23 +3,18 @@
"use strict"; "use strict";
const expect = require("expect"); const expect = require("expect");
const sinon = require("sinon"); const { render } = require("enzyme");
const { render, shallow } = require("enzyme");
const { createFactory } = require("devtools/client/shared/vendor/react"); const { createFactory } = require("devtools/client/shared/vendor/react");
const FilterButton = createFactory(require("devtools/client/webconsole/new-console-output/components/filter-button").FilterButton); const FilterButton = createFactory(require("devtools/client/webconsole/new-console-output/components/filter-button").FilterButton);
const { const { MESSAGE_LEVEL } = require("devtools/client/webconsole/new-console-output/constants");
FILTER_TOGGLE,
MESSAGE_LEVEL
} = require("devtools/client/webconsole/new-console-output/constants");
describe("FilterButton component:", () => { describe("FilterButton component:", () => {
const props = { const props = {
active: true, active: true,
label: "Error", label: "Error",
filterKey: MESSAGE_LEVEL.ERROR, filterKey: MESSAGE_LEVEL.ERROR,
dispatch: sinon.spy()
}; };
it("displays as active when turned on", () => { it("displays as active when turned on", () => {
@ -36,14 +31,4 @@ describe("FilterButton component:", () => {
"<button class=\"menu-filter-button\">Error</button>" "<button class=\"menu-filter-button\">Error</button>"
); );
}); });
it("fires FILTER_TOGGLE action when clicked", () => {
const wrapper = shallow(FilterButton(props));
wrapper.find("button").simulate("click");
const call = props.dispatch.getCall(0);
expect(call.args[0]).toEqual({
type: FILTER_TOGGLE,
filter: MESSAGE_LEVEL.ERROR
});
});
}); });

Просмотреть файл

@ -10,7 +10,6 @@
"jsdom": "^9.4.1", "jsdom": "^9.4.1",
"jsdom-global": "^2.0.0", "jsdom-global": "^2.0.0",
"mocha": "^2.5.3", "mocha": "^2.5.3",
"redux-mock-store": "^1.1.4",
"require-hacker": "^2.1.4", "require-hacker": "^2.1.4",
"sinon": "^1.17.5" "sinon": "^1.17.5"
}, },