mirror of https://github.com/prometheus/prometheus
Add conditional rendering of Navlink for Consoles (#6761)
* Add conditional rendering of Navlink for Consoles Signed-off-by: Drumil Patel <drumilpatel720@gmail.com> * Replacing if else with only if conditional rendering Signed-off-by: Drumil Patel <drumilpatel720@gmail.com> * Add tests and removing global declaration in Navbar Signed-off-by: Drumil Patel <drumilpatel720@gmail.com> * Correct Navbar Testcases and add types for ConsolesLink Signed-off-by: Drumil Patel <drumilpatel720@gmail.com> * Change names for Console link as per-naming convention Signed-off-by: Drumil Patel <drumilpatel720@gmail.com> * Change prop names to AppProps and NavbarProps respectively Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>pull/6790/head
parent
a336908678
commit
687a962bd1
@ -0,0 +1,30 @@
|
||||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Navigation from './Navbar';
|
||||
import { NavItem, NavLink } from 'reactstrap';
|
||||
|
||||
describe('Navbar should contain console Link', () => {
|
||||
it('with non-empty consoleslink', () => {
|
||||
const app = shallow(<Navigation pathPrefix="/path/prefix" consolesLink="/path/consoles" />);
|
||||
expect(
|
||||
app.contains(
|
||||
<NavItem>
|
||||
<NavLink href="/path/consoles">Consoles</NavLink>
|
||||
</NavItem>
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Navbar should not contain consoles link', () => {
|
||||
it('with empty string in consolesLink', () => {
|
||||
const app = shallow(<Navigation pathPrefix="/path/prefix" consolesLink="" />);
|
||||
expect(
|
||||
app.contains(
|
||||
<NavItem>
|
||||
<NavLink>Consoles</NavLink>
|
||||
</NavItem>
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
Loading…
Reference in new issue