UNPKG

address-client

Version:

地址管理前台组件

57 lines (50 loc) 2.13 kB
import init from 'test/unit/init' import { TestUtil } from 'vue-client' import AddressAddAddress from 'src/components/AddressAddAddress' describe('AddressAddAddress: 添加地址', () => { let vm = null before(() => { init() }) after(function () { }) it('修改小区', async function() { vm = TestUtil.createTest(AddressAddAddress, {f_location: {f_locationType: 't_area', f_locationId: 1}}) vm.type = '小区' await vm.updata({id: 1}) }) it('添加根地址', async function() { vm = TestUtil.createTest(AddressAddAddress, {f_location: {f_locationType: 't_area', f_locationId: 1}}) assert.include(vm.$el.innerText, '位置类型:') vm.model.f_name = '1号楼' vm.model.f_type = '楼' let res = await vm.addChild() // 检查数据是否正确 res = await vm.$resetpost(`rs/sql/address_getAddress`, {data: {condition: `id=${res.data.id}`}}) assert.equal(res.data[0].f_name, '1号楼') assert.equal(res.data[0].f_type, '楼') }) it('添加子地址', async function() { vm = TestUtil.createTest(AddressAddAddress, {f_parentId: 1}) assert.include(vm.$el.innerText, '位置类型:') vm.model.f_name = '2单元' vm.model.f_type = '单元' let res = await vm.addChild() // 检查数据是否正确 res = await vm.$resetpost(`rs/sql/address_getAddress`, {data: {f_parentId: 1, condition: `id=${res.data.id}`}}) assert.equal(res.data[0].f_name, '2单元') assert.equal(res.data[0].f_type, '单元') }) it('修改地址', async function() { // 取到要修改的数据 let res = await vm.$resetpost(`rs/sql/address_getAddress`, {data: {condition: `id=2`}}) vm = TestUtil.createTest(AddressAddAddress, {row: res.data[0]}) assert.include(vm.$el.innerText, '位置类型:') vm.model.f_name = '8号楼' await vm.addChild() // 检查数据是否正确 res = await vm.$resetpost(`rs/sql/address_getAddress`, {data: {condition: `id=2`}}) assert.equal(res.data[0].f_name, '8号楼') assert.equal(res.data[0].f_type, '楼') }) })