chore: add jest tests, cleanup rpc

This commit is contained in:
41666 2020-10-11 15:10:20 -04:00
parent 5977c35d38
commit ac830fc946
25 changed files with 2786 additions and 319 deletions

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -14,3 +15,7 @@ react_library(
"@types/styled-components",
],
)
jest_test(
src = ":button",
)

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -17,3 +18,8 @@ react_library(
"@types/styled-components",
],
)
jest_test(
src = ":role",
deps = ["//hack/fixtures"],
)

View file

@ -1,5 +1,5 @@
import { shallow } from 'enzyme';
import { roleCategory } from 'hack/fixtures/storyData';
import { roleCategory } from 'roleypoly/hack/fixtures/storyData';
import * as React from 'react';
import { Role } from './Role';

View file

@ -6,10 +6,8 @@ import { TabTitle, TabContent } from './TabView.styled';
const makeView = (props: Partial<TabViewProps> = {}) =>
shallow(
<TabView {...props}>
{{
'Tab 1': <Tab>{() => <div>tab 1</div>}</Tab>,
'Tab 2': <Tab>{() => <div>tab 2</div>}</Tab>,
}}
<Tab title="Tab 1">{() => <div>tab 1</div>}</Tab>
<Tab title="Tab 2">{() => <div>tab 2</div>}</Tab>,
</TabView>
);
@ -20,13 +18,13 @@ it('renders tab content correctly', () => {
});
it('automatically picks preselected tab content', () => {
const view = makeView({ initialTab: 'Tab 2' });
const view = makeView({ initialTab: 1 });
expect(view.find(Tab).renderProp('children')().text()).toBe('tab 2');
});
it('automatically uses the first tab when preselected tab is not present', () => {
const view = makeView({ initialTab: 'Not a Tab' });
const view = makeView({ initialTab: -1 });
view.find(TabContent).find('i').simulate('load');
expect(view.find(Tab).renderProp('children')().text()).toBe('tab 1');

View file

@ -1,4 +1,5 @@
load("//:hack/react.bzl", "react_library")
load("//:hack/jest.bzl", "jest_test")
package(default_visibility = ["//visibility:public"])
@ -9,3 +10,7 @@ react_library(
"@types/react",
],
)
jest_test(
src = ":timings",
)