Commit 9fd5a78d authored by Phil Hughes's avatar Phil Hughes

Fixed failing specs

Added tests to file row truncated text computed prop
parent d95465db
...@@ -53,8 +53,7 @@ describe('Diffs tree list component', () => { ...@@ -53,8 +53,7 @@ describe('Diffs tree list component', () => {
fileHash: 'test', fileHash: 'test',
key: 'index.js', key: 'index.js',
name: 'index.js', name: 'index.js',
path: 'index.js', path: 'app/index.js',
truncatedPath: '../index.js',
removedLines: 0, removedLines: 0,
tempFile: true, tempFile: true,
type: 'blob', type: 'blob',
...@@ -105,7 +104,7 @@ describe('Diffs tree list component', () => { ...@@ -105,7 +104,7 @@ describe('Diffs tree list component', () => {
vm.$el.querySelector('.file-row').click(); vm.$el.querySelector('.file-row').click();
expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'index.js'); expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/scrollToFile', 'app/index.js');
}); });
it('renders as file list when renderTreeList is false', done => { it('renders as file list when renderTreeList is false', done => {
...@@ -122,7 +121,7 @@ describe('Diffs tree list component', () => { ...@@ -122,7 +121,7 @@ describe('Diffs tree list component', () => {
vm.renderTreeList = false; vm.renderTreeList = false;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.querySelector('.file-row').textContent).toContain('../index.js'); expect(vm.$el.querySelector('.file-row').textContent).toContain('app/index.js');
done(); done();
}); });
...@@ -144,8 +143,7 @@ describe('Diffs tree list component', () => { ...@@ -144,8 +143,7 @@ describe('Diffs tree list component', () => {
const blurEvent = new Event('blur'); const blurEvent = new Event('blur');
vm.focusSearch = true; vm.focusSearch = true;
vm vm.$nextTick()
.$nextTick()
.then(() => { .then(() => {
vm.$el.querySelector('.form-control').dispatchEvent(blurEvent); vm.$el.querySelector('.form-control').dispatchEvent(blurEvent);
}) })
......
...@@ -470,7 +470,6 @@ describe('DiffsStoreUtils', () => { ...@@ -470,7 +470,6 @@ describe('DiffsStoreUtils', () => {
{ {
key: 'app', key: 'app',
path: 'app', path: 'app',
truncatedPath: 'app',
name: 'app', name: 'app',
type: 'tree', type: 'tree',
tree: [ tree: [
...@@ -482,7 +481,6 @@ describe('DiffsStoreUtils', () => { ...@@ -482,7 +481,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/index.js', key: 'app/index.js',
name: 'index.js', name: 'index.js',
path: 'app/index.js', path: 'app/index.js',
truncatedPath: 'app/index.js',
removedLines: 10, removedLines: 10,
tempFile: false, tempFile: false,
type: 'blob', type: 'blob',
...@@ -491,7 +489,6 @@ describe('DiffsStoreUtils', () => { ...@@ -491,7 +489,6 @@ describe('DiffsStoreUtils', () => {
{ {
key: 'app/test', key: 'app/test',
path: 'app/test', path: 'app/test',
truncatedPath: 'app/test',
name: 'test', name: 'test',
type: 'tree', type: 'tree',
opened: true, opened: true,
...@@ -504,7 +501,6 @@ describe('DiffsStoreUtils', () => { ...@@ -504,7 +501,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/test/index.js', key: 'app/test/index.js',
name: 'index.js', name: 'index.js',
path: 'app/test/index.js', path: 'app/test/index.js',
truncatedPath: 'app/test/index.js',
removedLines: 0, removedLines: 0,
tempFile: true, tempFile: true,
type: 'blob', type: 'blob',
...@@ -518,7 +514,6 @@ describe('DiffsStoreUtils', () => { ...@@ -518,7 +514,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/test/filepathneedstruncating.js', key: 'app/test/filepathneedstruncating.js',
name: 'filepathneedstruncating.js', name: 'filepathneedstruncating.js',
path: 'app/test/filepathneedstruncating.js', path: 'app/test/filepathneedstruncating.js',
truncatedPath: '...est/filepathneedstruncating.js',
removedLines: 0, removedLines: 0,
tempFile: true, tempFile: true,
type: 'blob', type: 'blob',
...@@ -532,7 +527,6 @@ describe('DiffsStoreUtils', () => { ...@@ -532,7 +527,6 @@ describe('DiffsStoreUtils', () => {
{ {
key: 'package.json', key: 'package.json',
path: 'package.json', path: 'package.json',
truncatedPath: 'package.json',
name: 'package.json', name: 'package.json',
type: 'blob', type: 'blob',
changed: true, changed: true,
......
...@@ -71,4 +71,40 @@ describe('RepoFile', () => { ...@@ -71,4 +71,40 @@ describe('RepoFile', () => {
expect(vm.$el.querySelector('.file-row-name').style.marginLeft).toBe('32px'); expect(vm.$el.querySelector('.file-row-name').style.marginLeft).toBe('32px');
}); });
describe('outputText', () => {
beforeEach(done => {
createComponent({
file: {
...file(),
path: 'app/assets/index.js',
},
level: 0,
});
vm.displayTextKey = 'path';
vm.$nextTick(done);
});
it('returns text if truncateStart is 0', done => {
vm.truncateStart = 0;
vm.$nextTick(() => {
expect(vm.outputText).toBe('app/assets/index.js');
done();
});
});
it('returns text truncated at start', done => {
vm.truncateStart = 5;
vm.$nextTick(() => {
expect(vm.outputText).toBe('...ssets/index.js');
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