components#Page TypeScript Examples

The following examples show how to use components#Page. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: child.test.tsx    From geist-ui with MIT License 6 votes vote down vote up
describe('PageChild', () => {
  it('the component Page.Content should be injected automatically', () => {
    const wrapper = mount(<Page>test-value</Page>)
    const content = mount(
      <Page>
        <Page.Content>test-value</Page.Content>
      </Page>,
    )
    expect(wrapper.html()).toEqual(content.html())
  })

  it('should work with child component', () => {
    const wrapper = mount(
      <Page>
        outside string
        <Page.Header>header</Page.Header>
        <Page.Content>content</Page.Content>
        <Page.Footer>Footer</Page.Footer>
        outside string
      </Page>,
    )
    expect(wrapper.html()).toMatchSnapshot()
    expect(() => wrapper.unmount()).not.toThrow()
  })

  it('the header should be centered', () => {
    const wrapper = mount(<Page.Header center>header</Page.Header>)
    expect(wrapper.find('.center').length).not.toBe(0)
  })
})
Example #2
Source File: index.test.tsx    From geist-ui with MIT License 5 votes vote down vote up
describe('Page', () => {
  it('should render correctly', () => {
    const wrapper = mount(<Page>test-value</Page>)
    expect(wrapper.text()).toContain('test-value')
    expect(wrapper.html()).toMatchSnapshot()
    expect(() => wrapper.unmount()).not.toThrow()
  })

  it('the first page should not contain content', () => {
    const html = ReactDom.renderToString(<Page render="effect">test-value</Page>)
    expect(html).not.toContain('test-value')

    const wrapper = mount(<Page render="effect">test-value</Page>)
    expect(wrapper.html()).toContain('test-value')
  })

  it('the first page should contain seo string', () => {
    const html = ReactDom.renderToString(<Page render="effect-seo">test-value</Page>)
    expect(html).toContain('test-value')
    expect(html).toContain('hidden')

    const wrapper = mount(<Page render="effect">test-value</Page>)
    expect(wrapper.html()).toContain('test-value')
  })

  it('the global styles should be added to body element', () => {
    const wrapper = mount(<Page dotBackdrop />)
    expect(wrapper.html()).toContain('global(body)')
  })

  it('should disable dot style when in dark mode', () => {
    const wrapper = mount(
      <GeistProvider themeType="dark">
        <Page dotBackdrop />
      </GeistProvider>,
    )
    expect(wrapper.html()).not.toContain('global(body)')
  })

  it('should work correctly with dot configs', () => {
    const wrapper = mount(<Page dotBackdrop dotSize="20px" dotSpace={0.5} />)
    expect(wrapper.html()).toMatchSnapshot()
    expect(() => wrapper.unmount()).not.toThrow()
  })
})