Commit ecb7c534 authored by Eric Eastwood's avatar Eric Eastwood
parent f1e1113b
......@@ -42,19 +42,20 @@ const RepoSidebar = {
file.loading = false;
} else {
Service.url = file.url;
// I need to refactor this to do the `then` here.
// Not a callback. For now this is good enough.
// it works.
Helper.getContent(file, () => {
Helper.getContent(file)
.then(() => {
file.loading = false;
Helper.scrollTabsRight();
});
})
.catch(Helper.loadingError);
}
},
goToPreviousDirectoryClicked(prevURL) {
Service.url = prevURL;
Helper.getContent(null, () => Helper.scrollTabsRight());
Helper.getContent(null)
.then(() => Helper.scrollTabsRight())
.catch(Helper.loadingError);
},
},
};
......
......@@ -135,14 +135,13 @@ const RepoHelper = {
return isRoot;
},
getContent(treeOrFile, cb) {
getContent(treeOrFile) {
let file = treeOrFile;
// const loadingData = RepoHelper.setLoading(true);
return Service.getContent()
.then((response) => {
const data = response.data;
// RepoHelper.setLoading(false, loadingData);
if (cb) cb();
Store.isTree = RepoHelper.isTree(data);
if (!Store.isTree) {
if (!file) file = data;
......
......@@ -64,9 +64,10 @@ describe('RepoSidebar', () => {
describe('methods', () => {
describe('fileClicked', () => {
it('should fetch data for new file', () => {
spyOn(Helper, 'getContent');
spyOn(Helper, 'getContent').and.callThrough();
const file1 = {
id: 0,
url: '',
};
RepoStore.files = [file1];
RepoStore.isRoot = true;
......@@ -74,7 +75,7 @@ describe('RepoSidebar', () => {
vm.fileClicked(file1);
expect(Helper.getContent).toHaveBeenCalledWith(file1, jasmine.any(Function));
expect(Helper.getContent).toHaveBeenCalledWith(file1);
});
it('should hide files in directory if already open', () => {
......
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