debian-mirror-gitlab/spec/frontend/notebook/cells/output/dataframe_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-06-20 00:43:36 +05:30
import { shallowMount } from '@vue/test-utils';
import DataframeOutput from '~/notebook/cells/output/dataframe.vue';
import JSONTable from '~/behaviors/components/json_table.vue';
import { outputWithDataframe } from '../../mock_data';
describe('~/notebook/cells/output/DataframeOutput', () => {
let wrapper;
function createComponent(rawCode) {
wrapper = shallowMount(DataframeOutput, {
propsData: {
rawCode,
count: 0,
index: 0,
},
});
}
const findTable = () => wrapper.findComponent(JSONTable);
describe('with valid dataframe', () => {
beforeEach(() => createComponent(outputWithDataframe.data['text/html'].join('')));
it('mounts the table', () => {
expect(findTable().exists()).toBe(true);
});
it('table caption is empty', () => {
expect(findTable().props().caption).toEqual('');
});
it('allows filtering', () => {
expect(findTable().props().hasFilter).toBe(true);
});
it('sets the correct fields', () => {
expect(findTable().props().fields).toEqual([
2023-07-09 08:55:56 +05:30
{ key: 'index0', label: '', sortable: true, class: 'gl-font-weight-bold' },
{ key: 'column0', label: 'column_1', sortable: true, class: '' },
{ key: 'column1', label: 'column_2', sortable: true, class: '' },
2023-06-20 00:43:36 +05:30
]);
});
it('sets the correct items', () => {
expect(findTable().props().items).toEqual([
2023-07-09 08:55:56 +05:30
{ index0: '0', column0: 'abc de f', column1: 'a' },
{ index0: '1', column0: 'True', column1: '0.1' },
2023-06-20 00:43:36 +05:30
]);
});
});
describe('invalid dataframe', () => {
it('still displays the table', () => {
createComponent('dataframe');
expect(findTable().exists()).toBe(true);
});
});
});