Skip to content

Commit

Permalink
test: add missing data provider tests (#7353)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Apr 25, 2024
1 parent 178d0e0 commit 1c2f65e
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions packages/combo-box/test/lazy-loading.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,6 @@ describe('lazy loading', () => {
expect(spyDataProvider.calledOnce).to.be.true;
});

it('should not request empty loaded page again', () => {
const dp = sinon.spy((params, callback) => callback([], 0));
comboBox.dataProvider = dp;
comboBox.open();
comboBox.close();
comboBox.open();
expect(dp.calledOnce).to.be.true;
});

it('should request pages asynchronously when scrolling', async () => {
comboBox.dataProvider = spyDataProvider;
spyDataProvider.resetHistory();
Expand Down Expand Up @@ -348,6 +339,32 @@ describe('lazy loading', () => {
});
});

describe('empty data set is loaded', () => {
beforeEach(() => {
comboBox.dataProvider = sinon.spy((_params, callback) => callback([], 0));
comboBox.open();
comboBox.close();
comboBox.dataProvider.resetHistory();
});

it('should not request first page on open', () => {
comboBox.open();
expect(comboBox.dataProvider).to.be.not.called;
});

it('should request first page on open after increasing size property', () => {
comboBox.size = SIZE;
comboBox.open();
expect(comboBox.dataProvider).to.be.calledOnce;
});

it('should request first page on open after clearing cache', () => {
comboBox.clearCache();
comboBox.open();
expect(comboBox.dataProvider).to.be.calledOnce;
});
});

describe('when selecting item', () => {
beforeEach(() => {
comboBox.dataProvider = spyDataProvider;
Expand Down Expand Up @@ -1133,23 +1150,6 @@ describe('lazy loading', () => {
expect(comboBox.value).to.equal('other value');
});
});

describe('after empty data set loaded', () => {
const emptyDataProvider = sinon.spy((params, callback) => callback([], 0));

beforeEach(() => {
comboBox.dataProvider = emptyDataProvider;
comboBox.open();
comboBox.close();
emptyDataProvider.resetHistory();
});

it('should request first page on open', () => {
comboBox.clearCache();
comboBox.open();
expect(emptyDataProvider.calledOnce).to.be.true;
});
});
});

describe('undefined size', () => {
Expand Down

0 comments on commit 1c2f65e

Please sign in to comment.