Skip to content

Commit 6f36bf1

Browse files
fix update-view.spec.ts
1 parent af80a53 commit 6f36bf1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/compass-aggregations/src/modules/update-view.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,38 @@ describe('update-view module', function () {
5656
beforeEach(async function () {
5757
dispatchFake = sinon.fake();
5858
updateCollectionFake = sinon.fake.resolves(undefined);
59-
showConfirmationStub = sinon.stub(updateViewSlice, 'showConfirmation');
59+
showConfirmationStub = sinon
60+
.stub(updateViewSlice, 'showConfirmation')
61+
.resolves(true);
6062
stateMock = {
6163
pipelineBuilder: { pipelineMode: 'builder-ui' },
64+
searchIndexes: { indexes: [{ name: 'index1' }] },
6265
focusMode: { isEnabled: false },
6366
namespace: 'aa.bb',
6467
editViewName: 'aa.bb',
65-
searchIndexes: { indexes: [{ name: 'index1' }] },
6668
dataService: {
6769
dataService: {
6870
updateCollection: updateCollectionFake,
6971
},
7072
},
7173
};
7274
getStateMock = () => stateMock;
73-
74-
const runUpdateView = updateView();
75-
await runUpdateView(dispatchFake, getStateMock, thunkArg as any);
7675
});
7776

7877
afterEach(function () {
7978
showConfirmationStub.restore();
8079
});
8180

82-
it('first it calls to dismiss any existing error', function () {
81+
it('first it calls to dismiss any existing error', async function () {
82+
const runUpdateView = updateView();
83+
await runUpdateView(dispatchFake, getStateMock, thunkArg as any);
84+
8385
expect(dispatchFake.firstCall.args[0]).to.deep.equal({
8486
type: 'aggregations/update-view/DISMISS_VIEW_UPDATE_ERROR',
8587
});
8688
});
8789

8890
it('shows confirmation banner when search indexes are present', async function () {
89-
showConfirmationStub.resolves(true);
90-
9191
const runUpdateView = updateView();
9292
await runUpdateView(dispatchFake, getStateMock, thunkArg as any);
9393

@@ -99,7 +99,6 @@ describe('update-view module', function () {
9999
});
100100

101101
it('does not update view if not confirmed', async function () {
102-
getStateMock = () => stateMock;
103102
showConfirmationStub.resolves(false);
104103

105104
const runUpdateView = updateView();
@@ -108,7 +107,10 @@ describe('update-view module', function () {
108107
expect(updateCollectionFake.calledOnce).to.be.false;
109108
});
110109

111-
it('calls the data service to update the view for the provided ns', function () {
110+
it('calls the data service to update the view for the provided ns', async function () {
111+
const runUpdateView = updateView();
112+
await runUpdateView(dispatchFake, getStateMock, thunkArg as any);
113+
112114
expect(updateCollectionFake.firstCall.args[0]).to.equal('aa.bb');
113115
expect(updateCollectionFake.firstCall.args[1]).to.deep.equal({
114116
viewOn: 'bb',

0 commit comments

Comments
 (0)