text: /* eslint-env mocha */
  const assert = require('assert')
  const TestHelper = require('../../../test-helper.js')
  const ScreenshotData = require('../../../screenshot-data.js')
  
  describe('/administrator/delete-schedule', () => {
    describe('before', () => {
      it('should bind data to req', async () => {
        const administrator = await TestHelper.createOwner()
        const user = await TestHelper.createUser()
        await TestHelper.setDeleted(user)
        const user2 = await TestHelper.createUser()
        await TestHelper.setDeleted(user2)
        const req = TestHelper.createRequest('/administrator/delete-schedule')
        req.account = administrator.account
        req.session = administrator.session
        await req.route.api.before(req)
        assert.strictEqual(req.data.accounts.length, global.pageSize)
        assert.strictEqual(req.data.accounts[0].accountid, user2.account.accountid)
        assert.strictEqual(req.data.accounts[1].accountid, user.account.accountid)
      })
    })
  
    describe('view', () => {
      it('should present the deleted accounts table (screenshots)', async () => {
        const administrator = await TestHelper.createOwner()
        const user = await TestHelper.createUser()
        await TestHelper.setDeleted(user)
        const req = TestHelper.createRequest('/administrator/delete-schedule')
        req.account = administrator.account
        req.session = administrator.session
        req.filename = __filename
        req.screenshots = [
          { hover: '#administrator-menu-container' },
          { click: '/administrator' },
          { click: '/administrator/delete-schedule' }
        ]
        global.pageSize = 50
        global.packageJSON.dashboard.server.push(ScreenshotData.administratorIndex)
        const result = await req.get()
        const doc = TestHelper.extractDoc(result.html)
        const row = doc.getElementById(user.account.accountid)
        assert.strictEqual(row.tag, 'tr')
      })
  
      it('should return one page', async () => {
        const administrator = await TestHelper.createOwner()
        for (let i = 0, len = global.pageSize + 1; i < len; i++) {
          const user = await TestHelper.createUser()
          await TestHelper.setDeleted(user)
        }
        const req = TestHelper.createRequest('/administrator/delete-schedule')
        req.account = administrator.account
        req.session = administrator.session
        const result = await req.get()
        const doc = TestHelper.extractDoc(result.html)
        const table = doc.getElementById('accounts-table')
        const rows = table.getElementsByTagName('tr')
        assert.strictEqual(rows.length, global.pageSize + 1)
      })
  
      it('should change page size', async () => {
        global.pageSize = 3
        const administrator = await TestHelper.createOwner()
        for (let i = 0, len = global.pageSize + 1; i < len; i++) {
          const user = await TestHelper.createUser()
          await TestHelper.setDeleted(user)
        }
        const req = TestHelper.createRequest('/administrator/delete-schedule')
        req.account = administrator.account
        req.session = administrator.session
        const result = await req.get()
        const doc = TestHelper.extractDoc(result.html)
        const table = doc.getElementById('accounts-table')
        const rows = table.getElementsByTagName('tr')
        assert.strictEqual(rows.length, global.pageSize + 1)
      })
  
      it('should change offset', async () => {
        const offset = 1
        const administrator = await TestHelper.createOwner()
        const users = []
        for (let i = 0, len = global.pageSize + 1; i < len; i++) {
          const user = await TestHelper.createUser()
          await TestHelper.setDeleted(user)
          users.unshift(user.account.accountid)
        }
        const req = TestHelper.createRequest(`/administrator/delete-schedule?offset=${offset}`)
        req.account = administrator.account
        req.session = administrator.session
        const result = await req.get()
        const doc = TestHelper.extractDoc(result.html)
        for (let i = 0, len = global.pageSize; i < len; i++) {
          assert.strictEqual(doc.getElementById(users[offset + i]).tag, 'tr')
        }
      })
    })
  })
  