Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('emits toggleTreeOpen on click', () => {
const fileName = 't3';
createComponent({
file: {
...file(fileName),
type: 'tree',
},
level: 0,
});
jest.spyOn(wrapper.vm, '$emit');
wrapper.element.click();
expect(wrapper.vm.$emit).toHaveBeenCalledWith('toggleTreeOpen', fileName);
});
it('indents row based on level', () => {
createComponent({
file: file('t4'),
level: 2,
});
expect(wrapper.find('.file-row-name').element.style.marginLeft).toBe('32px');
});
it('renders name', () => {
const fileName = 't4';
createComponent({
file: file(fileName),
level: 0,
});
const name = wrapper.find('.file-row-name');
expect(name.text().trim()).toEqual(fileName);
});
it('matches the current route against encoded file URL', () => {
const fileName = 'with space';
const rowFile = { ...file(fileName), url: `/${fileName}` };
const routerPath = `/project/${escapeFileUrl(fileName)}`;
createComponent(
{
file: rowFile,
level: 0,
},
{
currentRoute: {
path: routerPath,
},
},
);
expect(wrapper.vm.hasUrlAtCurrentRoute()).toBe(true);
});
it('does not render a title attribute if no tree present', () => {
createComponent({
file: file('f1.txt'),
level: 0,
});
expect(wrapper.element.title.trim()).toEqual('');
});
beforeEach((done) => {
createComponent({
files: [
{
...file('index.js'),
path: 'index.js',
type: 'blob',
url: '/index.jsurl',
},
{
...file('component.js'),
path: 'component.js',
type: 'blob',
},
],
});
setImmediate(done);
});
beforeEach((done) => {
createComponent({
files: [
{
...file('index.js'),
path: 'index.js',
type: 'blob',
url: '/index.jsurl',
},
{
...file('component.js'),
path: 'component.js',
type: 'blob',
},
],
});
setImmediate(done);
});