-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download and bookmark on listing item mouseover (#3697)
* Download and bookmark on listing item mouseover * use physicalKey for package files * fix passing physicalKey * add snapshot unit tests * there is path always, because we download something inside package * throw error on unexpected * cleaner mock for URL * throw instead of assertNever
- Loading branch information
Showing
12 changed files
with
720 additions
and
21 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
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,103 @@ | ||
import * as React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import * as NamedRoutes from 'utils/NamedRoutes' | ||
import * as Bookmarks from 'containers/Bookmarks/Provider' | ||
import { bucketFile, bucketDir, bucketPackageTree } from 'constants/routes' | ||
|
||
import { RowActions } from './ListingActions' | ||
|
||
function TestBucket({ children }: React.PropsWithChildren<{}>) { | ||
return ( | ||
<Bookmarks.Provider> | ||
<NamedRoutes.Provider routes={{ bucketFile, bucketDir, bucketPackageTree }}> | ||
{children} | ||
</NamedRoutes.Provider> | ||
</Bookmarks.Provider> | ||
) | ||
} | ||
|
||
describe('components/ListingActions', () => { | ||
describe('RowActions', () => { | ||
it('should render nothing if archived', () => { | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions archived to="" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render nothing if no route', () => { | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions to="" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render nothing if wrong route', () => { | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions to="/b/bucketA/BRANCH/fileB" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render Bucket directory', () => { | ||
jest.mock('react-redux') | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions to="/b/bucketA/tree/dirB/" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render Bucket file', () => { | ||
jest.mock('utils/AWS') | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions to="/b/bucketA/tree/fileB" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render Package directory', () => { | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions to="/b/bucketA/packages/namespaceB/nameC/tree/latest/dirD/" /> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
it('should render Package file', () => { | ||
const tree = renderer | ||
.create( | ||
<TestBucket> | ||
<RowActions | ||
to="/b/bucketA/packages/namespaceB/nameC/tree/latest/fileD" | ||
physicalKey="s3://bucketA/pathB/fileB" | ||
/> | ||
</TestBucket>, | ||
) | ||
.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.