@ -15,11 +15,51 @@
* /
import React from "react"
import { shallow } from "enzyme"
import { shallow , mount } from "enzyme"
import { MemoryRouter } from "react-router-dom"
import App from "../App"
jest . mock ( "../browser/Login" , ( ) => ( ) => < div > Login < / d i v > )
jest . mock ( "../browser/Browser" , ( ) => ( ) => < div > Browser < / d i v > )
describe ( "App" , ( ) => {
it ( "should render without crashing" , ( ) => {
shallow ( < App match = { { url : "/minio" } } / > )
shallow ( < App / > )
} )
it ( "should render Login component for '/login' route" , ( ) => {
const wrapper = mount (
< MemoryRouter initialEntries = { [ "/login" ] } >
< App / >
< / M e m o r y R o u t e r >
)
expect ( wrapper . text ( ) ) . toBe ( "Login" )
} )
it ( "should render Browser component for '/' route" , ( ) => {
const wrapper = mount (
< MemoryRouter initialEntries = { [ "/" ] } >
< App / >
< / M e m o r y R o u t e r >
)
expect ( wrapper . text ( ) ) . toBe ( "Browser" )
} )
it ( "should render Browser component for '/bucket' route" , ( ) => {
const wrapper = mount (
< MemoryRouter initialEntries = { [ "/bucket" ] } >
< App / >
< / M e m o r y R o u t e r >
)
expect ( wrapper . text ( ) ) . toBe ( "Browser" )
} )
it ( "should render Browser component for '/bucket/a/b/c' route" , ( ) => {
const wrapper = mount (
< MemoryRouter initialEntries = { [ "/bucket/a/b/c" ] } >
< App / >
< / M e m o r y R o u t e r >
)
expect ( wrapper . text ( ) ) . toBe ( "Browser" )
} )
} )