Skip to content

Commit

Permalink
Merge branch '2.0' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed May 30, 2023
2 parents 87a661e + 20e3d4c commit ca98e30
Show file tree
Hide file tree
Showing 37 changed files with 3,850 additions and 4,072 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssembed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-file.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/TinyMCE_ssmedia.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

218 changes: 0 additions & 218 deletions client/src/components/AssetDropzone/tests/AssetDropzone-test.js

This file was deleted.

95 changes: 40 additions & 55 deletions client/src/components/BackButton/tests/BackButton-test.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,46 @@
/* global jest, describe, it, expect, beforeEach */
/* global jest, test, expect */

import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import { Component as BackButton } from '../BackButton';
import { render } from '@testing-library/react';

function makeProps(obj = {}) {
return {
onClick: () => null,
enlarged: false,
badge: {
status: 'success',
message: 'Test successful',
},
...obj
};
}

test('BackButton render() should render a badge when the badge property is defined', () => {
const { container } = render(
<BackButton {...makeProps()}/>
);
expect(container.querySelectorAll('.gallery__back-badge')).toHaveLength(1);
});

describe('BackButton', () => {
let props = null;

beforeEach(() => {
props = {
onClick: jest.fn(),
enlarged: false,
badge: {
status: 'success',
message: 'Test successful',
},
};
});

describe('render()', () => {
it('should render a badge when the badge property is defined', () => {
const item = ReactTestUtils.renderIntoDocument(
<BackButton {...props} />
);
let badge = null;
try {
badge = ReactTestUtils.scryRenderedDOMComponentsWithClass(item, 'gallery__back-badge')[0];
} catch (e) {
// something happened
}

expect(badge).toBeTruthy();
});

it('should not render a badge when the badge property is falsey', () => {
props.badge = null;
const item = ReactTestUtils.renderIntoDocument(
<BackButton {...props} />
);
let badge = null;
try {
badge = ReactTestUtils.scryRenderedDOMComponentsWithClass(item, 'gallery__back-badge')[0];
} catch (e) {
// something happened
}

expect(badge).toBeFalsy();
});

it('should have extra classes when "enlarged"', () => {
props.isDropping = true;
const item = ReactTestUtils.renderIntoDocument(
<BackButton {...props} />
);
const button = ReactTestUtils.scryRenderedDOMComponentsWithClass(item, 'gallery__back')[0];
test('BackButton render() should not render a badge when the badge property is falsey', () => {
const { container } = render(
<BackButton {...makeProps({
badge: null
})}
/>
);
expect(container.querySelectorAll('.gallery__back-badge')).toHaveLength(0);
});

expect(Array.from(button.classList)).toContain('gallery__back--droppable-hover');
});
});
test('BackButton render() should have extra classes when "enlarged"', () => {
const { container } = render(
<BackButton {...makeProps({
isDropping: true
})}
/>
);
const els = container.querySelectorAll('.gallery__back');
expect(els).toHaveLength(1);
expect(els[0].classList).toContain('gallery__back--droppable-hover');
});
Loading

0 comments on commit ca98e30

Please sign in to comment.