GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#29)
by
unknown
02:19
created

tests/unit/vueCsvImport.spec.js   A

Complexity

Total Complexity 12
Complexity/F 1

Size

Lines of Code 76
Function Count 12

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 50
mnd 0
bc 0
fnc 12
dl 0
loc 76
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import { shallowMount, createLocalVue } from '@vue/test-utils';
2
import { VueCsvImportPlugin } from '../../src/index';
3
import VueCsvImport from '../../src/components/VueCsvImport';
4
5
describe('VueCsvImport', () => {
6
    let wrapper, objWrapper;
7
    const localVue = createLocalVue();
8
    const csv = [["name", "age", "grade"], ["Susan", "41", "a"], ["Mike", "5", "b"], ["Jake", "33", "c"], ["Jill", "30", "d"]];
9
    const sample = [["name", "age", "grade"], ["Susan", "41", "a"]];
10
    const sampleCapitalized = [["Name", "Age", "Grade"], ["Susan", "41", "a"]];
11
    const map = { "name": 0, "age": 1 };
12
    const fields = [{ key: "name", label: "name" }, { key: "age", label: "age" }]
13
14
    beforeEach(() => {
15
        wrapper = shallowMount(VueCsvImport, { propsData: { mapFields: ['name_map', 'age_map', 'grade_map'], url: '/hello' } });
16
        objWrapper = shallowMount(VueCsvImport, { propsData: { value: [], mapFields: { name: 'Name', age: 'Age' } } });
17
    });
18
19
    it('is a Vue instance', () => {
20
        expect(wrapper.isVueInstance()).toBeTruthy();
21
    });
22
23
    it('installs as plugin', () => {
24
        localVue.use(VueCsvImportPlugin);
25
        expect(localVue.options.components["VueCsvImport"]).toBeDefined();
26
    });
27
28
    it('has expected html', () => {
29
        expect(wrapper.vm.$el).toMatchSnapshot();
30
    });
31
32
    it('has expected map fields when array', () => {
33
        expect(wrapper.vm.fieldsToMap).toEqual([{ "key": "name_map", "label": "name_map" }, { "key": "age_map", "label": "age_map" }, { "key": "grade_map", "label": "grade_map" }]);
34
    });
35
36
    it('has expected map fields when object', () => {
37
        expect(objWrapper.vm.fieldsToMap).toEqual([{ "key": "name", "label": "Name" }, { "key": "age", "label": "Age" }]);
38
    });
39
40
    it('headers prop removes checkbox and use headers', () => {
41
        objWrapper.setData({ hasHeaders: true });
42
        expect(objWrapper.vm.hasHeaders).toEqual(true);
43
        expect(objWrapper.vm.$el).toMatchSnapshot();
44
    });
45
46
    it('headers prop removes checkbox and not use headers', () => {
47
        objWrapper.setData({ hasHeaders: false });
48
        expect(objWrapper.vm.hasHeaders).toEqual(false);
49
        expect(objWrapper.vm.$el).toMatchSnapshot();
50
    });
51
52
    it('can map when passed fields are an object', () => {
53
        objWrapper.setData({ hasHeaders: true, sample: sample, csv: csv, map: map });
54
        objWrapper.vm.submit();
55
        expect(objWrapper.emitted().input[0][0]).toEqual([{ "name": "Susan", "age": "41" }, { "name": "Mike", "age": "5" }, { "name": "Jake", "age": "33" }, {
56
            "name": "Jill",
57
            "age": "30"
58
        }]);
59
    });
60
61
    it('can map when passed fields are an array', () => {
62
        wrapper.setData({ hasHeaders: true, sample: sample, csv: csv, map: map });
63
        wrapper.vm.submit();
64
        expect(wrapper.emitted().input[0][0]).toEqual([{ "name": "Susan", "age": "41" }, { "name": "Mike", "age": "5" }, { "name": "Jake", "age": "33" }, {
65
            "name": "Jill",
66
            "age": "30"
67
        }]);
68
    });
69
70
    it('validates mime types', () => {
71
        wrapper.setData({ hasHeaders: true, sample: sample, csv: csv, map: map });
72
        expect(wrapper.vm.validateMimeType('peanut')).toEqual(false);
73
        expect(wrapper.vm.validateMimeType('text/csv')).toEqual(true);
74
        expect(wrapper.vm.validateMimeType('text/x-csv')).toEqual(true);
75
        expect(wrapper.vm.validateMimeType('application/vnd.ms-excel')).toEqual(true);
76
        expect(wrapper.vm.validateMimeType('text/plain')).toEqual(true);
77
    });
78
79
    it('automatically maps fields when cases match', async () => {
80
        objWrapper.setProps({ autoMatchFields: true })
81
        objWrapper.setData({ hasHeaders: true, sample: sampleCapitalized, csv: csv, fieldsToMap: fields });
82
        expect(objWrapper.vm.map).toEqual({"age": 1, "name": 0});
83
    })
84
    it('automatically maps fields when cases do not match', async () => {
85
        objWrapper.setProps({ autoMatchFields: true, autoMatchIgnoreCase: true })
86
        objWrapper.setData({ hasHeaders: true, sample: sample, csv: csv, fieldsToMap: fields });
87
        expect(objWrapper.vm.map).toEqual({"age": 1, "name": 0});
88
    })
89
});
90