Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(acc as any)[key] = value;
} else {
(acc as any)[key] = (defaultDirs as any)[key];
}
return acc;
},
{}
)
} as JupyterFrontEnd.IPaths;
if (this._info.devMode) {
this.shell.addClass('jp-mod-devMode');
}
// Add initial model factory.
this.docRegistry.addModelFactory(new Base64ModelFactory());
if (options.mimeExtensions) {
for (let plugin of createRendermimePlugins(options.mimeExtensions)) {
this.registerPlugin(plugin);
}
}
}
it('should get a registered model factory by name', () => {
const mFactory = new Base64ModelFactory();
registry.addModelFactory(mFactory);
expect(registry.getModelFactory('base64')).to.equal(mFactory);
});
});
it('should get the name of the model type', () => {
const factory = new Base64ModelFactory();
expect(factory.name).to.equal('base64');
});
});
it('should get a widget factory by name', () => {
registry.addModelFactory(new Base64ModelFactory());
const factory = createFactory();
registry.addWidgetFactory(factory);
const mdFactory = new WidgetFactory({
name: 'markdown',
fileTypes: ['markdown']
});
registry.addWidgetFactory(mdFactory);
expect(registry.getWidgetFactory(factory.name)).to.equal(factory);
expect(registry.getWidgetFactory('markdown')).to.equal(mdFactory);
expect(registry.getWidgetFactory('baz')).to.be.undefined;
});
});
it('should get the file type', () => {
const factory = new Base64ModelFactory();
expect(factory.contentType).to.equal('file');
});
});
it('should get the name of the model type', () => {
const factory = new Base64ModelFactory();
expect(factory.name).to.equal('base64');
});
});
it('should be a no-op a factory with the given `name` is already registered', () => {
const factory = new Base64ModelFactory();
registry.addModelFactory(factory);
const disposable = registry.addModelFactory(new Base64ModelFactory());
disposable.dispose();
});
it('should get the name of the model type', () => {
let factory = new Base64ModelFactory();
expect(factory.name).to.be('base64');
});
it('should be a no-op a factory with the given `name` is already registered', () => {
let factory = new Base64ModelFactory();
registry.addModelFactory(factory);
let disposable = registry.addModelFactory(new Base64ModelFactory());
disposable.dispose();
});
activate: (): IDocumentRegistry => {
let registry = new DocumentRegistry();
registry.addModelFactory(new TextModelFactory());
registry.addModelFactory(new Base64ModelFactory());
registry.addFileType({
name: 'Text',
extension: '.txt',
contentType: 'file',
fileFormat: 'text'
});
registry.addCreator({ name: 'Text File', fileType: 'Text', });
return registry;
}
};