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', () => {
fileHash: 'test',
key: 'index.js',
name: 'index.js',
path: 'index.js',
truncatedPath: '../index.js',
path: 'app/index.js',
removedLines: 0,
tempFile: true,
type: 'blob',
......@@ -105,7 +104,7 @@ describe('Diffs tree list component', () => {
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 => {
......@@ -122,7 +121,7 @@ describe('Diffs tree list component', () => {
vm.renderTreeList = false;
vm.$nextTick(() => {
expect(vm.$el.querySelector('.file-row').textContent).toContain('../index.js');
expect(vm.$el.querySelector('.file-row').textContent).toContain('app/index.js');
done();
});
......@@ -144,8 +143,7 @@ describe('Diffs tree list component', () => {
const blurEvent = new Event('blur');
vm.focusSearch = true;
vm
.$nextTick()
vm.$nextTick()
.then(() => {
vm.$el.querySelector('.form-control').dispatchEvent(blurEvent);
})
......
......@@ -470,7 +470,6 @@ describe('DiffsStoreUtils', () => {
{
key: 'app',
path: 'app',
truncatedPath: 'app',
name: 'app',
type: 'tree',
tree: [
......@@ -482,7 +481,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/index.js',
name: 'index.js',
path: 'app/index.js',
truncatedPath: 'app/index.js',
removedLines: 10,
tempFile: false,
type: 'blob',
......@@ -491,7 +489,6 @@ describe('DiffsStoreUtils', () => {
{
key: 'app/test',
path: 'app/test',
truncatedPath: 'app/test',
name: 'test',
type: 'tree',
opened: true,
......@@ -504,7 +501,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/test/index.js',
name: 'index.js',
path: 'app/test/index.js',
truncatedPath: 'app/test/index.js',
removedLines: 0,
tempFile: true,
type: 'blob',
......@@ -518,7 +514,6 @@ describe('DiffsStoreUtils', () => {
key: 'app/test/filepathneedstruncating.js',
name: 'filepathneedstruncating.js',
path: 'app/test/filepathneedstruncating.js',
truncatedPath: '...est/filepathneedstruncating.js',
removedLines: 0,
tempFile: true,
type: 'blob',
......@@ -532,7 +527,6 @@ describe('DiffsStoreUtils', () => {
{
key: 'package.json',
path: 'package.json',
truncatedPath: 'package.json',
name: 'package.json',
type: 'blob',
changed: true,
......
......@@ -71,4 +71,40 @@ describe('RepoFile', () => {
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