Commit ef22b0dc authored by Tim Zallmann's avatar Tim Zallmann

Title has now its own test

parent 705a840d
...@@ -8,14 +8,17 @@ describe('RepoFile', () => { ...@@ -8,14 +8,17 @@ describe('RepoFile', () => {
icon: 'icon', icon: 'icon',
url: 'url', url: 'url',
name: 'name', name: 'name',
pageTitle: 'pageTitle',
lastCommitMessage: 'message', lastCommitMessage: 'message',
lastCommitUpdate: Date.now(), lastCommitUpdate: Date.now(),
level: 10, level: 10,
}; };
const activeFile = { const activeFile = {
url: 'activeUrl',
pageTitle: 'pageTitle', pageTitle: 'pageTitle',
url: 'url',
};
const otherFile = {
html: '<p class="file-content">html</p>',
pageTitle: 'otherpageTitle',
}; };
function createComponent(propsData) { function createComponent(propsData) {
...@@ -31,7 +34,6 @@ describe('RepoFile', () => { ...@@ -31,7 +34,6 @@ describe('RepoFile', () => {
}); });
it('renders link, icon, name and last commit details', () => { it('renders link, icon, name and last commit details', () => {
RepoStore.setActiveFiles(activeFile);
const vm = createComponent({ const vm = createComponent({
file, file,
activeFile, activeFile,
...@@ -44,7 +46,6 @@ describe('RepoFile', () => { ...@@ -44,7 +46,6 @@ describe('RepoFile', () => {
expect(name.title).toEqual(file.url); expect(name.title).toEqual(file.url);
expect(name.href).toMatch(`/${file.url}`); expect(name.href).toMatch(`/${file.url}`);
expect(name.textContent.trim()).toEqual(file.name); expect(name.textContent.trim()).toEqual(file.name);
expect(document.title.trim()).toEqual(activeFile.pageTitle);
expect(vm.$el.querySelector('.commit-message').textContent.trim()).toBe(file.lastCommitMessage); expect(vm.$el.querySelector('.commit-message').textContent.trim()).toBe(file.lastCommitMessage);
expect(vm.$el.querySelector('.commit-update').textContent.trim()).toBe(updated); expect(vm.$el.querySelector('.commit-update').textContent.trim()).toBe(updated);
expect(fileIcon.classList.contains(file.icon)).toBeTruthy(); expect(fileIcon.classList.contains(file.icon)).toBeTruthy();
...@@ -65,6 +66,12 @@ describe('RepoFile', () => { ...@@ -65,6 +66,12 @@ describe('RepoFile', () => {
expect(vm.$el.querySelector('.fa-spin.fa-spinner')).toBeFalsy(); expect(vm.$el.querySelector('.fa-spin.fa-spinner')).toBeFalsy();
}); });
it('sets the document title correctly', () => {
RepoStore.setActiveFiles(otherFile);
expect(document.title.trim()).toEqual(otherFile.pageTitle);
});
it('renders a spinner if the file is loading', () => { it('renders a spinner if the file is loading', () => {
file.loading = true; file.loading = true;
const vm = createComponent({ const vm = createComponent({
......
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