improved reindexing to reindex in background
new button to cleanup gravity
This commit is contained in:
@ -22,15 +22,33 @@ describe('<MovieSettings/>', function () {
|
||||
});
|
||||
|
||||
it('test simulate reindex', function () {
|
||||
global.fetch = global.prepareFetchApi({});
|
||||
global.fetch = global.prepareFetchApi({success: true});
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
|
||||
wrapper.find(".reindexbtn").simulate("click");
|
||||
wrapper.find("button").findWhere(e => e.text() === "Reindex Movie" && e.type() === "button").simulate("click");
|
||||
|
||||
// initial send of reindex request to server
|
||||
expect(global.fetch).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test failing reindex start', done => {
|
||||
global.fetch = global.prepareFetchApi({success: false});
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
|
||||
wrapper.find("button").findWhere(e => e.text() === "Reindex Movie" && e.type() === "button").simulate("click");
|
||||
|
||||
// initial send of reindex request to server
|
||||
expect(global.fetch).toBeCalledTimes(1);
|
||||
|
||||
process.nextTick(() => {
|
||||
// reindex already running --> so disable startbdn
|
||||
expect(wrapper.state()).toMatchObject({startbtnDisabled: true});
|
||||
|
||||
global.fetch.mockClear();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('content available received and in state', done => {
|
||||
global.fetch = global.prepareFetchApi({
|
||||
contentAvailable: true,
|
||||
@ -51,4 +69,44 @@ describe('<MovieSettings/>', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('test reindex with no content available', done=> {
|
||||
global.fetch = global.prepareFetchApi({
|
||||
contentAvailable: false
|
||||
});
|
||||
|
||||
global.clearInterval = jest.fn();
|
||||
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
wrapper.instance().updateStatus();
|
||||
|
||||
process.nextTick(() => {
|
||||
// expect the refresh interval to be cleared
|
||||
expect(global.clearInterval).toBeCalledTimes(1);
|
||||
|
||||
// expect startbtn to be reenabled
|
||||
expect(wrapper.state()).toMatchObject({startbtnDisabled: false});
|
||||
|
||||
global.fetch.mockClear();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('test simulate gravity cleanup', done => {
|
||||
global.fetch = global.prepareFetchApi("mmi");
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
wrapper.instance().setState = jest.fn(),
|
||||
|
||||
wrapper.find("button").findWhere(e => e.text() === "Cleanup Gravity" && e.type() === "button").simulate("click");
|
||||
|
||||
// initial send of reindex request to server
|
||||
expect(global.fetch).toBeCalledTimes(1);
|
||||
|
||||
process.nextTick(() => {
|
||||
expect(wrapper.instance().setState).toBeCalledTimes(1);
|
||||
|
||||
global.fetch.mockClear();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user