QUnit Test

这篇博客详细介绍了如何使用QUnit进行单元测试,特别是针对一个名为`invDetailController`的控制器方法进行了深入的测试。测试涵盖了`onInit`、`_routeMatchedFun`、`_getDetailPageInfoDataFun`等多个关键函数,确保了代码的正确性和覆盖率。此外,还涉及到数据转换、消息处理和对话框操作等场景的测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*global QUnit*/
sap.ui.define(
    [
        'sbinv-monitor-ui/test/unit/axios/invDetail',
        'sap/ui/thirdparty/sinon',
        'sap/ui/thirdparty/sinon-qunit'
    ],
    function (detailData) {
        'use strict';

        QUnit.module('Detail controller', {
            beforeEach: function () {
                this.invDetailController = sap.ui.controller(
                    'sbinv-monitor-ui/controller/InvDetail'
                );
                sap.ushell.Container = {
                    getService: function () {
                        return {
                            constants: {
                                keyCategory: {
                                    FIXED_KEY: 'fixed'
                                },
                                writeFrequency: {
                                    LOW: 'low'
                                }
                            },
                            getContainer: function () {
                                return {
                                    fail: function (cb) {
                                        cb();
                                    },
                                    done: function (cb) {
                                        cb({
                                            save: function () {
                                                return {
                                                    done: function () {}
                                                };
                                            }
                                        });
                                    }
                                };
                            }
                        };
                    },
                    getUser: function () {
                        return {
                            getEmail: function () {}
                        };
                    }
                };
                sap.ushell.services = {
                    Personalization: {
                        VariantSetAdapter: function () {
                            return {
                                getVariantSet: function () {
                                    return {
                                        addVariant: function () {
                                            return {
                                                setItemValue: function () {},
                                                getVariantKey: function () {}
                                            };
                                        },
                                        delVariant: function () {},
                                        getVariant: function () {
                                            return {
                                                setItemValue: function () {},
                                                getItemValue: function () {
                                                    return [];
                                                }
                                            };
                                        },
                                        setCurrentVariantKey: function () {},
                                        getCurrentVariantKey: function () {},
                                        getVariantNamesAndKeys: function () {
                                            return {
                                                key: 'name'
                                            };
                                        }
                                    };
                                },
                                addVariantSet: function () {
                                    return {};
                                }
                            };
                        }
                    }
                };
                sap.ui.comp = {
                    variants: {
                        VariantItem: function () {}
                    }
                };

                this.invDetailController.displayChangeTableConstructor =
                    detailData.displayChangeTableConstructor;
                this.invDetailController.itemSectionTableConstructor =
                    detailData.itemSectionTableConstructor;

                this.invDetailController.objectPageDataBak = {
                    objectPageHeaderDto: {
                        referencedDeliveryNumber: '',
                        overAllStatus: '',
                        issueType: '',
                        referencedSalesOrganization: '',
                        referencedSalesOrganizationName: '',
                        referencedSoldToPartyNumberFromDelivery: '',
                        referenceSapCurrency: 'USD',
                        documentNetValueDifferentTotal: ''
                    },
                    objectPageAddInfoDto: {
                        documentLastChangeBy: '',
                        documentLastChangeDate: ''
                    }
                };

                this.invDetailController.language = 'en';
                this.invDetailController.editBtnInstance = {
                    setVisible: function () {}
                };
                this.invDetailController.deactivatedButton = {
                    setVisible: function () {},
                    getVisible: function () {
                        return true;
                    },
                    focus: function () {}
                };
                this.invDetailController.displayChangesButton = {
                    setVisible: function () {},
                    getVisible: function () {
                        return true;
                    },
                    focus: function () {}
                };
                this.invDetailController.objectPage = {
                    setShowFooter: function () {},
                    setBusy: function () {}
                };

                this.invDetailController.sectionMessage = {
                    setVisible: function () {},
                    setText: function () {}
                };
                this.invDetailController.headerDataSectionTable = {
                    destroyColumns: function () {
                        return { mBindingInfos: {} };
                    },
                    addColumn: function () {},
                    bindItems: function () {
                        return {
                            setKeyboardMode: function () {}
                        };
                    }
                };

                this.invDetailController.itemSectionTable = {
                    destroyColumns: function () {},
                    addColumn: function () {},
                    bindItems: function () {
                        return {
                            setKeyboardMode: function () {}
                        };
                    },
                    getBinding: function () {
                        return {
                            sort: function () {},
                            filter: function () {}
                        };
                    }
                };

                this.invDetailController.itemTableVariant = {
                    setModel: function () {},
                    addVariantItem: function () {},
                    removeVariantItem: function () {},
                    getItemByKey: function () {
                        return {
                            setProperty: function () {}
                        };
                    },
                    setDefaultVariantKey: function () {},
                    fireSelect: function () {},
                    setStandardFavorite: function () {}
                };

                this.invDetailController.mappingParams = {};

                this.invDetailController.oContainer = {
                    save: function () {
                        return {
                            done: function () {}
                        };
                    }
                };

                this.invDetailController.reassignItemsTable = {
                    getSelectedContexts: function () {
                        return {
                            map: function () {
                                return ['b2efbfac-993b-47ad-b91d-17478a5989f5'];
                            }
                        };
                    },
                    removeSelections: function () {}
                };
                this.invDetailController.displayChangeTable = {
                    destroyColumns: function () {},
                    addColumn: function () {},
                    bindItems: function () {
                        return {
                            setKeyboardMode: function () {}
                        };
                    },
                    getBinding: function () {
                        return {
                            sort: function () {},
                            filter: function () {}
                        };
                    }
                };

                this.invDetailController.overViewModel = {
                    setProperty: function () {},
                    getProperty: function () {}
                };

                this.invDetailController.headerDataSectionTableModel = {
                    setProperty: function () {},
                    getProperty: function () {
                        return {
                            columnsItems: [
                                {
                                    columnKey: 'transferredData',
                                    demandPopin: true,
                                    index: 1,
                                    minScreenWidth: 'Tablet',
                                    popinDisplay: 'Inline',
                                    text: '{i18n>transferredData}',
                                    visible: true,
                                    width: '15em'
                                },
                                {
                                    columnKey: 'referenceDocumentData',
                                    demandPopin: true,
                                    index: 2,
                                    minScreenWidth: 'Tablet',
                                    popinDisplay: 'Inline',
                                    text: '{i18n>referenceData}',
                                    visible: true,
                                    width: '15em'
                                }
                            ],
                            filter: function () {
                                return [
                                    {
                                        columnKey: 'name',
                                        index: 0,
                                        text: '{i18n>highlightedFieldName}',
                                        visible: true,
                                        width: '20em'
                                    },
                                    {
                                        columnKey: 'transferredData',
                                        demandPopin: true,
                                        index: 1,
                                        minScreenWidth: 'Tablet',
                                        popinDisplay: 'Inline',
                                        text: '{i18n>transferredData}',
                                        visible: true,
                                        width: '15em'
                                    },
                                    {
                                        columnKey: 'referenceDocumentData',
                                        demandPopin: true,
                                        index: 2,
                                        minScreenWidth: 'Tablet',
                                        popinDisplay: 'Inline',
                                        text: '{i18n>referenceData}',
                                        visible: true,
                                        width: '15em'
                                    }
                                ];
                            }
                        };
                    }
                };

                this.invDetailController.setItemSectionTableModel = {
                    setProperty: function () {},
                    getProperty: function () {
                        return {
                            filter: function () {
                                return [];
                            }
                        };
                    }
                };
                this.invDetailController.sdDocumentKey = 'cbb37bde-5c36-4152-905a-2b1807b541d4';
                this.invDetailController.newDestination = {
                    host: 'http://ccw-715-api.wdf.sap.corp:443',
                    billing: '',
                    delivery: ''
                };
                this.invDetailController.itemSectionTableModel = {
                    setProperty: function () {},
                    getProperty: function () {
                        return {
                            columnsItems: [
                                {
                                    columnKey: 'technicalItemNumber',
                                    text: '{i18n>NUMBER}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'default',
                                    visible: true,
                                    index: 0,
                                    width: '4rem'
                                },
                                {
                                    columnKey: 'transferredMaterial',
                                    text: '{i18n>TRANSMITTED_PRODUCT}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'editable',
                                    validation: '^[\\S\\s]\\{0,40}$',
                                    errorText:
                                        'this.ownerComponent._getI18nTextFun("MAX_LENGTH", ["40"])',
                                    visible: true,
                                    index: 1
                                },
                                {
                                    columnKey: 'referenceMaterial',
                                    text: '{i18n>PRODUCT}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'default',
                                    visible: true,
                                    index: 1
                                },
                                {
                                    columnKey: 'transmittedCustomerMaterial',
                                    text: '{i18n>TRANSMITTED_CUSTOMER_MATERIAL}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'editable',
                                    validation: '^[\\S\\s]\\{0,35}$',
                                    errorText:
                                        'this.ownerComponent._getI18nTextFun("MAX_LENGTH", ["40"])',
                                    visible: true,
                                    index: 2
                                },
                                {
                                    columnKey: 'referenceCustomerMaterial',
                                    text: '{i18n>CUSTOMER_MATERIAL}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'default',
                                    visible: true,
                                    index: 2
                                },
                                {
                                    columnKey: 'itemNetValueDifference',
                                    text: '{i18n>NET_VALUE_DIFFERENCE}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'referencedCurrency',
                                    visible: true,
                                    index: 3
                                },
                                {
                                    columnKey: 'transferredItemNetValue',
                                    text: '{i18n>TRANSMITTED_NET_VALUE}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'transmittedCurrency',
                                    visible: true,
                                    index: 4
                                },
                                {
                                    columnKey: 'simulatedNetValue',
                                    text: '{i18n>INTERNAL_NET_VALUE}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'referencedCurrency',
                                    visible: true,
                                    index: 5
                                },
                                {
                                    columnKey: 'itemTaxAmountDifference',
                                    text: '{i18n>TAX_AMOUNT_DIFFERENCE}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'referencedCurrency',
                                    visible: true,
                                    index: 6
                                },
                                {
                                    columnKey: 'transferredItemTaxAmount',
                                    text: '{i18n>TRANSMITTED_TAX_AMOUNT}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'transmittedCurrency',
                                    visible: true,
                                    index: 7
                                },
                                {
                                    columnKey: 'simulatedTaxAmount',
                                    text: '{i18n>INTERNAL_TAX_AMOUNT}',
                                    importance: sap.ui.core.Priority.None,
                                    type: 'currency',
                                    currency: 'referencedCurrency',
                                    visible: true,
                                    index: 8
                                },

                                {
                                    columnKey: 'transferredQuantity',
                                    text: '{i18n>TRANSMITTED_QUANTITY}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'objectNumber',
                                    currency: 'transmittedUom',
                                    visible: true,
                                    index: 9
                                },
                                {
                                    columnKey: 'referenceQuantity',
                                    text: '{i18n>INTERNAL_QUANTITY}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'objectNumber',
                                    currency: 'referencedUom',
                                    visible: true,
                                    index: 10
                                },
                                {
                                    columnKey: 'openQuantity',
                                    text: '{i18n>OPEN_QUANTITY}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'objectNumber',
                                    currency: 'referencedUom',
                                    visible: true,
                                    index: 11
                                },
                                {
                                    columnKey: 'itemQuantityDifference',
                                    text: '{i18n>QUANTITY_DIFFERENCE}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'objectNumber',
                                    currency: 'referencedUom',
                                    visible: true,
                                    index: 12
                                },
                                {
                                    columnKey: 'referenceDocumentItem',
                                    text: '{i18n>REFERENCE_ITEM}',
                                    importance: sap.ui.core.Priority.Low,
                                    type: 'default',
                                    visible: true,
                                    index: 13
                                }
                            ],
                            sortItems: { columnKey: 'quantity', operation: 'Descending' },
                            filterItems: {
                                columnKey: 'quantity',
                                exclude: false,
                                key: 'condition_0',
                                keyField: 'quantity',
                                operation: 'EQ',
                                showIfGrouped: true,
                                value1: '2',
                                value2: null
                            },
                            temp: [],
                            filter: function () {
                                return [
                                    {
                                        columnKey: 'technicalItemNumber',
                                        text: '{i18n>NUMBER}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'default',
                                        visible: true,
                                        index: 0,
                                        width: '4rem'
                                    },
                                    {
                                        columnKey: 'transferredMaterial',
                                        text: '{i18n>TRANSMITTED_PRODUCT}',
                                        importance: sap.ui.core.Priority.Low,
                                        type: 'editable',
                                        validation: '^[\\S\\s]\\{0,40}$',
                                        errorText:
                                            'this.ownerComponent._getI18nTextFun("MAX_LENGTH", ["40"])',
                                        visible: true,
                                        index: 1
                                    },
                                    {
                                        columnKey: 'referenceMaterial',
                                        text: '{i18n>PRODUCT}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'link',
                                        visible: true,
                                        index: 1
                                    },
                                    {
                                        columnKey: 'transferredQuantity',
                                        text: '{i18n>TRANSMITTED_QUANTITY}',
                                        importance: sap.ui.core.Priority.Low,
                                        type: 'objectNumber',
                                        currency: 'transmittedUom',
                                        visible: true,
                                        index: 9
                                    },
                                    {
                                        columnKey: 'transmittedCustomerMaterial',
                                        text: '{i18n>TRANSMITTED_CUSTOMER_MATERIAL}',
                                        importance: sap.ui.core.Priority.Low,
                                        type: 'icon-display',
                                        validation: '^[\\S\\s]\\{0,35}$',
                                        errorText:
                                            'this.ownerComponent._getI18nTextFun("MAX_LENGTH", ["40"])',
                                        visible: true,
                                        index: 2
                                    },
                                    {
                                        columnKey: 'referenceCustomerMaterial',
                                        text: '{i18n>CUSTOMER_MATERIAL}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'default',
                                        visible: true,
                                        index: 2
                                    },
                                    {
                                        columnKey: 'itemNetValueDifference',
                                        text: '{i18n>NET_VALUE_DIFFERENCE}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'referencedCurrency',
                                        visible: true,
                                        index: 3
                                    },
                                    {
                                        columnKey: 'transferredItemNetValue',
                                        text: '{i18n>TRANSMITTED_NET_VALUE}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'transmittedCurrency',
                                        visible: true,
                                        index: 4
                                    },
                                    {
                                        columnKey: 'simulatedNetValue',
                                        text: '{i18n>INTERNAL_NET_VALUE}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'referencedCurrency',
                                        visible: true,
                                        index: 5
                                    },
                                    {
                                        columnKey: 'itemTaxAmountDifference',
                                        text: '{i18n>TAX_AMOUNT_DIFFERENCE}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'referencedCurrency',
                                        visible: true,
                                        index: 6
                                    },
                                    {
                                        columnKey: 'transferredItemTaxAmount',
                                        text: '{i18n>TRANSMITTED_TAX_AMOUNT}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'transmittedCurrency',
                                        visible: true,
                                        index: 7
                                    },
                                    {
                                        columnKey: 'simulatedTaxAmount',
                                        text: '{i18n>INTERNAL_TAX_AMOUNT}',
                                        importance: sap.ui.core.Priority.None,
                                        type: 'currency',
                                        currency: 'referencedCurrency',
                                        visible: true,
                                        index: 8
                                    },
                                    {
                                        columnKey: 'transferredShortText',
                                        text: '{i18n>TRANSMITTED_SHORT_TEXT}',
                                        importance: sap.ui.core.Priority.Low,
                                        type: 'icon-action',
                                        icon: 'sap-icon://notification-2',
                                        pressEvent: '_pressTextFun',
                                        visible: true,
                                        index: 14
                                    }
                                ];
                            },
                            map: function () {}
                        };
                    },
                    bindList: function () {
                        return {
                            // Binding: function() {}
                            attachChange: function () {},
                            attachRefresh: function () {},
                            attachEvents: function () {},
                            initialize: function () {},
                            setContext: function () {}
                        };
                    },
                    getData: function () {}
                };
                this.invDetailController.overViewModel = {
                    setProperty: function () {},
                    getProperty: function () {
                        var temp = [];
                        return temp;
                    },
                    bindList: function () {
                        return {
                            // Binding: function() {}
                            attachChange: function () {},
                            attachRefresh: function () {},
                            attachEvents: function () {},
                            initialize: function () {},
                            setContext: function () {}
                        };
                    },
                    getData: function () {}
                };
                this.invDetailController.displayChangeTableModel = {
                    setProperty: function () {},
                    getProperty: function () {
                        return {
                            filter: function () {},
                            filterItems: {
                                // forEach: function() {},
                                // {
                                // columnKey: 'sectionId',
                                // exclude: false,
                                // keyField: 'sectionId',
                                // operation: 'EQ',
                                // showIfGrouped: true,
                                // text: 'sectionId',
                                // value1: 'Header Information',
                                // value2: null
                                // }
                            }
                        };
                    }
                };
                this.invDetailController.selectChangetype = {
                    bindItems: function () {},
                    setSelectedKeys: function () {}
                };
                this.invDetailController.oBindingChange = { filter: function () {} };

                this.invDetailController.oMessageView = {
                    setModel: function () {}
                };
                this.invDetailController.createMessagePopover = function () {};
                this.invDetailController.oMP = {
                    toggle: function () {}
                };

                this.invDetailController.beforeRouter = 'TargetList';
                this.oEvent = {
                    getParameter: function (arg) {
                        var temp;
                        if (arg === 'config') {
                            temp = {
                                config: 'detail',
                                name: 'detail'
                            };
                        } else if (arg === 'items') {
                            temp = {
                                map: function () {}
                            };
                        } else {
                            temp = {
                                getKey: function () {},
                                parameters: {
                                    select: {
                                        search: function () {}
                                    }
                                },
                                getProperty: function () {},
                                map: function () {},
                                sdDocumentKey: '5367ea49-5f02-4ae3-ab8d-4948253f5947'
                            };
                        }
                        return temp;
                    },

                    getSource: function () {
                        return {
                            getValueState: function () {
                                return 'Error';
                            },
                            getSelectedKey: function () {
                                return 'OD';
                            },
                            getName: function () {},
                            setValueState: function () {},
                            getParent: function () {
                                return this;
                            },
                            setHighlight: function () {},
                            close: function () {},
                            destroy: function () {},
                            getConditions: function () {
                                return [];
                            },
                            getBindingContext: function () {
                                return this;
                            },
                            getPath: function () {},
                            getBindingPath: function () {},
                            getProperty: function () {
                                return this;
                            },
                            split: function () {
                                return ['transmittedSupplier', 'name', 'validation', 'errorText'];
                            }
                        };
                    }
                };

                this.variantOEvent = {
                    getParameters: function () {
                        return {
                            overwrite: false,
                            key: '',
                            name: '',
                            def: true,
                            global: false,
                            renamed: [{ key: '1' }],
                            deleted: [{ key: '1' }],
                            fav: [{ key: '1' }]
                        };
                    }
                };

                this.invDetailController.oVariantSet = {
                    addVariant: function () {
                        return {
                            setItemValue: function () {},
                            getVariantKey: function () {}
                        };
                    },
                    delVariant: function () {},
                    getVariant: function () {
                        return {
                            setItemValue: function () {},
                            getItemValue: function () {
                                return [];
                            },
                            setVariantName: function () {}
                        };
                    },
                    setCurrentVariantKey: function () {},
                    getCurrentVariantKey: function () {}
                };

                sinon.stub(this.invDetailController, 'getView').returns({
                    setModel: function () {},
                    addDependent: function () {},
                    getModel: function () {},
                    $: function () {
                        return {
                            closest: function () {
                                return { length: 1 };
                            }
                        };
                    },
                    getId: function () {
                        return 'invDeital';
                    }
                });

                sinon.stub(this.invDetailController, 'byId').returns({
                    getItemNavigation: function () {
                        return {
                            getFocusedIndex: function () {
                                return 1;
                            }
                        };
                    },
                    destroyColumns: function () {},
                    addColumn: function () {},
                    bindItems: function () {
                        return {
                            setKeyboardMode: function () {}
                        };
                    },
                    addItem: function () {},
                    getBinding: function () {
                        return {
                            getDistinctValues: function () {
                                return [
                                    {
                                        name: 'test',
                                        transferredShortText: { value: '4werqwr13312' },
                                        billingDocumentItemKey: { value: '4werqwr13312' },
                                        priceElements: { priceElements: [] }
                                    }
                                ];
                            },
                            sort: function () {},
                            filter: function () {},
                            oList: [
                                {
                                    name: 'test',
                                    transferredShortText: { value: '4werqwr13312' },
                                    billingDocumentItemKey: { value: '4werqwr13312' },
                                    priceElements: { priceElements: [] }
                                }
                            ]
                        };
                    },
                    setVisible: function () {},
                    getVisible: function () {},
                    focus: function () {},
                    setText: function () {},
                    setShowFooter: function () {},
                    setBusy: function () {},
                    addDependent: function () {},
                    _oScroller: {
                        scrollTo: function () {}
                    },
                    setShowHeaderContent: function () {},
                    open: function () {},
                    getId: function () {},
                    setSelectedKeys: function () {},
                    setAppData: function () {},
                    setCustomUrl: function () {},
                    setProperty: function () {},
                    setServiceUrl: function () {},
                    setText: function () {},
                    scrollToSection: function () {},
                    setActive: function () {},
                    setModel: function () {},
                    addVariantItem: function () {},
                    removeVariantItem: function () {},
                    getItemByKey: function () {
                        return {
                            setProperty: function () {}
                        };
                    },
                    setDefaultVariantKey: function () {},
                    fireSelect: function () {},
                    setStandardFavorite: function () {},
                    close: function () {},
                    getHeaderTitle: function () {
                        return {
                            getActions: function () {
                                return [
                                    {
                                        getProperty: function () {
                                            return true;
                                        },
                                        focus: function () {}
                                    }
                                ];
                            }
                        };
                    },
                    setEnabled: function () {}
                });

                sinon.stub(this.invDetailController, 'getOwnerComponent').returns({
                    getRouter: function () {
                        return {
                            attachRouteMatched: function () {},
                            navTo: function () {}
                        };
                    },
                    getModel: function () {
                        return {
                            getResourceBundle: function () {
                                return {
                                    getText: function (key) {
                                        var params = {
                                            not: 'N/A',
                                            within: 'Within Tolerance',
                                            outside: 'Outside Tolerance'
                                        };
                                        return params[key];
                                    }
                                };
                            }
                        };
                    },
                    byId: function () {
                        return {
                            setBusy: function () {}
                        };
                    },
                    _showMessageFun: function () {},
                    _getI18nTextFun: function () {},
                    _showMessageViewFun: function () {},
                    _handleToleranceGroupPressedFun: function () {},
                    _handleHeaderSectionMessageFun: function () {
                        return {
                            state: 'Information',
                            stateColor: '#6a6d70',
                            newMessageList: [
                                {
                                    message: 'Journal entry 9400000601 has been updated.',
                                    longText: null,
                                    category: 'Information',
                                    tag: 'Header Data'
                                }
                            ]
                        };
                    },
                    _newDialog: function () {
                        return {
                            bindList: function () {
                                return {
                                    // Binding: function() {}
                                    attachChange: function () {},
                                    attachRefresh: function () {},
                                    attachEvents: function () {},
                                    initialize: function () {},
                                    setContext: function () {}
                                };
                            }
                        };
                    },
                    _deactivatedMessageBox: function () {}
                });

                this.invDetailController._setVariableFun();

                this.invDetailController.data = {
                    headerDataSectionTableData: [
                        {
                            name: {
                                value: 'Delivery Determination Category',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: 'Delivery Note',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: 'Delivery Note555',
                                state: 'None',
                                invalid: false
                            }
                        },
                        {
                            name: { value: 'Delivery', state: 'None', invalid: false },
                            transferredData: {
                                value: '800315',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: { value: 'Action Code555', state: 'None', invalid: false },
                            transferredData: {
                                value: '005',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '22222',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Supplier',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '1830',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Plant',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '72322',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Unloading Point',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '4101',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: { value: 'Sold-to Party', state: 'None', invalid: false },
                            transferredData: {
                                value: '850849',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'ISO Currency',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: 'NO',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: 'EU',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Main Reference',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: { value: null, state: 'None', invalid: false },
                            referenceDocumentData: {
                                value: '4444',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        }
                    ],
                    itemSectionTableData: [
                        {
                            referenceMaterialNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredMaterialNumber: {
                                value: 'TEWED03',
                                state: 'None',
                                invalid: false
                            },
                            referenceCustomerMaterialNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredCustomerMaterialNumber: {
                                value: '132416095',
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetValue: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceItemNetValue: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredSapCurrency: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetPrice: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetPriceUnit: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceDeliveryItemNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            commercialUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referencedItemPlant: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentByPrice: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            materialStatus: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceMaterialDescription: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentByQuantity: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentTotal: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemToleranceResult: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemQuantity: {
                                value: '1631.000',
                                state: 'None',
                                invalid: false
                            },
                            transferredSapUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredIsoUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceItemQuantity: {
                                value: null,
                                state: 'None',
                                unit: '',
                                invalid: false
                            },
                            referenceSapUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            differenceItemQuantity: {
                                value: null,
                                state: 'None',
                                unit: '',
                                invalid: false
                            },
                            itemvatRate: { value: '16.00', state: 'None', invalid: false },
                            transferredItemActionCode: {
                                value: '093',
                                state: 'None',
                                invalid: false
                            },
                            itemvatAmount: {
                                value: '637.46',
                                state: 'None',
                                invalid: false
                            },
                            sdDocumentItemKey: {
                                value: 'e922eacb-2b38-490c-9bb8-8ae0e4403eed',
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNumber: {
                                value: '000011',
                                state: 'None',
                                invalid: false
                            },
                            transferredDeliveryNetValue: {
                                value: '0.00',
                                state: 'None',
                                invalid: false
                            },
                            transferredTechnicalItem: {
                                value: '2',
                                state: 'None',
                                invalid: false
                            }
                        }
                    ],
                    additionalInformationData: {
                        transferredChequeNumber: null,
                        transferredSupplierPostingNumber: null,
                        transferredshippingDate: '2010-02-22T00:00:00Z',
                        transferredpaymentDueDate: '2010-04-10T00:00:00Z',
                        transferredgoodsReceiptDate: '2010-02-22T00:00:00Z',
                        transferreddocumentDate: null,
                        transferredTransmissionId: '000040',
                        contactPerson: null,
                        note: null
                    },
                    displayChangeTableData: [
                        {
                            changeDate: 1,
                            changeUser: 'changeUser',
                            sectionId: 'item1',
                            fieldName: 'Currency',
                            oldValue: 'tggttt',
                            newValue: 'dssdssds'
                        },
                        {
                            changeDate: 2,
                            changeUser: 'changeUser',
                            sectionId: 'item1',
                            fieldName: 'Currency',
                            oldValue: 'tggttt',
                            newValue: 'dssdssds'
                        }
                    ],
                    destination: {
                        host: 'http://ccw-715-api.wdf.sap.corp:443',
                        billing: '',
                        delivery: ''
                    }
                };
                this.invDetailController.oData = {
                    headerDataSectionTableData: [
                        {
                            name: {
                                value: 'Delivery Determination Category',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: 'Delivery Note',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: 'Delivery Note',
                                state: 'None',
                                invalid: false
                            }
                        },
                        {
                            name: { value: 'Delivery', state: 'None', invalid: false },
                            transferredData: {
                                value: '80031685',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: { value: 'Action Code', state: 'None', invalid: false },
                            transferredData: {
                                value: '005',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Supplier',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '1830',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Plant',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '72322',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Customer Unloading Point',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: '4101',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: { value: 'Sold-to Party', state: 'None', invalid: false },
                            transferredData: {
                                value: '850849',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'ISO Currency',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: {
                                value: 'NOK',
                                state: 'None',
                                invalid: false
                            },
                            referenceDocumentData: {
                                value: 'EUR',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        },
                        {
                            name: {
                                value: 'Main Reference',
                                state: 'None',
                                invalid: false
                            },
                            transferredData: { value: null, state: 'None', invalid: false },
                            referenceDocumentData: {
                                value: '',
                                state: 'None',
                                invalid: false
                            },
                            hasError: false
                        }
                    ],
                    itemSectionTableData: [
                        {
                            referenceMaterialNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredMaterialNumber: {
                                value: 'TEWED01',
                                state: 'None',
                                invalid: false
                            },
                            referenceCustomerMaterialNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredCustomerMaterialNumber: {
                                value: '13241609',
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetValue: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceItemNetValue: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredSapCurrency: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetPrice: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNetPriceUnit: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceDeliveryItemNumber: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            commercialUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referencedItemPlant: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentByPrice: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            materialStatus: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceMaterialDescription: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentByQuantity: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemNetValueDifferentTotal: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            itemToleranceResult: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredItemQuantity: {
                                value: '1631.000',
                                state: 'None',
                                invalid: false
                            },
                            transferredSapUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            transferredIsoUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            referenceItemQuantity: {
                                value: null,
                                state: 'None',
                                unit: '',
                                invalid: false
                            },
                            referenceSapUnitOfMeasure: {
                                value: null,
                                state: 'None',
                                invalid: false
                            },
                            differenceItemQuantity: {
                                value: null,
                                state: 'None',
                                unit: '',
                                invalid: false
                            },
                            itemvatRate: { value: '16.00', state: 'None', invalid: false },
                            transferredItemActionCode: {
                                value: '093',
                                state: 'None',
                                invalid: false
                            },
                            itemvatAmount: {
                                value: '637.46',
                                state: 'None',
                                invalid: false
                            },
                            sdDocumentItemKey: {
                                value: 'e922eacb-2b38-490c-9bb8-8ae0e4403eed',
                                state: 'None',
                                invalid: false
                            },
                            transferredItemNumber: {
                                value: '000011',
                                state: 'None',
                                invalid: false
                            },
                            transferredDeliveryNetValue: {
                                value: '0.00',
                                state: 'None',
                                invalid: false
                            },
                            transferredTechnicalItem: {
                                value: '2',
                                state: 'None',
                                invalid: false
                            }
                        }
                    ],
                    additionalInformationData: {
                        transferredChequeNumber: null,
                        transferredSupplierPostingNumber: null,
                        transferredshippingDate: '2010-02-22T00:00:00Z',
                        transferredpaymentDueDate: '2010-04-10T00:00:00Z',
                        transferredgoodsReceiptDate: '2010-02-22T00:00:00Z',
                        transferreddocumentDate: null,
                        transferredTransmissionId: '000040',
                        contactPerson: null,
                        note: null
                    },
                    displayChangeTableData: [
                        {
                            changeDate: 1,
                            changeUser: 'changeUser',
                            sectionId: 'item1',
                            fieldName: 'Currency',
                            oldValue: 'tggttt',
                            newValue: 'dssdssds'
                        },
                        {
                            changeDate: 2,
                            changeUser: 'changeUser',
                            sectionId: 'item1',
                            fieldName: 'Currency',
                            oldValue: 'tggttt',
                            newValue: 'dssdssds'
                        }
                    ],
                    destination: {
                        host: 'http://ccw-715-api.wdf.sap.corp:443',
                        billing: '',
                        delivery: ''
                    }
                };
                this.invDetailController._oPopover = {
                    destroyContent: function () {},
                    close: function () {},
                    destroy: function () {},
                    addContent: function () {},
                    openBy: function () {}
                };
                this.invDetailController._RelatedDocumentsPopover = {
                    close: function () {},
                    destroyContent: function () {},
                    setTitle: function () {},
                    addContent: function () {},
                    openBy: function () {}
                };
                this.invDetailController.docLists = [
                    { document: '666666', documentKey: '2223333' }
                ];
            },
            afterEach: function () {}
        });

        QUnit.test('invDetailController on onInit method', function (assert) {
            assert.ok(
                this.invDetailController.onInit,
                'invDetailController onInit initialized successed.'
            );
            this.invDetailController.onInit();
            // this.invDetailController._setViewModelFun();
        });

        QUnit.test('invDetailController on _routeMatchedFun method', function (assert) {
            assert.ok(
                this.invDetailController._routeMatchedFun,
                'invDetailController _routeMatchedFun initialized successed.'
            );
            this.invDetailController._setHeaderDataSectionTableFun = function () {};
            this.invDetailController._setItemSectionTableFun = function () {};
            this.oEvent_a = {
                getParameter: function () {
                    return {
                        config: 'TargetList',
                        name: 'TargetList',
                        arguments: '5367ea49-5f02-4ae3-ab8d-4948253f5947'
                    };
                }
            };
            // annotation

            this.invDetailController._routeMatchedFun(this.oEvent_a);
            this.invDetailController._routeMatchedFun(this.oEvent);
        });

        QUnit.test('invDetailController on _getDetailPageInfoDataFun method', function (assert) {
            assert.ok(
                this.invDetailController._getDetailPageInfoDataFun,
                'invDetailController _getDetailPageInfoDataFun initialized successed.'
            );
            this.invDetailController._setHeaderDataSectionTableFun = function () {};
            this.invDetailController._setItemSectionTableFun = function () {};
            this.invDetailController._getDetailPageInfoDataFun();
        });

        QUnit.test('invDetailController on _transformDataFun method', function (assert) {
            assert.ok(
                this.invDetailController._transformDataFun,
                'invDetailController _transformDataFun initialized successed.'
            );
            let data = this.invDetailController._mappingDataFieldFun(detailData.objectA);
            this.invDetailController._transformDataFun(data);
            this.invDetailController._changeActivateFun();
            this.invDetailController._activateActionFun('ACTIVE');
            data = this.invDetailController._mappingDataFieldFun(detailData.objectB);
            this.invDetailController._transformDataFun(data);
            this.invDetailController._changeActivateFun();
            this.invDetailController._activateActionFun('DEACTIVATE');

            // this.invDetailController._transformDataFun(detailData.objectC);
        });

        QUnit.test('invDetailController on _setSectionMessageFun method', function (assert) {
            assert.ok(
                this.invDetailController._setSectionMessageFun,
                'invDetailController _setSectionMessageFun has data successed.'
            );
            this.invDetailController._setSectionMessageFun(detailData.message.messageListError);
            this.invDetailController._setSectionMessageFun(detailData.message.messageListWarning);
            this.invDetailController._setSectionMessageFun(
                detailData.message.messageListInformation
            );
            this.invDetailController._setSectionMessageFun([]);
        });
        QUnit.test('invDetailController on _createMessagePopoverFun method', function (assert) {
            assert.ok(
                this.invDetailController._createMessagePopoverFun,
                'invDetailController _createMessagePopoverFun initialized successed.'
            );

            this.invDetailController._createMessagePopoverFun(this.oEvent);
        });

        QUnit.test('invDetailController on _pressReferenceDocumentFun method', function (assert) {
            assert.ok(
                this.invDetailController._pressReferenceDocumentFun,
                'invDetailController _pressReferenceDocumentFun initialized successed.'
            );
            this.invDetailController._pressReferenceDocumentFun();
        });

        QUnit.test('invDetailController on _getCurrentRowDataFun method', function (assert) {
            assert.ok(
                this.invDetailController._getCurrentRowDataFun,
                'invDetailController _getCurrentRowDataFun initialized successed.'
            );
            this.invDetailController._getCurrentRowDataFun();
        });

        QUnit.test('invDetailController on _pressTextFun method', function (assert) {
            assert.ok(
                this.invDetailController._pressTextFun,
                'invDetailController _pressTextFun initialized successed.'
            );
            this.invDetailController._oPopover = {
                addDependent: function () {},
                setShowHeader: function () {},
                destroyContent: function () {},
                addContent: function () {},
                openBy: function () {}
            };
            this.invDetailController._pressTextFun(this.oEvent);
        });

        QUnit.test('invDetailController on _onShareEmailPressFun method', function (assert) {
            assert.ok(
                this.invDetailController._onShareEmailPressFun,
                'invDetailController _onShareEmailPressFun initialized successed.'
            );
            this.invDetailController._onShareEmailPressFun();
        });

        QUnit.test('invDetailController on _pressPriceElementFun method', function (assert) {
            assert.ok(
                this.invDetailController._pressPriceElementFun,
                'invDetailController _pressPriceElementFun initialized successed.'
            );
            this.invDetailController._pressPriceElementFun();
        });

        QUnit.test('invDetailController on _closeNoteFun method', function (assert) {
            assert.ok(
                this.invDetailController._closeNoteFun,
                'invDetailController _closeNoteFun initialized successed.'
            );
            this.invDetailController._closeNoteFun();
        });

        QUnit.test('invDetailController on _navigatePressFun method', function (assert) {
            assert.ok(
                this.invDetailController._navigatePressFun,
                'invDetailController _navigatePressFun initialized successed.'
            );
            this.invDetailController._navigatePressFun();
        });

        QUnit.test('invDetailController on _canPositionFun method', function (assert) {
            var sControlId = true;
            assert.ok(
                this.invDetailController._canPositionFun,
                'invDetailController _canPositionFun successed.'
            );
            this.invDetailController._canPositionFun(sControlId);
            sControlId = false;
            this.invDetailController._canPositionFun(sControlId);
        });

        QUnit.test('invDetailController on _getGroupNameFun method', function (assert) {
            assert.ok(
                this.invDetailController._getGroupNameFun,
                'invDetailController _getGroupNameFun successed.'
            );
            this.invDetailController._getGroupNameFun();
        });

        QUnit.test('invDetailController on _saveVariantFun method', function (assert) {
            assert.ok(
                this.invDetailController._saveVariantFun,
                'invDetailController _saveVariantFun successed.'
            );
            this.invDetailController._saveVariantFun(this.variantOEvent);

            var oEvent = {
                getParameters: function () {
                    return {
                        overwrite: true,
                        key: '',
                        name: '',
                        def: true,
                        global: false,
                        renamed: [{ key: '1' }],
                        deleted: [{ key: '1' }],
                        fav: [{ key: '1' }]
                    };
                }
            };
            // annotation
            this.invDetailController._saveVariantFun(oEvent);
        });
        QUnit.test('invDetailController on _selectVariantFun method', function (assert) {
            assert.ok(
                this.invDetailController._selectVariantFun,
                'invDetailController _selectVariantFun successed.'
            );
            this.invDetailController._setItemSectionTableFun = function () {};
            this.invDetailController._selectVariantFun(this.variantOEvent);
        });
        QUnit.test('invDetailController on _manageVariantFun method', function (assert) {
            assert.ok(
                this.invDetailController._manageVariantFun,
                'invDetailController _manageVariantFun successed.'
            );
            // annotation
            this.invDetailController._manageVariantFun(this.variantOEvent);
        });
        // QUnit.test('invDetailController on _getChangeLogFun method', function (assert) {
        //     assert.ok(
        //         this.invDetailController._getChangeLogFun,
        //         'invDetailController _getChangeLogFun successed.'
        //     );
        //     this.invDetailController._getChangeLogFun();
        // });
        QUnit.test('invDetailController on _clearCacheDataFun method', function (assert) {
            assert.ok(
                this.invDetailController._clearCacheDataFun,
                'invDetailController _clearCacheDataFun successed.'
            );
            this.invDetailController._clearCacheDataFun();
        });
        QUnit.test('invDetailController on dateFormatFun method', function (assert) {
            assert.ok(
                this.invDetailController.dateFormatFun,
                'invDetailController dateFormatFun successed.'
            );
            const date = '0001-01-01T00:00Z';
            this.invDetailController.dateFormatFun(date);
        });
        QUnit.test('invDetailController on timeFormatFun method', function (assert) {
            assert.ok(
                this.invDetailController.timeFormatFun,
                'invDetailController timeFormatFun successed.'
            );
            const date = '2020-03-15T15:20:18+08:00';
            this.invDetailController.timeFormatFun(date);
        });
        QUnit.test('invDetailController on _openMessageDialogFun method', function (assert) {
            this.invDetailController.messageDialog = {
                open: function () {},
                close: function () {}
            };
            assert.ok(
                this.invDetailController._openMessageDialogFun,
                'invDetailController _openMessageDialogFun successed.'
            );
            this.invDetailController._openMessageDialogFun();
            this.invDetailController.messageDialog.close();
        });
        QUnit.test('_afterCloseFun', function (assert) {
            assert.ok(
                this.invDetailController._afterCloseFun,
                'invDetailController _afterCloseFun successed.'
            );
            this.invDetailController._afterCloseFun();
        });
        QUnit.test('_editFun', function (assert) {
            assert.ok(this.invDetailController._editFun, 'invDetailController _editFun successed.');
            this.invDetailController._editFun();
        });
        QUnit.test('invDetailController on _saveFun method', function (assert) {
            assert.ok(this.invDetailController._saveFun, 'invDetailController _saveFun successed.');
            this.invDetailController._saveFun();
            // var data = {};
            // this.invDetailController._transformODataFun(
            //     this.invDetailController.overViewModel.oData,
            //     data
            // );
        });
        QUnit.test('invDetailController on _handleSaveResultFun method', function (assert) {
            assert.ok(
                this.invDetailController._handleSaveResultFun,
                'invDetailController _handleSaveResultFun successed.'
            );
            this.invDetailController._handleSaveResultFun({
                success: true,
                completed: false,
                object: '2020-07-27 06:35:42.912000'
            });
            this.invDetailController._handleSaveResultFun({
                success: false
            });
        });
        QUnit.test('_cancelFun', function (assert) {
            assert.ok(
                this.invDetailController._cancelFun,
                'invDetailController _cancelFun successed.'
            );
            this.invDetailController._cancelFun();
        });
        QUnit.test('_discardFun', function (assert) {
            assert.ok(
                this.invDetailController._discardFun,
                'invDetailController _discardFun successed.'
            );
            this.invDetailController._discardPopover = {
                close: function () {}
            };
            this.invDetailController._setHeaderDataSectionTableFun = function () {};
            this.invDetailController._setItemSectionTableFun = function () {};
            this.invDetailController._discardFun();
        });
        QUnit.test('_objectShareButtonPressFun', function (assert) {
            assert.ok(
                this.invDetailController._objectShareButtonPressFun,
                'invDetailController _objectShareButtonPressFun successed.'
            );
            this.invDetailController._objectShareButtonPressFun(this.oEvent);
        });
        QUnit.test('_saveAndSimulateFun', function (assert) {
            assert.ok(
                this.invDetailController._saveAndSimulateFun,
                'invDetailController _saveAndSimulateFun successed.'
            );
            this.invDetailController._saveAndSimulateFun();
        });

        QUnit.test('_handleSaveAndSimulateResultFun', function (assert) {
            assert.ok(
                this.invDetailController._handleSaveAndSimulateResultFun,
                'invDetailController _handleSaveAndSimulateResultFun successed.'
            );
            this.invDetailController._setHeaderDataSectionTableFun = function () {};
            this.invDetailController._setItemSectionTableFun = function () {};
            this.invDetailController._handleSaveAndSimulateResultFun({
                success: true,
                completed: true
            });
            this.invDetailController._handleSaveAndSimulateResultFun({
                success: false,
                completed: false
            });
            this.invDetailController._handleSaveAndSimulateResultFun({
                success: true,
                completed: false,
                object: '2.7.2020'
            });
        });

        QUnit.test('invDetailController on _handleLifeCycleResultFun method', function (assert) {
            assert.ok(
                this.invDetailController._handleLifeCycleResultFun,
                'invDetailController _handleLifeCycleResultFun successed.'
            );
            this.invDetailController._handleLifeCycleResultFun({
                success: true,
                completed: true
            });
            this.invDetailController._handleLifeCycleResultFun({
                success: false,
                completed: false
            });
            this.invDetailController._handleLifeCycleResultFun({
                success: true,
                completed: false
            });
        });

        QUnit.test(
            'invDetailController on _collectFieldValueOfHeaderTable method',
            function (assert) {
                assert.ok(
                    this.invDetailController._collectFieldValueOfHeaderTable,
                    'invDetailController _collectFieldValueOfHeaderTable successed.'
                );
                const oEvent = {
                    getSource() {
                        return this;
                    },
                    getProperty() {
                        return this;
                    },
                    split() {
                        return ['transmittedSupplier'];
                    },
                    getValue() {
                        return 'supplier';
                    }
                };
                this.invDetailController._collectFieldValueOfHeaderTable(oEvent);
            }
        );

        QUnit.test(
            'invDetailController on _collectFieldValueOfItemTable method',
            function (assert) {
                assert.ok(
                    this.invDetailController._collectFieldValueOfItemTable,
                    'invDetailController _collectFieldValueOfItemTable successed.'
                );
                const oEvent = {
                    getSource() {
                        return this;
                    },
                    getProperty() {
                        return this;
                    },
                    split() {
                        return ['transferredMaterial'];
                    },
                    getValue() {
                        return '123';
                    },
                    getParent() {
                        return this;
                    },
                    getBindingContext() {
                        return this;
                    },
                    getObject() {
                        return {
                            billingDocumentItemKey: {
                                value: 'billingDocumentItemKey'
                            }
                        };
                    }
                };
                this.invDetailController._collectFieldValueOfItemTable(oEvent);
            }
        );

        QUnit.test('invDetailController on _changePersonFun method', function (assert) {
            assert.ok(
                this.invDetailController._changePersonFun,
                'invDetailController _changePersonFun successed.'
            );
            const oEvent = {
                getSource() {
                    return this;
                },
                getValue() {
                    return '123';
                }
            };
            this.invDetailController._changePersonFun(oEvent);
        });

        QUnit.test('invDetailController on _changeNoteFun method', function (assert) {
            assert.ok(
                this.invDetailController._changeNoteFun,
                'invDetailController _changeNoteFun successed.'
            );
            const oEvent = {
                getSource() {
                    return this;
                },
                getValue() {
                    return '123';
                }
            };
            this.invDetailController._changeNoteFun(oEvent);
        });

        QUnit.test('invDetailController on _removeMessageFromTargetFun method', function (assert) {
            assert.ok(
                this.invDetailController._removeMessageFromTargetFun,
                'invDetailController _removeMessageFromTargetFun successed.'
            );
            this.invDetailController._removeMessageFromTargetFun('1');
        });

        QUnit.test('invDetailController on _handleLiveChangeFun method', function (assert) {
            assert.ok(
                this.invDetailController._handleLiveChangeFun,
                'invDetailController _handleLiveChangeFun successed.'
            );
            var oEvent = {
                getSource: function () {
                    return this;
                },
                getValueState: function () {
                    return 'Error';
                },
                getSelectedKey: function () {},
                getName: function () {},
                setValueState: function () {},
                getParent: function () {
                    return this;
                },
                getValue() {
                    return '1';
                },
                getId: function () {},
                setHighlight: function () {},
                close: function () {},
                destroy: function () {},
                getConditions: function () {
                    return [];
                },
                getBindingContext: function () {
                    return this;
                },
                getPath: function () {},
                getBindingPath: function () {},
                getProperty: function () {
                    return this;
                },
                getObject: function () {
                    return {
                        name: { state: 'Error' }
                    };
                },
                split: function () {
                    return ['note', 'name', 'validation', 'errorText'];
                }
            };
            this.invDetailController._handleLiveChangeFun(oEvent);
        });

        QUnit.test(
            'invDetailController on _setHeaderDataSectionTableFun method',
            function (assert) {
                assert.ok(
                    this.invDetailController._setHeaderDataSectionTableFun,
                    'invDetailController _setHeaderDataSectionTableFun successed.'
                );

                this.invDetailController._setHeaderDataSectionTableFun();
            }
        );

        QUnit.test('invDetailController on _setItemSectionTableFun method', function (assert) {
            assert.ok(
                this.invDetailController._setItemSectionTableFun,
                'invDetailController _setItemSectionTableFun successed.'
            );

            this.invDetailController._setItemSectionTableFun();
        });
    }
);

data mock && function mock

#单元测试# #覆盖率#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值