import { render } from '@stencil/vitest';
import { mutationObserverMock } from '../../../utils/tests/mutation-observer.mock';
global.MutationObserver = mutationObserverMock;
describe('ontario-blockquote', () => {
describe('snapshot', () => {
it('should render the expected html', async () => {
const page = await render(
``,
);
expect(page.root).toMatchSnapshot();
});
});
it('should render a byline when the byline prop is passed', async () => {
const page = await render(
`This is a test quote`,
);
expect(page.root).toEqualHtml(`
This is a test quote
DS Tech Team
The best team at the ODS!
This is a test quote
`);
});
it('should reflect attributes/props being set', async () => {
const page = await render(
``,
);
expect(page.instance.quote).toBe('This is another test quote');
expect(page.instance.attribution).toBe('DS Tech Team');
expect(page.instance.byline).toBe('Ontario Digital Service');
});
it('should set the shortQuote state to `true` when the character count is under 140', async () => {
const page = await render(
``,
);
expect(page.instance.shortQuote).toBe(true);
});
it('should set the shortQuote state to `false` when the character count is over 140', async () => {
const page = await render(
`I saw this movie about a bus that had to speed around a city, keeping its speed over fifty, and if its speed dropped, it would explode! I think it was called, "The Bus That Couldn’t Slow Down".`,
);
expect(page.instance.shortQuote).toBe(false);
});
});