Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 683 Bytes

currentPath.md

File metadata and controls

40 lines (31 loc) · 683 Bytes

.content() => String

Returns the current URL path

Returns

A string of the current URL path

Example in Jest

import React from 'react'
import Page from 'react-page-object'
import { BrowserRouter, Link } from 'react-router-dom'

const App = () => (
  <BrowserRouter>
    <div>
      <Link to="/first" />
    </div>
  </BrowserRouter>
)

describe('currentPath', () => {
  let page

  beforeEach(() => {
    page = new Page(<App />)
  })

  afterEach(() => {
    page.destroy()
  })

  it('returns the current URL path', () => {
    expect(page.currentPath()).toEqual('/')
    page.clickLink('/first')
    expect(page.currentPath()).toEqual('/first')
  })
})