|
1 | 1 | import React from 'react'; |
2 | 2 |
|
| 3 | +import PeopleJSONAdapter from '../../adapters/PeopleJSONAdapter'; |
| 4 | +import {PersonStatus} from '../../adapters/PeopleAdapter'; |
| 5 | +import person from '../../data/people'; |
| 6 | + |
3 | 7 | import WebexAvatar from './WebexAvatar'; |
4 | 8 |
|
5 | | -describe('Webex Avatar component:', () => { |
6 | | - let wrapper; |
| 9 | +describe('Webex Avatar component', () => { |
| 10 | + let personID, peopleJSONAdapter; |
7 | 11 |
|
8 | 12 | beforeEach(() => { |
9 | | - wrapper = shallow(<WebexAvatar />); |
| 13 | + [personID] = Object.keys(person); |
| 14 | + peopleJSONAdapter = new PeopleJSONAdapter(person); |
| 15 | + global.console.error = jest.fn(); |
| 16 | + }); |
| 17 | + |
| 18 | + test('matches snapshot with "default" status', () => { |
| 19 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 20 | + }); |
| 21 | + |
| 22 | + test(`matches snapshot with "${PersonStatus.ACTIVE}" person status`, () => { |
| 23 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.ACTIVE; |
| 24 | + |
| 25 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 26 | + }); |
| 27 | + |
| 28 | + test(`matches snapshot with "${PersonStatus.BOT}" person status`, () => { |
| 29 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.BOT; |
| 30 | + |
| 31 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 32 | + }); |
| 33 | + test(`matches snapshot with "${PersonStatus.CALL}" person status`, () => { |
| 34 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.CALL; |
| 35 | + |
| 36 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 37 | + }); |
| 38 | + |
| 39 | + test(`matches snapshot with "${PersonStatus.DO_NOT_DISTURB}" person status`, () => { |
| 40 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.DO_NOT_DISTURB; |
| 41 | + |
| 42 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 43 | + }); |
| 44 | + |
| 45 | + test(`matches snapshot with "${PersonStatus.INACTIVE}" person status`, () => { |
| 46 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.INACTIVE; |
| 47 | + |
| 48 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
10 | 49 | }); |
11 | 50 |
|
12 | | - test('exists', () => { |
13 | | - expect(wrapper).toMatchSnapshot(); |
| 51 | + test(`matches snapshot with "${PersonStatus.MEETING}" person status`, () => { |
| 52 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.MEETING; |
| 53 | + |
| 54 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 55 | + }); |
| 56 | + |
| 57 | + test(`matches snapshot with "${PersonStatus.OUT_OF_OFFICE}" person status`, () => { |
| 58 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.OUT_OF_OFFICE; |
| 59 | + |
| 60 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 61 | + }); |
| 62 | + |
| 63 | + test(`matches snapshot with "${PersonStatus.PRESENTING}" person status`, () => { |
| 64 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.PRESENTING; |
| 65 | + |
| 66 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 67 | + }); |
| 68 | + |
| 69 | + test(`matches snapshot with "${PersonStatus.SELF}" person status`, () => { |
| 70 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.SELF; |
| 71 | + |
| 72 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 73 | + }); |
| 74 | + |
| 75 | + test(`matches snapshot with "${PersonStatus.TYPING}" person status`, () => { |
| 76 | + peopleJSONAdapter.datasource[personID].status = PersonStatus.TYPING; |
| 77 | + |
| 78 | + expect(shallow(<WebexAvatar personID={personID} adapter={peopleJSONAdapter} />)).toMatchSnapshot(); |
| 79 | + }); |
| 80 | + |
| 81 | + test('throws error with inappropriate personID', () => { |
| 82 | + shallow(<WebexAvatar personID="Wrong PersonID" adapter={peopleJSONAdapter} />); |
| 83 | + |
| 84 | + expect(global.console.error).toHaveBeenCalledWith('Could not find person with ID "Wrong PersonID"'); |
14 | 85 | }); |
15 | 86 |
|
16 | 87 | afterEach(() => { |
17 | | - wrapper = null; |
| 88 | + personID = null; |
| 89 | + peopleJSONAdapter = null; |
| 90 | + global.console.error = null; |
18 | 91 | }); |
19 | 92 | }); |
0 commit comments