123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- import React from 'react';
- import {shallow} from 'enzyme';
- import ContextSummary, {
- OsSummary,
- GpuSummary,
- } from 'app/components/events/contextSummary';
- const CONTEXT_USER = {
- email: 'mail@example.org',
- id: '1',
- };
- const CONTEXT_DEVICE = {
- arch: 'x86',
- family: 'iOS',
- model: 'iPhone10,5',
- type: 'device',
- };
- const CONTEXT_OS = {
- kernel_version: '17.5.0',
- version: '10.13.4',
- type: 'os',
- build: '17E199',
- name: 'Mac OS X',
- };
- const CONTEXT_RUNTIME = {
- version: '1.7.13',
- type: 'runtime',
- name: 'Electron',
- };
- const CONTEXT_BROWSER = {
- version: '65.0.3325',
- name: 'Chrome',
- };
- describe('ContextSummary', function() {
- describe('render()', function() {
- it('should render nothing without contexts', () => {
- const event = {
- id: '',
- contexts: {},
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render nothing with a single user context', () => {
- const event = {
- id: '',
- user: CONTEXT_USER,
- contexts: {},
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should bail out with empty contexts', () => {
- const event = {
- id: '',
- user: CONTEXT_USER,
- contexts: {
- device: {},
- os: {},
- },
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render at least three contexts', () => {
- const event = {
- id: '',
- user: CONTEXT_USER,
- contexts: {
- device: CONTEXT_DEVICE,
- },
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render up to four contexts', () => {
- const event = {
- id: '',
- user: CONTEXT_USER,
- contexts: {
- os: CONTEXT_OS,
- browser: CONTEXT_BROWSER,
- runtime: CONTEXT_RUNTIME,
- device: CONTEXT_DEVICE, // must be omitted
- },
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should skip non-default named contexts', () => {
- const event = {
- id: '',
- user: CONTEXT_USER,
- contexts: {
- os: CONTEXT_OS,
- chrome: CONTEXT_BROWSER, // non-standard context
- runtime: CONTEXT_RUNTIME,
- device: CONTEXT_DEVICE,
- },
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should skip a missing user context', () => {
- const event = {
- id: '',
- contexts: {
- os: CONTEXT_OS,
- chrome: CONTEXT_BROWSER, // non-standard context
- runtime: CONTEXT_RUNTIME,
- device: CONTEXT_DEVICE,
- },
- };
- const wrapper = shallow(<ContextSummary event={event} />);
- expect(wrapper).toMatchSnapshot();
- });
- });
- });
- describe('OsSummary', function() {
- describe('render()', function() {
- it('should render the version string', () => {
- const os = {
- kernel_version: '17.5.0',
- version: '10.13.4',
- type: 'os',
- build: '17E199',
- name: 'Mac OS X',
- };
- const wrapper = shallow(<OsSummary data={os} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render the kernel version when no version', () => {
- const os = {
- kernel_version: '17.5.0',
- type: 'os',
- build: '17E199',
- name: 'Mac OS X',
- };
- const wrapper = shallow(<OsSummary data={os} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render unknown when no version', () => {
- const os = {
- type: 'os',
- build: '17E199',
- name: 'Mac OS X',
- };
- const wrapper = shallow(<OsSummary data={os} />);
- expect(wrapper).toMatchSnapshot();
- });
- });
- });
- describe('GpuSummary', function() {
- describe('render()', function() {
- it('should render name and vendor', () => {
- const gpu = {
- name: 'Mali-T880',
- vendor_name: 'ARM',
- version: 'OpenGL ES 3.2 v1.r22p0-01rel0.f294e54ceb2cb2d81039204fa4b0402e',
- };
- const wrapper = shallow(<GpuSummary data={gpu} />);
- expect(wrapper).toMatchSnapshot();
- });
- it('should render unknown when no vendor', () => {
- const gpu = {
- type: 'gpu',
- name: 'Apple A8 GPU',
- };
- const wrapper = shallow(<GpuSummary data={gpu} />);
- expect(wrapper).toMatchSnapshot();
- });
- });
- });
|