From 6dfcd70025ac5ea137bc5a7e1b8e3496ccd45a56 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Fri, 25 Oct 2019 10:45:42 +0200 Subject: [PATCH] refactor: adds test for registry info component (#214) --- .../RegistryInfoContent.test.tsx | 23 +++++++++++++++++++ .../RegistryInfoContent.test.tsx.snap | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 src/components/RegistryInfoContent/RegistryInfoContent.test.tsx create mode 100644 src/components/RegistryInfoContent/__snapshots__/RegistryInfoContent.test.tsx.snap diff --git a/src/components/RegistryInfoContent/RegistryInfoContent.test.tsx b/src/components/RegistryInfoContent/RegistryInfoContent.test.tsx new file mode 100644 index 0000000..058c27e --- /dev/null +++ b/src/components/RegistryInfoContent/RegistryInfoContent.test.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { mount } from 'enzyme'; + +import RegistryInfoContent from './RegistryInfoContent'; + +describe(' component', () => { + test('should render the component in default state with npm tab', () => { + const wrapper = mount(); + expect(wrapper.html()).toMatchSnapshot(); + }); + + test('should render the component in default state with pnpm tab', () => { + const wrapper = mount(); + wrapper.setState({ tabPosition: 1 }); + expect(wrapper.html()).toMatchSnapshot(); + }); + + test('should render the component in default state with yarn tab', () => { + const wrapper = mount(); + wrapper.setState({ tabPosition: 2 }); + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/src/components/RegistryInfoContent/__snapshots__/RegistryInfoContent.test.tsx.snap b/src/components/RegistryInfoContent/__snapshots__/RegistryInfoContent.test.tsx.snap new file mode 100644 index 0000000..0f69ac5 --- /dev/null +++ b/src/components/RegistryInfoContent/__snapshots__/RegistryInfoContent.test.tsx.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` component should render the component in default state with npm tab 1`] = `"
npm set @registry https://registry.verdaccio.org
npm adduser --registry https://registry.verdaccio.org
npm profile set password --registry https://registry.verdaccio.org
"`; + +exports[` component should render the component in default state with pnpm tab 1`] = `"
pnpm set @registry https://registry.verdaccio.org
pnpm adduser --registry https://registry.verdaccio.org
pnpm profile set password --registry https://registry.verdaccio.org
"`; + +exports[` component should render the component in default state with yarn tab 1`] = `"
yarn config set @registry https://registry.verdaccio.org
"`;