Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should add a file type to the document registry', () => {
registry = new DocumentRegistry({ initialFileTypes: [] });
const fileType = { name: 'notebook', extensions: ['.ipynb'] };
registry.addFileType(fileType);
expect(registry.fileTypes().next().name).to.equal(fileType.name);
});
it('should get the registered file types', () => {
registry = new DocumentRegistry({ initialFileTypes: [] });
expect(toArray(registry.fileTypes()).length).to.equal(0);
const fileTypes = [
{ name: 'notebook', extensions: ['.ipynb'] },
{ name: 'python', extensions: ['.py'] },
{ name: 'table', extensions: ['.table.json'] }
];
registry.addFileType(fileTypes[0]);
registry.addFileType(fileTypes[1]);
registry.addFileType(fileTypes[2]);
const values = registry.fileTypes();
expect(values.next().name).to.equal(fileTypes[0].name);
expect(values.next().name).to.equal(fileTypes[1].name);
expect(values.next().name).to.equal(fileTypes[2].name);
});
});
it('should be a no-op if a file type of the same name is registered', () => {
registry = new DocumentRegistry({ initialFileTypes: [] });
const fileType = { name: 'notebook', extensions: ['.ipynb'] };
registry.addFileType(fileType);
const disposable = registry.addFileType(fileType);
disposable.dispose();
expect(registry.fileTypes().next().name).to.equal(fileType.name);
});
});
beforeEach(() => {
registry = new DocumentRegistry();
registry.addFileType({
name: 'foobar',
extensions: ['.foo.bar']
});
registry.addFileType({
name: 'baz',
extensions: ['.baz']
});
});