Passed
Push — master ( 967bc6...fd5993 )
by Vinicius
02:44
created

page-title.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 1
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1 2
import { buildPageTitle, safeString } from './utils'
2
3
/**
4
 * if use ssr document is not available
5
 * @method isBrowser
6
 * @return {Boolean}
7
 */
8 10
const isBrowser = () => (typeof document !== 'undefined')
9
10
/**
11
 * update document.title
12
 * @method setPageTitle
13
 * @param  {String}     value new title
14
 * @param  {Object}     options buildPageTitle options
15
 * @return {void}
16
 */
17 2
const setPageTitle = (value, options) => {
18
  // test if not is a browser
19
  /* istanbul ignore next: SSR */
20
  if (!isBrowser()) {
21
    console.warn('no browser enviroment')
22
    return
23
  }
24
25
  // test if title is empty
26 10
  if (safeString(value).length > 0) {
27 8
    document.title = buildPageTitle(value, options)
28
  }
29
}
30
31
export { setPageTitle }
32