UNPKG

@salesforce/design-system-react

Version:

Salesforce Lightning Design System for React

89 lines (86 loc) 3.03 kB
import React from 'react'; import chai, { expect } from 'chai'; import chaiEnzyme from 'chai-enzyme'; import { mount } from 'enzyme'; import sinon from 'sinon'; import IconSettings from '../../../components/icon-settings'; import SplitViewListbox, { SORT_OPTIONS } from '../../../components/split-view/listbox'; chai.use(chaiEnzyme()); var listOptions = [{ id: 'option1', label: 'Riley Shultz', topRightText: '99', bottomLeftText: 'Biotech, Inc.', bottomRightText: 'Nurturing' }, { id: 'option2', label: 'Jason A. - VP of Sales', topRightText: '92', bottomLeftText: 'Case Management Solutions', bottomRightText: 'Contacted' }, { id: 'option3', label: 'Josh Smith', topRightText: '90', bottomLeftText: 'Acme, Inc.', bottomRightText: 'Contacted' }, { id: 'option4', label: 'Bobby Tree', topRightText: '89', bottomLeftText: 'Salesforce, Inc.', bottomRightText: 'Closing' }]; describe('SLDSSplitView - Listbox header', function () { var component; var WrappedComponent = function WrappedComponent(props) { return /*#__PURE__*/React.createElement(IconSettings, { iconPath: "/assets/icons" }, /*#__PURE__*/React.createElement(SplitViewListbox, props)); }; var mountComponent = function mountComponent(props) { return mount( /*#__PURE__*/React.createElement(WrappedComponent, props)); }; var props = { options: listOptions, unread: [listOptions[1], listOptions[3]], labels: { header: 'test header' }, assistiveText: { sort: { sortedBy: 'test sort by', descending: 'test descending', ascending: 'test ascending' }, unreadItem: 'test unread' }, sortDirection: SORT_OPTIONS.DOWN, events: { onSort: sinon.spy(), onSelect: function onSelect(event, _ref) { var selectedItems = _ref.selectedItems; component.setProps({ selection: selectedItems }); } } }; beforeEach(function () { component = mountComponent(props); }); it('should have unread', function () { expect(component.find('li').at(0).prop('className')).to.not.contain('slds-is-unread'); expect(component.find('li').at(1).prop('className')).to.contain('slds-is-unread'); expect(component.find('li').at(2).prop('className')).to.not.contain('slds-is-unread'); expect(component.find('li').at(3).prop('className')).to.contain('slds-is-unread'); expect(component.find('.slds-indicator_unread')).to.have.length(2); }); it('should have unread assistive text', function () { expect(component.find('.slds-indicator_unread').at(0).prop('title')).to.equal('test unread'); expect(component.find('.slds-indicator_unread').at(1).prop('title')).to.equal('test unread'); expect(component.find('.slds-indicator_unread').at(0).prop('aria-label')).to.equal('test unread'); expect(component.find('.slds-indicator_unread').at(1).prop('aria-label')).to.equal('test unread'); }); }); //# sourceMappingURL=split-view.listbox.unread.browser-test.js.map