relateStoreDialog.spec.js 1.15 KB
import { shallowMount } from "@vue/test-utils";
import RelateStoreDialog from "./relateStoreDialog.vue";

describe("purchase shelves merchant dialog", () => {
	it("shows merchant address immediately after merchant name", async () => {
		const wrapper = shallowMount(RelateStoreDialog, {
			propsData: {
				storeApi: jest.fn().mockResolvedValue({ list: [], total: 0 }),
			},
			stubs: {
				"d2-dialog": { template: "<div><slot /></div>" },
				"el-button": { template: "<button><slot /></button>" },
				"el-pagination": true,
				"el-row": { template: "<div><slot /></div>" },
				"el-table": { template: "<div><slot /></div>" },
				"el-table-column": {
					props: ["label", "prop"],
					template: "<div class='merchant-column' :data-label='label' :data-prop='prop'></div>",
				},
			},
		});
		await wrapper.vm.$nextTick();

		const columnProps = wrapper.findAll(".merchant-column").wrappers.map(column => column.attributes("data-prop"));
		const addressColumn = wrapper.find("[data-prop='address']");

		expect(columnProps.slice(1, 4)).toEqual(["merchantName", "address", "merchantId"]);
		expect(addressColumn.attributes("data-label")).toBe("商户地址");
	});
});