Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amundsen_dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Surendar Reddy Mangannagari
amundsen_dev
Commits
5b32e160
Unverified
Commit
5b32e160
authored
Mar 05, 2020
by
Tamika Tannis
Committed by
GitHub
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create TableHeaderBullets component (#397)
* Create TableHeaderBullets component * Fix mocks
parent
f9bf500c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
18 deletions
+102
-18
index.tsx
...ic/js/components/TableDetail/TableHeaderBullets/index.tsx
+27
-0
index.spec.tsx
...nents/TableDetail/TableHeaderBullets/tests/index.spec.tsx
+61
-0
index.tsx
...en_application/static/js/components/TableDetail/index.tsx
+6
-6
index.spec.tsx
...r/InlineSearchResults/SearchItemList/tests/index.spec.tsx
+3
-4
index.spec.tsx
...common/SearchBar/InlineSearchResults/tests/index.spec.tsx
+5
-8
No files found.
amundsen_application/static/js/components/TableDetail/TableHeaderBullets/index.tsx
0 → 100644
View file @
5b32e160
import
*
as
React
from
'react'
;
import
{
getDisplayNameByResource
,
getDatabaseDisplayName
}
from
'config/config-utils'
;
import
{
ResourceType
}
from
'interfaces/Resources'
;
export
interface
TableHeaderBulletsProps
{
cluster
:
string
;
database
:
string
;
}
const
TableHeaderBullets
:
React
.
SFC
<
TableHeaderBulletsProps
>
=
({
cluster
,
database
})
=>
{
return
(
<
ul
className=
"header-bullets"
>
<
li
>
{
getDisplayNameByResource
(
ResourceType
.
table
)
}
</
li
>
<
li
>
{
getDatabaseDisplayName
(
database
)
}
</
li
>
<
li
>
{
cluster
}
</
li
>
</
ul
>
);
};
TableHeaderBullets
.
defaultProps
=
{
cluster
:
''
,
database
:
''
,
};
export
default
TableHeaderBullets
;
amundsen_application/static/js/components/TableDetail/TableHeaderBullets/tests/index.spec.tsx
0 → 100644
View file @
5b32e160
import
*
as
React
from
'react'
;
import
{
mocked
}
from
'ts-jest/utils'
;
import
{
shallow
}
from
'enzyme'
;
import
TableHeaderBullets
,
{
TableHeaderBulletsProps
}
from
'../'
;
import
{
ResourceType
}
from
'interfaces/Resources'
;
const
MOCK_RESOURCE_DISPLAY_NAME
=
'Test'
;
const
MOCK_DB_DISPLAY_NAME
=
'AlsoTest'
;
jest
.
mock
(
'config/config-utils'
,
()
=>
({
getDisplayNameByResource
:
jest
.
fn
(),
getDatabaseDisplayName
:
jest
.
fn
()
}));
import
{
getDatabaseDisplayName
,
getDisplayNameByResource
}
from
'config/config-utils'
;
describe
(
'TableHeaderBullets'
,
()
=>
{
const
setup
=
(
propOverrides
?:
Partial
<
TableHeaderBulletsProps
>
)
=>
{
const
props
:
TableHeaderBulletsProps
=
{
database
:
'hive'
,
cluster
:
'main'
,
...
propOverrides
};
const
wrapper
=
shallow
(<
TableHeaderBullets
{
...
props
}
/>);
return
{
props
,
wrapper
};
};
describe
(
'render'
,
()
=>
{
let
props
:
TableHeaderBulletsProps
;
let
wrapper
;
let
listElement
;
beforeAll
(()
=>
{
mocked
(
getDatabaseDisplayName
).
mockImplementation
(()
=>
MOCK_DB_DISPLAY_NAME
);
mocked
(
getDisplayNameByResource
).
mockImplementation
(()
=>
MOCK_RESOURCE_DISPLAY_NAME
);
const
setupResult
=
setup
();
props
=
setupResult
.
props
;
wrapper
=
setupResult
.
wrapper
;
listElement
=
wrapper
.
find
(
'ul'
);
});
it
(
'renders a list with correct class'
,
()
=>
{
expect
(
listElement
.
props
().
className
).
toEqual
(
'header-bullets'
);
});
it
(
'renders a list with resource display name'
,
()
=>
{
expect
(
getDisplayNameByResource
).
toHaveBeenCalledWith
(
ResourceType
.
table
);
expect
(
listElement
.
find
(
'li'
).
at
(
0
).
text
()).
toEqual
(
MOCK_RESOURCE_DISPLAY_NAME
);
});
it
(
'renders a list with database display name'
,
()
=>
{
expect
(
getDatabaseDisplayName
).
toHaveBeenCalledWith
(
props
.
database
);
expect
(
listElement
.
find
(
'li'
).
at
(
1
).
text
()).
toEqual
(
MOCK_DB_DISPLAY_NAME
);
});
it
(
'renders a list with cluster'
,
()
=>
{
expect
(
listElement
.
find
(
'li'
).
at
(
2
).
text
()).
toEqual
(
props
.
cluster
);
});
});
});
amundsen_application/static/js/components/TableDetail/index.tsx
View file @
5b32e160
...
@@ -24,6 +24,7 @@ import OwnerEditor from 'components/TableDetail/OwnerEditor';
...
@@ -24,6 +24,7 @@ import OwnerEditor from 'components/TableDetail/OwnerEditor';
import
ReportTableIssue
from
'components/TableDetail/ReportTableIssue'
;
import
ReportTableIssue
from
'components/TableDetail/ReportTableIssue'
;
import
SourceLink
from
'components/TableDetail/SourceLink'
;
import
SourceLink
from
'components/TableDetail/SourceLink'
;
import
TableDescEditableText
from
'components/TableDetail/TableDescEditableText'
;
import
TableDescEditableText
from
'components/TableDetail/TableDescEditableText'
;
import
TableHeaderBullets
from
'components/TableDetail/TableHeaderBullets'
;
import
TableIssues
from
'components/TableDetail/TableIssues'
;
import
TableIssues
from
'components/TableDetail/TableIssues'
;
import
WatermarkLabel
from
'components/TableDetail/WatermarkLabel'
;
import
WatermarkLabel
from
'components/TableDetail/WatermarkLabel'
;
import
WriterLink
from
'components/TableDetail/WriterLink'
;
import
WriterLink
from
'components/TableDetail/WriterLink'
;
...
@@ -32,7 +33,7 @@ import { TableMetadata } from 'interfaces/TableMetadata';
...
@@ -32,7 +33,7 @@ import { TableMetadata } from 'interfaces/TableMetadata';
import
{
EditableSection
}
from
'components/TableDetail/EditableSection'
;
import
{
EditableSection
}
from
'components/TableDetail/EditableSection'
;
import
{
getD
isplayNameByResource
,
getDatabaseDisplayName
,
getD
atabaseIconClass
,
issueTrackingEnabled
,
notificationsEnabled
}
from
'config/config-utils'
;
import
{
getDatabaseIconClass
,
issueTrackingEnabled
,
notificationsEnabled
}
from
'config/config-utils'
;
import
{
ResourceType
}
from
'interfaces/Resources'
;
import
{
ResourceType
}
from
'interfaces/Resources'
;
import
{
formatDateTimeShort
}
from
'utils/dateUtils'
;
import
{
formatDateTimeShort
}
from
'utils/dateUtils'
;
...
@@ -142,11 +143,10 @@ class TableDetail extends React.Component<TableDetailProps & RouteComponentProps
...
@@ -142,11 +143,10 @@ class TableDetail extends React.Component<TableDetailProps & RouteComponentProps
</
h3
>
</
h3
>
<
BookmarkIcon
bookmarkKey=
{
this
.
props
.
tableData
.
key
}
/>
<
BookmarkIcon
bookmarkKey=
{
this
.
props
.
tableData
.
key
}
/>
<
div
className=
"body-2"
>
<
div
className=
"body-2"
>
<
ul
className=
"header-bullets"
>
<
TableHeaderBullets
<
li
>
{
getDisplayNameByResource
(
ResourceType
.
table
)
}
</
li
>
database=
{
data
.
database
}
<
li
>
{
getDatabaseDisplayName
(
data
.
database
)
}
</
li
>
cluster=
{
data
.
cluster
}
<
li
>
{
data
.
cluster
}
</
li
>
/>
</
ul
>
{
{
data
.
badges
.
length
>
0
&&
data
.
badges
.
length
>
0
&&
<
BadgeList
badges=
{
data
.
badges
}
/>
<
BadgeList
badges=
{
data
.
badges
}
/>
...
...
amundsen_application/static/js/components/common/SearchBar/InlineSearchResults/SearchItemList/tests/index.spec.tsx
View file @
5b32e160
import
*
as
React
from
'react'
;
import
*
as
React
from
'react'
;
import
{
mocked
}
from
'ts-jest/utils'
;
import
{
shallow
}
from
'enzyme'
;
import
{
shallow
}
from
'enzyme'
;
import
SearchItemList
,
{
SearchItemListProps
}
from
'../'
;
import
SearchItemList
,
{
SearchItemListProps
}
from
'../'
;
...
@@ -82,8 +83,7 @@ describe('SearchItemList', () => {
...
@@ -82,8 +83,7 @@ describe('SearchItemList', () => {
describe
(
'renders ResourceType.user SearchItem based on config'
,
()
=>
{
describe
(
'renders ResourceType.user SearchItem based on config'
,
()
=>
{
it
(
'when indexUsersEnabled = true, renders SearchItem'
,
()
=>
{
it
(
'when indexUsersEnabled = true, renders SearchItem'
,
()
=>
{
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
indexUsersEnabled
).
mockImplementation
(()
=>
true
);
indexUsersEnabled
.
mockImplementation
(()
=>
true
);
setUpResult
=
setup
();
setUpResult
=
setup
();
props
=
setUpResult
.
props
;
props
=
setUpResult
.
props
;
wrapper
=
setUpResult
.
wrapper
;
wrapper
=
setUpResult
.
wrapper
;
...
@@ -101,8 +101,7 @@ describe('SearchItemList', () => {
...
@@ -101,8 +101,7 @@ describe('SearchItemList', () => {
});
});
it
(
'when indexUsersEnabled = false, does not render SearchItem'
,
()
=>
{
it
(
'when indexUsersEnabled = false, does not render SearchItem'
,
()
=>
{
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
indexUsersEnabled
).
mockImplementation
(()
=>
false
);
indexUsersEnabled
.
mockImplementation
(()
=>
false
);
wrapper
=
setup
().
wrapper
;
wrapper
=
setup
().
wrapper
;
const
item
=
wrapper
.
find
(
'SearchItem'
).
findWhere
(
item
=>
item
.
prop
(
'resourceType'
)
===
ResourceType
.
user
);
const
item
=
wrapper
.
find
(
'SearchItem'
).
findWhere
(
item
=>
item
.
prop
(
'resourceType'
)
===
ResourceType
.
user
);
expect
(
item
.
exists
()).
toBe
(
false
)
expect
(
item
.
exists
()).
toBe
(
false
)
...
...
amundsen_application/static/js/components/common/SearchBar/InlineSearchResults/tests/index.spec.tsx
View file @
5b32e160
import
*
as
React
from
'react'
;
import
*
as
React
from
'react'
;
import
{
mocked
}
from
'ts-jest/utils'
;
import
{
shallow
}
from
'enzyme'
;
import
{
shallow
}
from
'enzyme'
;
import
{
InlineSearchResults
,
InlineSearchResultsProps
,
mapStateToProps
}
from
'../'
;
import
{
InlineSearchResults
,
InlineSearchResultsProps
,
mapStateToProps
}
from
'../'
;
...
@@ -210,8 +211,7 @@ describe('InlineSearchResults', () => {
...
@@ -210,8 +211,7 @@ describe('InlineSearchResults', () => {
});
});
it
(
'returns the results of getDatabaseIconClass for ResourceType.table'
,
()
=>
{
it
(
'returns the results of getDatabaseIconClass for ResourceType.table'
,
()
=>
{
const
mockClass
=
'test-class'
;
const
mockClass
=
'test-class'
;
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
getDatabaseIconClass
).
mockImplementation
(()
=>
mockClass
);
getDatabaseIconClass
.
mockImplementation
(()
=>
mockClass
);
const
givenTable
=
props
.
tables
.
results
[
0
];
const
givenTable
=
props
.
tables
.
results
[
0
];
const
output
=
wrapper
.
instance
().
getSuggestedResultIconClass
(
ResourceType
.
table
,
givenTable
);
const
output
=
wrapper
.
instance
().
getSuggestedResultIconClass
(
ResourceType
.
table
,
givenTable
);
expect
(
output
).
toEqual
(
mockClass
);
expect
(
output
).
toEqual
(
mockClass
);
...
@@ -285,8 +285,7 @@ describe('InlineSearchResults', () => {
...
@@ -285,8 +285,7 @@ describe('InlineSearchResults', () => {
});
});
it
(
'returns the results of getDatabaseDisplayName for ResourceType.table'
,
()
=>
{
it
(
'returns the results of getDatabaseDisplayName for ResourceType.table'
,
()
=>
{
const
mockName
=
'Hive'
;
const
mockName
=
'Hive'
;
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
getDatabaseDisplayName
).
mockImplementation
(()
=>
mockName
);
getDatabaseDisplayName
.
mockImplementation
(()
=>
mockName
);
const
givenTable
=
props
.
tables
.
results
[
0
];
const
givenTable
=
props
.
tables
.
results
[
0
];
const
output
=
wrapper
.
instance
().
getSuggestedResultType
(
ResourceType
.
table
,
givenTable
);
const
output
=
wrapper
.
instance
().
getSuggestedResultType
(
ResourceType
.
table
,
givenTable
);
expect
(
output
).
toEqual
(
mockName
);
expect
(
output
).
toEqual
(
mockName
);
...
@@ -401,16 +400,14 @@ describe('InlineSearchResults', () => {
...
@@ -401,16 +400,14 @@ describe('InlineSearchResults', () => {
describe
(
'calls renderResultsByResource for ResourceType.user based on config'
,
()
=>
{
describe
(
'calls renderResultsByResource for ResourceType.user based on config'
,
()
=>
{
it
(
'does not call if indexUsersEnabled() = false'
,
()
=>
{
it
(
'does not call if indexUsersEnabled() = false'
,
()
=>
{
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
indexUsersEnabled
).
mockImplementation
(()
=>
false
);
indexUsersEnabled
.
mockImplementation
(()
=>
false
);
renderResultsByResourceSpy
.
mockClear
();
renderResultsByResourceSpy
.
mockClear
();
wrapper
.
instance
().
renderResults
();
wrapper
.
instance
().
renderResults
();
expect
(
renderResultsByResourceSpy
).
not
.
toHaveBeenCalledWith
(
ResourceType
.
user
);
expect
(
renderResultsByResourceSpy
).
not
.
toHaveBeenCalledWith
(
ResourceType
.
user
);
});
});
it
(
'calls if indexUsersEnabled() = true'
,
()
=>
{
it
(
'calls if indexUsersEnabled() = true'
,
()
=>
{
// @ts-ignore: Known issue but can't find solution: https://github.com/kulshekhar/ts-jest/issues/661
mocked
(
indexUsersEnabled
).
mockImplementation
(()
=>
true
);
indexUsersEnabled
.
mockImplementation
(()
=>
true
);
renderResultsByResourceSpy
.
mockClear
();
renderResultsByResourceSpy
.
mockClear
();
wrapper
.
instance
().
renderResults
();
wrapper
.
instance
().
renderResults
();
expect
(
renderResultsByResourceSpy
).
toHaveBeenCalledWith
(
ResourceType
.
user
);
expect
(
renderResultsByResourceSpy
).
toHaveBeenCalledWith
(
ResourceType
.
user
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment