all files / tests/unit/ uploader.spec.js

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                                                                           
import chai, { expect } from "chai";
import Vue from 'vue'
import sinon from 'sinon'
import sinonChai from 'sinon-chai'
chai.use(sinonChai)
import { shallowMount, mount } from "@vue/test-utils"
import Uploader from "@/uploader";
import http from '../../src/http'
describe("Uploader.vue", () => {
    it('存在.', () => {
        expect(Uploader).to.exist
    })
    // it('可以上传一个文件', (done) => {
    //     const wrapper = mount(Uploader, {
    //         propsData: {
    //             name: 'file',
    //             action: '/upload',
    //             parseResponse: (res) => {
    //                 const data = JSON.parse(res)
    //                 console.log(123)
    //                 return `/upload/${data.key}`
    //             },
    //             fileList: []
    //         },
    //         slots: {
    //             default: `<span id="x">上传</span>`
    //         },
    //         listeners: {
    //             'update:fileList': (fileList) => {
    //                 console.log(fileList)
    //                 wrapper.setProps({ fileList })
    //             }
    //         }
    //     })
    //     wrapper.find('#x').trigger('click')
    //     let wrapperInput = wrapper.find('input[type="file"]')
    //     let input = wrapperInput.element
    //     let file1 = new File(['xxxx'], 'xxx.txt')
    //     let file2 = new File(['yyyy'], 'yyy.txt')
 
    //     const data = new DataTransfer()
    //     data.items.add(file1)
    //     data.items.add(file2)
    //     input.files = data.files
    //     var evt = document.createEvent("HTMLEvents");
    //     evt.initEvent("change", false, true);
    //     input.dispatchEvent(evt);
    //     setTimeout(() => {
    //         console.log(wrapper.html())
    //         let use = wrapper.find('.imgItem').find('use').element
    //         // expect(use.getAttribute('xlink:href')).to.eq('#i-loading')
    //         expect(wrapper.find('img').exists()).to.eq(true)
    //         done()
    //     },1000)
    // })
 
});