Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('handles delayed parsing of rows past the initial rows', async () => {
const d = new DSVModel({
data: `a,b,c\nc,d,e\nf,g,h\ni,j,k`,
delimiter: ',',
initialRows: 2
});
expect(d.rowCount('column-header')).to.equal(1);
expect(d.rowCount('body')).to.equal(1);
expect(d.columnCount('row-header')).to.equal(1);
expect(d.columnCount('body')).to.equal(3);
expect([0, 1, 2].map(i => d.data('column-header', 0, i))).to.deep.equal([
'a',
'b',
'c'
]);
// Expected behavior is that all unparsed data is lumped into the final field.
expect([0, 1, 2].map(i => d.data('body', 0, i))).to.deep.equal([
function activateCsv(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
themeManager: IThemeManager,
mainMenu: IMainMenu,
searchregistry: ISearchProviderRegistry = null
): void {
const factory = new CSVViewerFactory({
name: FACTORY_CSV,
fileTypes: ['csv'],
defaultFor: ['csv'],
readOnly: true
});
const tracker = new InstanceTracker>({
namespace: 'csvviewer'
});
// The current styles for the data grids.
let style: DataGrid.IStyle = Private.LIGHT_STYLE;
let rendererConfig: TextRenderConfig = Private.LIGHT_TEXT_CONFIG;
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
function activateCsv(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
themeManager: IThemeManager,
mainMenu: IMainMenu,
searchregistry: ISearchProviderRegistry = null
): void {
const factory = new CSVViewerFactory({
name: FACTORY_CSV,
fileTypes: ['csv'],
defaultFor: ['csv'],
readOnly: true
});
const tracker = new WidgetTracker>({
namespace: 'csvviewer'
});
// The current styles for the data grids.
let style: DataGrid.IStyle = Private.LIGHT_STYLE;
let rendererConfig: TextRenderConfig = Private.LIGHT_TEXT_CONFIG;
// Handle state restoration.
void restorer.restore(tracker, {
command: 'docmanager:open',
function activateTsv(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
themeManager: IThemeManager,
mainMenu: IMainMenu,
searchregistry: ISearchProviderRegistry = null
): void {
const factory = new TSVViewerFactory({
name: FACTORY_TSV,
fileTypes: ['tsv'],
defaultFor: ['tsv'],
readOnly: true
});
const tracker = new InstanceTracker>({
namespace: 'tsvviewer'
});
// The current styles for the data grids.
let style: DataGrid.IStyle = Private.LIGHT_STYLE;
let rendererConfig: TextRenderConfig = Private.LIGHT_TEXT_CONFIG;
// Handle state restoration.
restorer.restore(tracker, {
command: 'docmanager:open',
function activateTsv(
app: JupyterFrontEnd,
restorer: ILayoutRestorer,
themeManager: IThemeManager,
mainMenu: IMainMenu,
searchregistry: ISearchProviderRegistry = null
): void {
const factory = new TSVViewerFactory({
name: FACTORY_TSV,
fileTypes: ['tsv'],
defaultFor: ['tsv'],
readOnly: true
});
const tracker = new WidgetTracker>({
namespace: 'tsvviewer'
});
// The current styles for the data grids.
let style: DataGrid.IStyle = Private.LIGHT_STYLE;
let rendererConfig: TextRenderConfig = Private.LIGHT_TEXT_CONFIG;
// Handle state restoration.
void restorer.restore(tracker, {
command: 'docmanager:open',
it('should be the number of columns in the region', () => {
let model = new CSVModel({ content: CSV_DATA });
expect(model.columnCount('row-header')).to.be(1);
expect(model.columnCount('body')).to.be(4);
});
it('should instantiate a `CSVModel`', () => {
let model = new CSVModel();
expect(model).to.be.a(CSVModel);
});
it('should be the number of rows in the region', () => {
let model = new CSVModel({ content: CSV_DATA });
expect(model.rowCount('column-header')).to.be(1);
expect(model.rowCount('body')).to.be(1002);
});
it('should accept content and delimiter values', () => {
let content = 'foo';
let delimiter = '\t';
let model = new CSVModel({ content, delimiter });
expect(model).to.be.a(CSVModel);
expect(model.content).to.be(content);
expect(model.delimiter).to.be(delimiter);
});
it('should be settable', () => {
let model = new CSVModel({ content: CSV_DATA });
expect(model.content).to.be(CSV_DATA);
model.content = 'foo';
expect(model.content).to.be('foo');
});