storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/__tests__/App.test.js (about) 1 /* 2 * MinIO Cloud Storage (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import React from "react" 18 import { shallow, mount } from "enzyme" 19 import { MemoryRouter } from "react-router-dom" 20 import App from "../App" 21 22 jest.mock("../browser/Login", () => () => <div>Login</div>) 23 jest.mock("../browser/Browser", () => () => <div>Browser</div>) 24 25 describe("App", () => { 26 it("should render without crashing", () => { 27 shallow(<App />) 28 }) 29 30 it("should render Login component for '/login' route", () => { 31 const wrapper = mount( 32 <MemoryRouter initialEntries={["/login"]}> 33 <App /> 34 </MemoryRouter> 35 ) 36 expect(wrapper.text()).toBe("Login") 37 }) 38 39 it("should render Browser component for '/' route", () => { 40 const wrapper = mount( 41 <MemoryRouter initialEntries={["/"]}> 42 <App /> 43 </MemoryRouter> 44 ) 45 expect(wrapper.text()).toBe("Browser") 46 }) 47 48 it("should render Browser component for '/bucket' route", () => { 49 const wrapper = mount( 50 <MemoryRouter initialEntries={["/bucket"]}> 51 <App /> 52 </MemoryRouter> 53 ) 54 expect(wrapper.text()).toBe("Browser") 55 }) 56 57 it("should render Browser component for '/bucket/a/b/c' route", () => { 58 const wrapper = mount( 59 <MemoryRouter initialEntries={["/bucket/a/b/c"]}> 60 <App /> 61 </MemoryRouter> 62 ) 63 expect(wrapper.text()).toBe("Browser") 64 }) 65 })