-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'improvement/ZENKO-2833-testing-list-buckets-components-…
…and-actions' into q/1.0
- Loading branch information
Showing
6 changed files
with
250 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/react/databrowser/buckets/__tests__/BucketList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import BucketList from '../BucketList'; | ||
import { List } from 'immutable'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import React from 'react'; | ||
import { reduxMount } from '../../../utils/test'; | ||
|
||
describe('BucketList', () => { | ||
const buckets = List([{ | ||
CreationDate: 'Wed Oct 07 2020 16:35:57', | ||
LocationConstraint: 'us-east-1', | ||
Name: 'bucket1', | ||
}, { | ||
CreationDate: 'Wed Oct 07 2020 16:35:57', | ||
LocationConstraint: 'us-east-1', | ||
Name: 'bucket2', | ||
}]); | ||
const selectedBucketName = 'bucket2'; | ||
|
||
it('should list buckets with the data associated with', () => { | ||
const { component } = reduxMount( | ||
<MemoryRouter> | ||
<BucketList buckets={buckets} locations={{ | ||
'us-east-1': { | ||
isBuiltin: true, | ||
locationType: 'location-file-v1', | ||
name: 'us-east-1', | ||
objectId: '', | ||
}, | ||
}} selectedBucketName=""/> | ||
</MemoryRouter>, | ||
); | ||
|
||
const firstBucketCellLink = component.find('Cell').at(0).find('a'); | ||
const firstBucketCellLocation = component.find('Cell').at(1); | ||
const firstBucketCellDate = component.find('Cell').at(2); | ||
expect(firstBucketCellLink.text()).toBe('bucket1'); | ||
expect(firstBucketCellLink.prop('href')).toBe('/buckets/bucket1/objects'); | ||
expect(firstBucketCellLocation.text()).toBe('us-east-1 / Zenko Local Filesystem'); | ||
expect(firstBucketCellDate.text()).toBe('Wed Oct 07 2020 16:35:57'); | ||
|
||
const secondBucketCellLink = component.find('Cell').at(3).find('a'); | ||
const secondBucketCellLocation = component.find('Cell').at(4); | ||
const secondBucketCellDate = component.find('Cell').at(5); | ||
expect(secondBucketCellLink.text()).toBe('bucket2'); | ||
expect(secondBucketCellLink.prop('href')).toBe('/buckets/bucket2/objects'); | ||
expect(secondBucketCellLocation.text()).toBe('us-east-1 / Zenko Local Filesystem'); | ||
expect(secondBucketCellDate.text()).toBe('Wed Oct 07 2020 16:35:57'); | ||
}); | ||
|
||
it('should select row if the bucket name specified in the parameter matches one of the bucket names listed', () => { | ||
const { component } = reduxMount( | ||
<MemoryRouter> | ||
<BucketList buckets={buckets} locations={{}} selectedBucketName={selectedBucketName}/> | ||
</MemoryRouter>, | ||
); | ||
|
||
const bucketRows = component.find('Row').children(); | ||
bucketRows.forEach(bucketRow => { | ||
if (bucketRow.find('a').text() === selectedBucketName) { | ||
expect(bucketRow.prop('isSelected')).toBe(true); | ||
} else { | ||
expect(bucketRow.prop('isSelected')).toBe(false); | ||
} | ||
}); | ||
}); | ||
|
||
it('should select no row if there is no bucket name specified in the parameter', () => { | ||
const { component } = reduxMount( | ||
<MemoryRouter> | ||
<BucketList buckets={buckets} locations={{}} selectedBucketName=""/> | ||
</MemoryRouter>, | ||
); | ||
|
||
const bucketRows = component.find('Row').children(); | ||
bucketRows.forEach(bucketRow => { | ||
expect(bucketRow.prop('isSelected')).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import router, { Redirect } from 'react-router'; | ||
import BucketDetails from '../BucketDetails'; | ||
import BucketHead from '../BucketHead'; | ||
import BucketList from '../BucketList'; | ||
import Buckets from '../Buckets'; | ||
import { List } from 'immutable'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { OWNER_NAME } from '../../../actions/__tests__/utils/testUtil'; | ||
import React from 'react'; | ||
import { reduxMount } from '../../../utils/test'; | ||
|
||
describe('Buckets', () => { | ||
const buckets = [{ | ||
CreationDate: 'Wed Oct 07 2020 16:35:57', | ||
LocationConstraint: 'us-east-1', | ||
Name: 'bucket1', | ||
}, { | ||
CreationDate: 'Wed Oct 07 2020 16:35:57', | ||
LocationConstraint: 'us-east-1', | ||
Name: 'bucket2', | ||
}]; | ||
|
||
it('should display EmptyStateContainer if no bucket is present', () => { | ||
jest.spyOn(router, 'useParams').mockReturnValue({ bucketName: '' }); | ||
const { component } = reduxMount(<Buckets/>); | ||
|
||
expect(component.find('Warning').prop('title')).toBe('Create your first bucket.'); | ||
}); | ||
|
||
it('should redirect to the first bucket if no bucket is selected', () => { | ||
jest.spyOn(router, 'useParams').mockReturnValue({ bucketName: '' }); | ||
const { component } = reduxMount(<MemoryRouter><Buckets/></MemoryRouter>, { | ||
s3: { | ||
listBucketsResults: { | ||
list: List(buckets), | ||
ownerName: OWNER_NAME, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(component.find(Redirect)).toHaveLength(1); | ||
}); | ||
|
||
it('should render the component', () => { | ||
jest.spyOn(router, 'useParams').mockReturnValue({ bucketName: 'bucket1' }); | ||
const { component } = reduxMount(<MemoryRouter><Buckets/></MemoryRouter>, { | ||
s3: { | ||
listBucketsResults: { | ||
list: List(buckets), | ||
}, | ||
}, | ||
}); | ||
|
||
expect(component.find(BucketHead)).toHaveLength(1); | ||
expect(component.find(BucketList)).toHaveLength(1); | ||
expect(component.find(BucketDetails)).toHaveLength(1); | ||
}); | ||
}); |