it('should render error when no traces are found', () => { const traceDetailsStore = createStubDetailsStore(stubDetails, fulfilledPromise, fulfilledPromise, []); const wrapper = mount(<TraceDetailsStubComponent traceId={stubDetails[0].traceId} location={stubLocation} baseServiceName={stubDetails[0].serviceName} traceDetailsStore={traceDetailsStore} />); wrapper.find('a#related-view').simulate('click'); wrapper.find('select#field').simulate('change', {target: { value: 0}}); expect(wrapper.find('.error-message_text p').text()).to.equal('No related traces found'); });
describe("before questions are loaded into the store", () => { it("renders a loading message by default", () => { expect(questions.find("h1").text()).toMatch(/loading/i); }); });
beforeEach(() => { wrapper = mount(<Timer />); clock = sinon.useFakeTimers(); wrapper.findWhere(n => n.type() === 'button' && n.text() === 'Start').simulate('click'); });
it('check default message', () => { const app = mount(<App />); let txt = app.find('.message').text() expect(txt).toEqual("Form is Incomplete!"); });
test('it should render GreetingView a second time', () => { // nearly same test as above, just to make sure resetting the // backend mock works as expected backend.loadFromServer.mockImplementation(success => success('hello')); const component = mount(<GreetingView/>); // calls should still be one because we reset the mock // in beforeEach() expect(backend.loadFromServer.mock.calls).toHaveLength(1); expect(component.find('h1').text()).toEqual('hello'); expect(component.find('p')).toHaveLength(0); });
test('Header component has a header image and name', (t) => { t.pass( expect(wrapper.find('img').length).toEqual(1) ) t.pass( expect(wrapper.find('h1').text()).toEqual('Zendesk Test App') ) t.end() })
describe('<TitleHeader />', function(){ it('should render correctly', function(){ var title = "Hello World"; const component = renderer.create(<TitleHeader title={title}/>); const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); it('should have the correct title prop', function(){ var title = "New Title"; const component = mount(<TitleHeader title={title} />); expect(component.find('h1').text()).toEqual('New Title'); }); })
it('renders job list anchor link', () => { const wrapper = mount( <Provider store={store}> <Router> <App /> </Router> </Provider> ); const anchor = wrapper.find(Route).find('JobsListingContainer').find('Job').find('a').first(); expect(anchor.text() == "View"); })
describe('<Header/>', function() { it('should show title', function() { const title = 'Marvel Comics'; const wrapper = mount(<Header title={title}/>); assert(wrapper.find('.mdl-layout-title').text(), title); }) });
it("renders a character's name", () => { const store = createMockStore({ ...initialState, guessedCharacters: ['david'], }) const rendered = mount( <Provider store={store}> <Character name={'gavin'} /> </Provider> ) expect(rendered.text()).toMatch('Character: gavin') })
it("should render the Homepage for the logged in user without tasks", () => { const props = { isLoggedIn: true, username: "Jesse" } const app = mount(<App {...props} />) // Checking output expect(app.find(Home)).toHaveLength(1) expect(app.find('p').at(0).text()).toEqual("Welcome, Jesse!") expect(app.find('li')).toHaveLength(0) })
describe('<App />', () => { it('should display h1 tag', () => { const wrapper = mount(<App />) const h1 = wrapper.find('h1') assert.strictEqual(h1.length, 1) assert.strictEqual(h1.text(), 'Hello there') }) })
describe("app", () => { test("should render Hello World page", () => { const wrapper = mount( <MockedProvider> <App /> </MockedProvider> ); expect(wrapper.text()).toBe("Hello World"); }); });
it('displays the list of guessed characters', () => { const store = createMockStore({ ...initialState, guessedCharacters: ['david'], }) const rendered = mount( <Provider store={store}> <GuessedCharacters /> </Provider> ) expect(rendered.text()).toMatch('You have guessed: david') })
test('it should render GreetingView by default', () => { // Configure the mock. Make it return a fixed answer, // that should be rendered by the GreetingView backend.loadFromServer.mockImplementation(success => success('moin')); const component = mount(<GreetingView/>); // as backend.loadFromServer is a sync call (on our mock) // componentDidMount have been run at this point expect(backend.loadFromServer.mock.calls).toHaveLength(1); expect(component.find('h1').text()).toEqual('moin'); expect(component.find('p')).toHaveLength(0); });