Commit 1f63581a authored by Thomas Randolph's avatar Thomas Randolph

Ensure that the image size always appears

...regardless of the diffMode that occurred
parent 88648d16
...@@ -112,6 +112,7 @@ export default { ...@@ -112,6 +112,7 @@ export default {
<div class="image"> <div class="image">
<image-viewer <image-viewer
:path="imagePath" :path="imagePath"
:file-size="isNew ? newSize : oldSize"
:inner-css-classes="[ :inner-css-classes="[
'frame', 'frame',
{ {
......
...@@ -9,6 +9,11 @@ describe('ImageDiffViewer', () => { ...@@ -9,6 +9,11 @@ describe('ImageDiffViewer', () => {
newPath: GREEN_BOX_IMAGE_URL, newPath: GREEN_BOX_IMAGE_URL,
oldPath: RED_BOX_IMAGE_URL, oldPath: RED_BOX_IMAGE_URL,
}; };
const allProps = {
...requiredProps,
oldSize: 2048,
newSize: 1024,
};
let vm; let vm;
function createComponent(props) { function createComponent(props) {
...@@ -50,9 +55,11 @@ describe('ImageDiffViewer', () => { ...@@ -50,9 +55,11 @@ describe('ImageDiffViewer', () => {
}); });
it('renders image diff for replaced', done => { it('renders image diff for replaced', done => {
createComponent(requiredProps); createComponent({ ...allProps });
setTimeout(() => { setTimeout(() => {
const metaInfoElements = vm.$el.querySelectorAll('.image-info');
expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL); expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL);
expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(RED_BOX_IMAGE_URL); expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(RED_BOX_IMAGE_URL);
...@@ -66,35 +73,35 @@ describe('ImageDiffViewer', () => { ...@@ -66,35 +73,35 @@ describe('ImageDiffViewer', () => {
'Onion skin', 'Onion skin',
); );
expect(metaInfoElements.length).toBe(2);
expect(metaInfoElements[0]).toHaveText('2.00 KiB');
expect(metaInfoElements[1]).toHaveText('1.00 KiB');
done(); done();
}); });
}); });
it('renders image diff for new', done => { it('renders image diff for new', done => {
createComponent( createComponent({ ...allProps, diffMode: 'new', oldPath: '' });
Object.assign({}, requiredProps, {
diffMode: 'new',
oldPath: '',
}),
);
setTimeout(() => { setTimeout(() => {
const metaInfoElement = vm.$el.querySelector('.image-info');
expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL); expect(vm.$el.querySelector('.added img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL);
expect(metaInfoElement).toHaveText('1.00 KiB');
done(); done();
}); });
}); });
it('renders image diff for deleted', done => { it('renders image diff for deleted', done => {
createComponent( createComponent({ ...allProps, diffMode: 'deleted', newPath: '' });
Object.assign({}, requiredProps, {
diffMode: 'deleted',
newPath: '',
}),
);
setTimeout(() => { setTimeout(() => {
const metaInfoElement = vm.$el.querySelector('.image-info');
expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(RED_BOX_IMAGE_URL); expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(RED_BOX_IMAGE_URL);
expect(metaInfoElement).toHaveText('2.00 KiB');
done(); done();
}); });
...@@ -105,24 +112,38 @@ describe('ImageDiffViewer', () => { ...@@ -105,24 +112,38 @@ describe('ImageDiffViewer', () => {
components: { components: {
imageDiffViewer, imageDiffViewer,
}, },
data: {
...allProps,
diffMode: 'renamed',
},
template: ` template: `
<image-diff-viewer diff-mode="renamed" new-path="${GREEN_BOX_IMAGE_URL}" old-path=""> <image-diff-viewer
:diff-mode="diffMode"
:new-path="newPath"
:old-path="oldPath"
:new-size="newSize"
:old-size="oldSize"
>
<span slot="image-overlay" class="overlay">test</span> <span slot="image-overlay" class="overlay">test</span>
</image-diff-viewer> </image-diff-viewer>
`, `,
}).$mount(); }).$mount();
setTimeout(() => { setTimeout(() => {
const metaInfoElement = vm.$el.querySelector('.image-info');
expect(vm.$el.querySelector('img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL); expect(vm.$el.querySelector('img').getAttribute('src')).toBe(GREEN_BOX_IMAGE_URL);
expect(vm.$el.querySelector('.overlay')).not.toBe(null); expect(vm.$el.querySelector('.overlay')).not.toBe(null);
expect(metaInfoElement).toHaveText('2.00 KiB');
done(); done();
}); });
}); });
describe('swipeMode', () => { describe('swipeMode', () => {
beforeEach(done => { beforeEach(done => {
createComponent(requiredProps); createComponent({ ...requiredProps });
setTimeout(() => { setTimeout(() => {
done(); done();
...@@ -141,7 +162,7 @@ describe('ImageDiffViewer', () => { ...@@ -141,7 +162,7 @@ describe('ImageDiffViewer', () => {
describe('onionSkin', () => { describe('onionSkin', () => {
beforeEach(done => { beforeEach(done => {
createComponent(requiredProps); createComponent({ ...requiredProps });
setTimeout(() => { setTimeout(() => {
done(); done();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment