text: /* eslint-disable no-undef */
  import { shallowMount, createLocalVue } from '@vue/test-utils'
  import importWords from '@/pages/import-words/component/index.vue'
  import elementUI from 'element-ui'
  import { Database } from '@/utils/database.js'
  import Vuex from 'vuex'
  const Dexie = require('dexie')
  Dexie.dependencies.indexedDB = require('fake-indexeddb')
  Dexie.dependencies.IDBKeyRange = require('fake-indexeddb/lib/FDBKeyRange')
  const localVue = createLocalVue()
  localVue.use(Vuex)
  localVue.use(elementUI)
  
  const networks = [
    {
      name: 'Filcoin Mainnet',
      rpc: 'https://api.fivetoken.io',
      chainID: '',
      symbol: 'FIL',
      ids: 'filecoin',
      browser: 'https://filscan.io',
      khazix: 'khazix',
      create_time: 1631613194,
      networkType: 'proxy',
      filecoinAddress0: 'f',
      decimals: 18,
      disabled: true,
      image: 'fil.svg',
      deriveIndex: 0
    },
    {
      name: 'Filecoin Calibration Testnet',
      rpc: 'https://api.calibration.fivetoken.io',
      chainID: '',
      symbol: 'FIL',
      ids: 'filecoin',
      browser: 'https://calibration.filscan.io',
      khazix: 'khazix',
      networkType: 'proxy',
      filecoinAddress0: 't',
      create_time: 1631613195,
      decimals: 18,
      image: 'fil.svg',
      disabled: true,
      deriveIndex: 0
    },
    {
      name: 'Binance TEST',
      rpc: 'https://data-seed-prebsc-1-s1.binance.org:8545',
      chainID: '56',
      symbol: 'BNB',
      ids: 'binancecoin',
      browser: 'https://testnet.bscscan.com',
      khazix: 'khazix',
      networkType: 'ethereum',
      filecoinAddress0: '',
      create_time: 1631613196,
      decimals: 18,
      image: 'bnb.svg',
      disabled: true,
      deriveIndex: 0
    }
  ]
  
  describe('importWords index.vue', () => {
    const assignMock = jest.fn()
    delete window.location
    window.location = { assign: assignMock }
    afterEach(() => {
      assignMock.mockClear()
    })
    const db = new Database()
    const store = new Vuex.Store({
      modules: {
        app: {
          state: {
            address: 'f1ntv4qlgoi55wqqxrxxolatfdgn7xvu7vfhrkcfq',
            rpc: 'https://api.fivetoken.io',
            networkType: 'proxy',
            symbol: 'FIL',
            filecoinAddress0: 'f',
            deriveIndex: 1,
            accountList: [
              {
                accountName: 'Account1',
                address: 'f1ntv4qlgoi55wqqxrxxolatfdgn7xvu7vfhrkcfq',
                createType: 'mnemonic',
                create_time: 1631613193,
                digest: 'zBUjeDDJuuDAPNQF',
                fil: 0,
                id: 1,
                isDelete: 0,
                khazix: 'khazix',
                privateKey: '98b983395737275c208f5b6884180cbc7575e7c208dba4621da300fc5248046ec7224a209285b4e9e770fa1e',
                rpc: 'https://api.fivetoken.io'
              }
            ],
            networks: networks
          },
          mutations: {
            SET_PRIVATEKEY: (state, data) => {
              state.privateKey = data
            },
            SET_ADDRESS: (state, data) => {
              state.address = data
            },
            SET_DIGEST: (state, data) => {
              state.digest = data
            },
            SET_ACCOUNTNAME: (state, data) => {
              state.accountName = data
            },
            SET_DERIVEINDEX: (state, data) => {
              state.deriveIndex = data
            }
          },
          namespaced: true
        }
      }
    })
  
    Object.defineProperty(window, 'location', {
      value: {
        href: './setting.html',
        search: '?mnemonicWords=robot%20sort%20steak%20cart%20banana%20bracket%20cat%20mass%20room%20success%20tackle%20rival&accountName=Account1&password=Aa123456&createType=create'
      }
    })
  
    const wrapper = shallowMount(importWords, {
      store,
      localVue,
      data () {
        return {
          error: false,
          db
        }
      },
      mocks: {
        $t: key => key,
        $router: {
          go: key => key
        }
      },
      stubs: {
        'el-dialog': true
      }
    })
  
    it('index.vue-test', async () => {
      wrapper.vm.layoutMounted()
  
      await wrapper.vm.importWallet()
      wrapper.vm.focus()
      expect(wrapper.vm.error).toBe(false)
  
      wrapper.vm.mnemonicWordsChange('words')
      expect(wrapper.vm.form.mnemonicWords).toBe('words')
  
      const accountName = wrapper.vm.getQuery('accountName')
      expect(accountName).toBe('Account1')
  
      await wrapper.vm.back()
      wrapper.vm.back()
      const back = wrapper.vm.$router.go(-1)
      expect(back).toBe(-1)
    })
  })
  