Skip to content

Commit

Permalink
Add AutocompleteEditor snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arisgk committed Sep 16, 2017
1 parent 5285c6c commit 3422b11
Show file tree
Hide file tree
Showing 2 changed files with 1,315 additions and 0 deletions.
104 changes: 104 additions & 0 deletions src/components/Home/AutocompleteEditor/AutocompleteEditor.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* global jest, describe, it, expect */
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import AutocompleteEditor from './AutocompleteEditor';

// -- https://github.com/facebook/draft-js/issues/702
jest.mock('draft-js/lib/generateRandomKey', () => () => '123');

describe('AutocompleteEditor', () => {
it('renders correctly', () => {
let mentionSuggestions = [];
let hashtagSuggestions = [];
let relationSuggestions = [];

let wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();

mentionSuggestions = [
{
name: 'Matthew Yorke',
title: 'Senior Software Engineer',
avatar: 'https://pbs.twimg.com/profile_images/517863945/mattsailing_400x400.jpg',
},
{
name: 'Julian Smith',
title: 'United Kingdom',
avatar: 'https://avatars2.githubusercontent.com/u/1188186?v=3&s=400',
},
];

wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();

mentionSuggestions = [];
wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();

hashtagSuggestions = [
{
name: 'nba',
},
{
name: 'sweet',
},
];

wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();

relationSuggestions = [
{
name: 'Meta',
},
{
name: 'Oculus',
},
];

wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();

hashtagSuggestions = [];
relationSuggestions = [];
wrapper = shallow(
<AutocompleteEditor
mentionSuggestions={mentionSuggestions}
hashtagSuggestions={hashtagSuggestions}
relationSuggestions={relationSuggestions}
/>,
);
expect(toJson(wrapper)).toMatchSnapshot();
});
});
Loading

0 comments on commit 3422b11

Please sign in to comment.