import * as core from '@pluralsight/ps-design-system-core' import { render } from '@testing-library/react' import React from 'react' import Shave from '../shave' jest.mock('shave') describe('Shave', () => { let shaveFn: jest.Mock beforeEach(() => { shaveFn = require('shave') }) it('shaves on initial mount', () => { const character = '…' const lineHeight = parseInt(core.type.lineHeightStandard, 10) const lines = 3 render(some text string) expect(shaveFn).toHaveBeenCalledWith( expect.anything(), lineHeight * lines, { character } ) }) it('is configurable', () => { const character = '... read more' const lineHeight = 10 const lines = 10 render( some text string ) expect(shaveFn).toHaveBeenCalledWith( expect.anything(), lineHeight * lines, { character } ) }) it('updates on window resize', () => { render(some text string) shaveFn.mockClear() global.dispatchEvent(new Event('resize')) expect(shaveFn).toHaveBeenCalled() }) })