Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Added some boundary tests to the lazy rendering hash
Browse files Browse the repository at this point in the history
  • Loading branch information
domharrington committed Jun 24, 2019
1 parent 455b7fd commit 2694d04
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/api-explorer/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ describe('auth', () => {
expect(lazyHash[2]).toEqual(false);
expect(lazyHash[3]).toEqual(false);
expect(lazyHash[4]).toEqual(false);
expect(lazyHash[5]).toEqual(true);
});

it('should disable lazy render middle 5 projects', () => {
Expand All @@ -239,11 +240,13 @@ describe('auth', () => {
const slugs = instance.props.docs.map(x => x.slug);
const centerIdx = slugs.indexOf('user-createWithArray');

expect(instance.lazyHash[centerIdx - 3]).toEqual(true);
expect(instance.lazyHash[centerIdx - 2]).toEqual(false);
expect(instance.lazyHash[centerIdx - 1]).toEqual(false);
expect(instance.lazyHash[centerIdx]).toEqual(false);
expect(instance.lazyHash[centerIdx + 1]).toEqual(false);
expect(instance.lazyHash[centerIdx + 2]).toEqual(false);
expect(instance.lazyHash[centerIdx + 3]).toEqual(true);
});

it('should disable lazy render for last 5 projects', () => {
Expand All @@ -255,6 +258,7 @@ describe('auth', () => {
const slugs = instance.props.docs.map(x => x.slug);
const centerIdx = slugs.indexOf('user-username');

expect(instance.lazyHash[centerIdx - 3]).toEqual(true);
expect(instance.lazyHash[centerIdx - 2]).toEqual(false);
expect(instance.lazyHash[centerIdx - 1]).toEqual(false);
expect(instance.lazyHash[centerIdx]).toEqual(false);
Expand Down

0 comments on commit 2694d04

Please sign in to comment.