-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-merged master into dev on deployment.
- Loading branch information
Showing
53 changed files
with
872 additions
and
561 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import EksternLenke from './EksternLenke'; | ||
import '../utils/SetupEnzyme'; | ||
|
||
describe('<EksternLenke/>', () => { | ||
it('skal padde href med protokoll når det mangler', () => { | ||
const tekst = 'nav.no'; | ||
const wrapper = shallow(<EksternLenke lenke={tekst} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('skal ikke padde href med protokoll, http', () => { | ||
const tekst = 'http://nav.no'; | ||
const wrapper = shallow(<EksternLenke lenke={tekst} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('skal ikke padde href med protokoll, https', () => { | ||
const tekst = 'https://nav.no'; | ||
const wrapper = shallow(<EksternLenke lenke={tekst} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('skal padde href med protokoll når det mangler, www', () => { | ||
const tekst = 'www.nav.no'; | ||
const wrapper = shallow(<EksternLenke lenke={tekst} />); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
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,22 @@ | ||
import React from 'react'; | ||
import Lenke from 'nav-frontend-lenker'; | ||
import { ReactComponent as EksternLenkeIkon } from './ekstern-lenke.svg'; | ||
|
||
const httpRegex = /^(https?):\/\/.*$/; | ||
|
||
interface PropTypes { | ||
lenke: string | null; | ||
} | ||
|
||
export default function EksternLenke(props: PropTypes) { | ||
const { lenke } = props; | ||
|
||
if (!lenke) return null; | ||
const paddaLenke = lenke && lenke.match(httpRegex) ? lenke : `http://${lenke}`; | ||
return ( | ||
<Lenke href={paddaLenke}> | ||
{lenke} | ||
<EksternLenkeIkon /> | ||
</Lenke> | ||
); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/felleskomponenter/__snapshots__/EksternLenke.test.tsx.snap
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,37 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<EksternLenke/> skal ikke padde href med protokoll, http 1`] = ` | ||
<Lenke | ||
href="http://nav.no" | ||
> | ||
http://nav.no | ||
<ForwardRef(SvgEksternLenke) /> | ||
</Lenke> | ||
`; | ||
|
||
exports[`<EksternLenke/> skal ikke padde href med protokoll, https 1`] = ` | ||
<Lenke | ||
href="https://nav.no" | ||
> | ||
https://nav.no | ||
<ForwardRef(SvgEksternLenke) /> | ||
</Lenke> | ||
`; | ||
|
||
exports[`<EksternLenke/> skal padde href med protokoll når det mangler 1`] = ` | ||
<Lenke | ||
href="http://nav.no" | ||
> | ||
nav.no | ||
<ForwardRef(SvgEksternLenke) /> | ||
</Lenke> | ||
`; | ||
|
||
exports[`<EksternLenke/> skal padde href med protokoll når det mangler, www 1`] = ` | ||
<Lenke | ||
href="http://www.nav.no" | ||
> | ||
www.nav.no | ||
<ForwardRef(SvgEksternLenke) /> | ||
</Lenke> | ||
`; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Routing from './view/App'; | ||
import App from './view/App'; | ||
|
||
require('./mock'); | ||
|
||
ReactDOM.render(<Routing />, document.getElementById('root')); | ||
ReactDOM.render(<App />, document.getElementById('root')); |
Oops, something went wrong.