Best JavaScript code snippet using argos
AddAccount.test.js
Source:AddAccount.test.js  
...25    it('ActsAccountAddAccount_0100', 0, async function (done) {26        console.debug("====>ActsAccountAddAccount_0100 start====");27        var appAccountManager = account.createAppAccountManager();28        console.debug("====>creat finish====");29        appAccountManager.addAccount("account_name_callback_first", (err)=>{30            console.debug("====>add account ActsAccountAddAccount_0100 err:" + JSON.stringify(err));31            expect(err.code).assertEqual(0);32            appAccountManager.deleteAccount("account_name_callback_first", (err)=>{33                console.debug("====>delete Account ActsAccountAddAccount_0100 err:" + JSON.stringify(err));34                expect(err.code).assertEqual(0);35                console.debug("====>ActsAccountAddAccount_0100 end====");36                done();37            });38        });39    });40    /*41     * @tc.number    : ActsAccountAddAccount_020042     * @tc.name      : Add account promise form43     * @tc.desc      : Add account in promise form without additional information44     */45    it('ActsAccountAddAccount_0200', 0, async function (done) {46        console.debug("====>ActsAccountAddAccount_0200 start====");47        var appAccountManager = account.createAppAccountManager();48        console.debug("====>creat finish====");49        console.debug("====>add account start====");50        try{51            await appAccountManager.addAccount("account_name_promise_first");52        }53        catch(err){54            console.error("====>add account fail err:" + JSON.stringify(err));55            expect().assertFail();56            done();57        }58        console.debug("====>delete account start====");59        await appAccountManager.deleteAccount("account_name_promise_first");60        console.debug("====>ActsAccountAddAccount_0200 end====");61        done();   62    });63    /*64     * @tc.number    : ActsAccountAddAccount_030065     * @tc.name      : Add account calllback form66     * @tc.desc      : Add account in calllback form with additional information67     */68    it('ActsAccountAddAccount_0300', 0, async function (done) {69        console.debug("====>ActsAccountAddAccount_0300 start====");70        var appAccountManager = account.createAppAccountManager();71        console.debug("====>creat finish====");72        appAccountManager.addAccount("account_name_callback_second", "account_extraInfo_callback_second", (err)=>{73            console.debug("====>add account ActsAccountAddAccount_0300 err:" + JSON.stringify(err));74            expect(err.code).assertEqual(0);75            appAccountManager.deleteAccount("account_name_callback_second", (err)=>{76                console.debug("====>delete Account ActsAccountAddAccount_0300 err:" + JSON.stringify(err));77                expect(err.code).assertEqual(0);78                console.debug("====>ActsAccountAddAccount_0300 end====");79                done();80            });81        });82    });83    /*84     * @tc.number    : ActsAccountAddAccount_040085     * @tc.name      : Add account promise form86     * @tc.desc      : Add account in promise form with additional information87     */88    it('ActsAccountAddAccount_0400', 0, async function (done) {89        console.debug("====>ActsAccountAddAccount_0400 start====");90        var appAccountManager = account.createAppAccountManager();91        console.debug("====>creat finish====");92        console.debug("====>add account start====");93        try{94            await appAccountManager.addAccount("account_name_promise_second", "account_extraInfo_promise_second");95        }96        catch(err){97            console.error("====>add account fail err:" + JSON.stringify(err));98            expect().assertFail();99            done();100        }101        console.debug("====>delete account start====");102        await appAccountManager.deleteAccount("account_name_promise_second");103        console.debug("====>ActsAccountAddAccount_0400 end====");104        done();105    });106    /*107     * @tc.number    : ActsAccountAddAccount_0500108     * @tc.name      : Add account calllback form109     * @tc.desc      : Repeatedly add the same name account and the same additional information110     */111    it('ActsAccountAddAccount_0500', 0, async function (done) {112        console.debug("====>ActsAccountAddAccount_0500 start====");113        var appAccountManager = account.createAppAccountManager();114        appAccountManager.addAccount("account_name_callback_third", "account_extraInfo_callback_third", (err)=>{115            console.debug("====>add account first time ActsAccountAddAccount_0500 err:" + JSON.stringify(err));116            expect(err.code).assertEqual(0);117            appAccountManager.addAccount("account_name_callback_third", "account_extraInfo_callback_third", (err)=>{118                console.debug("====>add account second time ActsAccountAddAccount_0500 err:" + JSON.stringify(err));119                expect(err.code != 0).assertEqual(true);120                appAccountManager.deleteAccount("account_name_callback_third", (err)=>{121                    console.debug("====>delete Account ActsAccountAddAccount_0500 err:" + JSON.stringify(err));122                    expect(err.code).assertEqual(0);123                    console.debug("====>ActsAccountAddAccount_0500 end====");124                    done();125                });126            });127        });128    });129    /*130     * @tc.number    : ActsAccountAddAccount_0600131     * @tc.name      : Add account promise form132     * @tc.desc      : Repeatedly add the same name account and the same additional information133     */134    it('ActsAccountAddAccount_0600', 0, async function (done) {135        console.debug("====>ActsAccountAddAccount_0600 start====");136        var appAccountManager = account.createAppAccountManager();137        console.debug("====>add account for the first time ActsAccountAddAccount_0600====");138        await appAccountManager.addAccount("account_name_promise_third", "account_extraInfo_promise_third");139        console.debug("====>add account for the second time ActsAccountAddAccount_0600 start====");140        try{141            await appAccountManager.addAccount("account_name_promise_third", "account_extraInfo_promise_third");142        }143        catch(err){144            console.debug("====>add account for the second time 0600 err:" + JSON.stringify(err));145            expect(err.code != 0).assertEqual(true);146            await appAccountManager.deleteAccount("account_name_promise_third");147            console.debug("====>ActsAccountAddAccount_0600 end====");148            done();149        }150    });151    /*152     * @tc.number    : ActsAccountAddAccount_0700153     * @tc.name      : Add account calllback form154     * @tc.desc      : The account name exceeds the length limit of 512 characters155     */156    it('ActsAccountAddAccount_0700', 0, async function (done) {157        console.debug("====>ActsAccountAddAccount_0700 start====");158        var limitAccountName = '';159        for (var i = 0; i < NAMELIMIT + 1; i++) {160            limitAccountName += 't';161        }162        var appAccountManager = account.createAppAccountManager();163        appAccountManager.addAccount(limitAccountName, "account_extraInfo_callback_fourth", (err)=>{164            console.debug("====>add account ActsAccountAddAccount_0700 err:" + JSON.stringify(err));165            expect(err.code != 0).assertEqual(true);166            console.debug("====>ActsAccountAddAccount_0700 end====");167            done();168        });169    });170    /*171     * @tc.number    : ActsAccountAddAccount_0800172     * @tc.name      : Add account promise form173     * @tc.desc      : The account name exceeds the length limit of 512 characters174     */175    it('ActsAccountAddAccount_0800', 0, async function (done) {176        console.debug("====>ActsAccountAddAccount_0800 start====");177        var limitAccountName = '';178        for (var i = 0; i < NAMELIMIT + 1; i++) {179            limitAccountName += 'n';180        }181        var appAccountManager = account.createAppAccountManager();182        try{183            await appAccountManager.addAccount(limitAccountName, "account_extraInfo_promise_fourth");184        }185        catch(err){186            console.debug("====>add account ActsAccountAddAccount_0800 err:" + JSON.stringify(err));187            expect(err.code != 0).assertEqual(true);188            console.debug("====>ActsAccountAddAccount_0800 end====");189            done();190        }191    });192    /*193     * @tc.number    : ActsAccountAddAccount_0900194     * @tc.name      : Add account calllback form195     * @tc.desc      : Additional information exceeds the length limit of 1024 characters196     */197    it('ActsAccountAddAccount_0900', 0, async function (done) {198        console.debug("====>ActsAccountAddAccount_0900 start====");199        var limitAccountExtra = '';200        for (var i = 0; i < LENGTHLIMIT + 1; i++) {201            limitAccountExtra += 't';202        }203        var appAccountManager = account.createAppAccountManager();204        appAccountManager.addAccount("account_name_callback_fifth", limitAccountExtra, (err)=>{205            console.debug("====>add account ActsAccountAddAccount_0900 err:" + JSON.stringify(err));206            expect(err.code != 0).assertEqual(true);207            console.debug("====>ActsAccountAddAccount_0900 end====");208            done();209        });210    });211    /*212     * @tc.number    : ActsAccountAddAccount_1000213     * @tc.name      : Add account promise form214     * @tc.desc      : Additional information exceeds the length limit of 1024 characters215     */216    it('ActsAccountAddAccount_1000', 0, async function (done) {217        console.debug("====>ActsAccountAddAccount_1000 start====");218        var limitAccountExtra = '';219        for (var i = 0; i < LENGTHLIMIT + 1; i++) {220            limitAccountExtra += 'e';221        }222        var appAccountManager = account.createAppAccountManager();223        try{224            await appAccountManager.addAccount("account_name_promise_fifth", limitAccountExtra);225        }226        catch(err){227            console.debug("====>add account ActsAccountAddAccount_1000 err:" + JSON.stringify(err));228            expect(err.code != 0).assertEqual(true);229            console.debug("====>ActsAccountAddAccount_1000 end====");230            done();231        }232    });233    /*234     * @tc.number    : ActsAccountAddAccount_1100235     * @tc.name      : Add account calllback form236     * @tc.desc      : The account name is an empty string237     */238    it('ActsAccountAddAccount_1100', 0, async function (done) {239        console.debug("====>ActsAccountAddAccount_1100 start====");240        var appAccountManager = account.createAppAccountManager();241        appAccountManager.addAccount("", "account_name_callback_sixth", (err)=>{242            console.debug("====>add account ActsAccountAddAccount_1100 err:" + JSON.stringify(err));243            expect(err.code != 0).assertEqual(true);244            console.debug("====>ActsAccountAddAccount_1100 end====");245            done();246        });247    });248    /*249     * @tc.number    : ActsAccountAddAccount_1200250     * @tc.name      : Add account promise form251     * @tc.desc      : The account name is an empty string252     */253    it('ActsAccountAddAccount_1200', 0, async function (done) {254        console.debug("====>ActsAccountAddAccount_1200 start====");255        console.debug("====>ActsAccountAddAccount_1200 add account start====");256        var appAccountManager = account.createAppAccountManager();257        try{258            await appAccountManager.addAccount("", "account_name_promise_sixth");259        }260        catch(err){261            console.debug("====>add account ActsAccountAddAccount_1200 err:"+ JSON.stringify(err));262            expect(err.code != 0).assertEqual(true);263            console.debug("====>ActsAccountAddAccount_1200 end====");264            done();265        }266    });267    /*268     * @tc.number    : ActsAccountAddAccount_1300269     * @tc.name      : Add account calllback form270     * @tc.desc      : Additional information is an empty string271     */272    it('ActsAccountAddAccount_1300', 0, async function (done) {273        console.debug("====>ActsAccountAddAccount_1300 start====");274        var appAccountManager = account.createAppAccountManager();275        appAccountManager.addAccount("account_name_callback_seventh", "", (err)=>{276            console.debug("====>add account ActsAccountAddAccount_1300 err:" + JSON.stringify(err));277            expect(err.code).assertEqual(0);278            appAccountManager.deleteAccount("account_name_callback_seventh", (err)=>{279                console.debug("====>delete Account ActsAccountAddAccount_1300 err:" + JSON.stringify(err));280                expect(err.code).assertEqual(0);281                console.debug("====>ActsAccountAddAccount_1300 end====");282                done();283            });284        });285    });286    /*287     * @tc.number    : ActsAccountAddAccount_1400288     * @tc.name      : Add account promise form289     * @tc.desc      : Additional information is an empty string290     */291    it('ActsAccountAddAccount_1400', 0, async function (done) {292        console.debug("====>ActsAccountAddAccount_1400 start====");293        var appAccountManager = account.createAppAccountManager();294        console.debug("====>add account ActsAccountAddAccount_1400 start====");295        try{296            await appAccountManager.addAccount("account_name_promise_seventh", "");297        }298        catch(err){299            console.error("====>add account ActsAccountAddAccount_1400 err:" + JSON.stringify(err));300            expect().assertFail();301            done();302        }303        console.debug("====>delete account ActsAccountAddAccount_1400 start====");304        await appAccountManager.deleteAccount("account_name_promise_seventh");305        done();306    });307    /*308     * @tc.number    : ActsAccountAddAccount_1500309     * @tc.name      : Add account calllback form310     * @tc.desc      : The account name is a special character such as a space311     */312    it('ActsAccountAddAccount_1500', 0, async function (done) {313        console.debug("====>ActsAccountAddAccount_1500 start====");314        var appAccountManager = account.createAppAccountManager();315        var specialStr = " ";316        appAccountManager.addAccount(specialStr, "account_extraInfo_callback_eight", (err)=>{317            console.debug("====>add account ActsAccountAddAccount_1500 err:" + JSON.stringify(err));318            expect(err.code != 0).assertEqual(true);319            console.debug("====>ActsAccountAddAccount_1500 end====");320            done();321        });322    });323    /*324     * @tc.number    : ActsAccountAddAccount_1600325     * @tc.name      : Add account promise form326     * @tc.desc      : The account name is a special character such as a space327     */328    it('ActsAccountAddAccount_1600', 0, async function (done) {329        console.debug("====>ActsAccountAddAccount_1600 start====");330        var appAccountManager = account.createAppAccountManager();331        var specialStr = " ";332        try{333            await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_eighth");334        }335        catch(err){336            console.debug("====>add Account ActsAccountAddAccount_1600 err:" + JSON.stringify(err));337            expect(err.code != 0).assertEqual(true);338            console.debug("====>ActsAccountAddAccount_1600 end====");339            done();340        }341    });342    /*343     * @tc.number    : ActsAccountAddAccount_1700344     * @tc.name      : Add account calllback form345     * @tc.desc      : The account name is a special string346     */347    it('ActsAccountAddAccount_1700', 0, async function (done) {348        console.debug("====>ActsAccountAddAccount_1700 start====");349        var appAccountManager = account.createAppAccountManager();350        var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890";351        appAccountManager.addAccount(specialStr, "account_extraInfo_callback_ninth", (err)=>{352            console.debug("====>add account ActsAccountAddAccount_1700 err:" + JSON.stringify(err));353            expect(err.code).assertEqual(0);354            appAccountManager.deleteAccount(specialStr, (err)=>{355                console.debug("====>delete Account ActsAccountAddAccount_1700 err" + JSON.stringify(err));356                expect(err.code).assertEqual(0);357                console.debug("====>ActsAccountAddAccount_1700 end====");358                done();359            });360        });361    });362    /*363     * @tc.number    : ActsAccountAddAccount_1800364     * @tc.name      : Add account promise form365     * @tc.desc      : The account name is a special string366     */367    it('ActsAccountAddAccount_1800', 0, async function (done) {368        console.debug("====>ActsAccountAddAccount_1800 start====");369        var appAccountManager = account.createAppAccountManager();370        var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890";371        console.debug("====>add account ActsAccountAddAccount_1800====");372        try{373            await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_ninth");374        }375        catch(err){376            console.error("====>add Account ActsAccountAddAccount_1800 err:" + JSON.stringify(err));377            expect().assertFail();378            done();379        }380        console.debug("====>delete account ActsAccountAddAccount_1800====");381        await appAccountManager.deleteAccount(specialStr);382        console.debug("====>ActsAccountAddAccount_1800 end====");383        done();384    });385    /*386     * @tc.number    : ActsAccountAddAccount_1900387     * @tc.name      : Add account calllback form388     * @tc.desc      : Additional information is a special character such as a space389     */390    it('ActsAccountAddAccount_1900', 0, async function (done) {391        console.debug("====>ActsAccountAddAccount_1900 start====");392        var appAccountManager = account.createAppAccountManager();393        var specialStr = " ";394        appAccountManager.addAccount("account_name_callback_tenth", specialStr, (err)=>{395            console.debug("====>add account ActsAccountAddAccount_1900 err:" + JSON.stringify(err));396            expect(err.code).assertEqual(0);397            appAccountManager.deleteAccount("account_name_callback_tenth", (err)=>{398                console.debug("====>delete Account ActsAccountAddAccount_1900 err" + JSON.stringify(err));399                expect(err.code).assertEqual(0);400                console.debug("====>ActsAccountAddAccount_1900 end====");401                done();402            });403        });404    });405    /*406     * @tc.number    : ActsAccountAddAccount_2000407     * @tc.name      : Add account promise form408     * @tc.desc      : Additional information is a special character such as a space409     */410    it('ActsAccountAddAccount_2000', 0, async function (done) {411        console.debug("====>ActsAccountAddAccount_2000 start====");412        var appAccountManager = account.createAppAccountManager();413        var specialStr = " ";414        console.debug("====>add account ActsAccountAddAccount_2000====");415        try{416            await appAccountManager.addAccount("account_name_promise_tenth", specialStr);417        }418        catch(err){419            console.error("====>add Account ActsAccountAddAccount_2000 err:" + JSON.stringify(err));420            expect().assertFail();421            done();422        }423        console.debug("====>delete account ActsAccountAddAccount_2000====");424        await appAccountManager.deleteAccount("account_name_promise_tenth");425        console.debug("====>ActsAccountAddAccount_2000 end====");426        done();427    });428    /*429     * @tc.number    : ActsAccountAddAccount_2100430     * @tc.name      : Add account calllback form431     * @tc.desc      : Additional information is a special string432     */433    it('ActsAccountAddAccount_2100', 0, async function (done) {434        console.debug("====>ActsAccountAddAccount_2100 start====");435        var appAccountManager = account.createAppAccountManager();436        var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890";437        appAccountManager.addAccount("account_extraInfo_callback_eleventh", specialStr, (err)=>{438            console.debug("====>add account ActsAccountAddAccount_2100 err:" + JSON.stringify(err));439            expect(err.code).assertEqual(0);440            appAccountManager.deleteAccount("account_extraInfo_callback_eleventh", (err)=>{441                console.debug("====>delete Account ActsAccountAddAccount_2100 err" + JSON.stringify(err));442                expect(err.code).assertEqual(0);443                console.debug("====>ActsAccountAddAccount_2100 end====");444                done();445            });446        });447    });448    /*449     * @tc.number    : ActsAccountAddAccount_2200450     * @tc.name      : Add account promise form451     * @tc.desc      : Additional information is a special string452     */453    it('ActsAccountAddAccount_2200', 0, async function (done) {454        console.debug("====>ActsAccountAddAccount_2200 start====");455        var appAccountManager = account.createAppAccountManager();456        var specialStr = "#@$%^&*()_+!<>~?,./[]abcdefgABCDEFG1234567890";457        console.debug("====>add account ActsAccountAddAccount_2200====");458        try{459            await appAccountManager.addAccount("account_extraInfo_promise_eleventh", specialStr);460        }461        catch(err){462            console.error("====>add Account ActsAccountAddAccount_2200 err:" + JSON.stringify(err));463            expect().assertFail();464            done();465        }466        console.debug("====>delete account ActsAccountAddAccount_2200====");467        await appAccountManager.deleteAccount("account_extraInfo_promise_eleventh");468        console.debug("====>ActsAccountAddAccount_2200 end====");469        done();470    });471    /*472     * @tc.number    : ActsAccountAddAccount_2300473     * @tc.name      : Add account calllback form474     * @tc.desc      : Repeatedly add accounts with the same name and different additional information475     */476    it('ActsAccountAddAccount_2300', 0, async function (done) {477        console.debug("====>ActsAccountAddAccount_2300 start====");478        var appAccountManager = account.createAppAccountManager();479        appAccountManager.addAccount("account_name_callback_same", "account_extraInfo_callback", (err)=>{480            console.debug("====>add account first time ActsAccountAddAccount_2300 err:" + JSON.stringify(err));481            expect(err.code).assertEqual(0);482            appAccountManager.addAccount("account_name_callback_same", "account_extraInfo_callback_different", (err)=>{483                console.debug("====>add account second time ActsAccountAddAccount_2300 err:" + JSON.stringify(err));484                expect(err.code != 0).assertEqual(true);485                appAccountManager.deleteAccount("account_name_callback_same", (err)=>{486                    console.debug("====>delete Account ActsAccountAddAccount_2300 err:" + JSON.stringify(err));487                    expect(err.code).assertEqual(0);488                    console.debug("====>ActsAccountAddAccount_2300 end====");489                    done();490                });491            });492        });493    });494    /*495     * @tc.number    : ActsAccountAddAccount_2400496     * @tc.name      : Add account promise form497     * @tc.desc      : Repeatedly add accounts with the same name and different additional information498     */499    it('ActsAccountAddAccount_2400', 0, async function (done) {500        console.debug("====>ActsAccountAddAccount_2400 start====");501        var appAccountManager = account.createAppAccountManager();502        console.debug("====>add account for the first time ActsAccountAddAccount_2400====");503        await appAccountManager.addAccount("account_name_promise_same", "account_extraInfo_promise");504        console.debug("====>add account for the second time ActsAccountAddAccount_2400====");505        try{506            await appAccountManager.addAccount("account_name_promise_same", "account_extraInfo_promise_different");507        }508        catch(err){509            console.debug("====>add account for the second time err:" + JSON.stringify(err));510            expect(err.code != 0).assertEqual(true);511            appAccountManager.deleteAccount("account_name_promise_same"); 512            console.debug("====>ActsAccountAddAccount_2400 end====");513            done();514        }515    });516    /*517     * @tc.number    : ActsAccountAddAccount_2500518     * @tc.name      : Add account calllback form519     * @tc.desc      : The account name reaches the limit of 512 characters520     */521    it('ActsAccountAddAccount_2500', 0, async function (done) {522        console.debug("====>ActsAccountAddAccount_2500 start====");523        var limitName = '';524        for (var i = 0; i < NAMELIMIT; i++) {525            limitName += 't';526        }527        var appAccountManager = account.createAppAccountManager();528        appAccountManager.addAccount(limitName, "account_extraInfo_callback", (err)=>{529            console.debug("====>add account ActsAccountAddAccount_2500 err:" + JSON.stringify(err));530            expect(err.code).assertEqual(0);531            appAccountManager.deleteAccount(limitName, (err)=>{532                console.debug("====>delete Account ActsAccountAddAccount_2500 err:" + JSON.stringify(err));533                expect(err.code).assertEqual(0);534                console.debug("====>ActsAccountAddAccount_2500 end====");535                done();536            });537        });538    });539    /*540     * @tc.number    : ActsAccountAddAccount_2600541     * @tc.name      : Add account promise form542     * @tc.desc      : The account name reaches the limit of 512 characters543     */544    it('ActsAccountAddAccount_2600', 0, async function (done) {545        console.debug("====>ActsAccountAddAccount_2600 start====");546        var nameLimit = '';547        for (var i = 0; i < NAMELIMIT; i++) {548            nameLimit += 't';549        }550        var appAccountManager = account.createAppAccountManager();551        console.debug("====>add account ActsAccountAddAccount_2600 start====");552        try{553            await appAccountManager.addAccount(nameLimit, "account_extraInfo_promise");554        }555        catch(err){556            console.error("====>add account ActsAccountAddAccount_2600 err:" + JSON.stringify(err));557            expect().assertFail();558            done();559        }560        console.debug("====>delete account ActsAccountAddAccount_2600 start====");561        await appAccountManager.deleteAccount(nameLimit);562        console.debug("====>ActsAccountAddAccount_2600 end====");563        done();564    });565    /*566     * @tc.number    : ActsAccountAddAccount_2700567     * @tc.name      : Add account calllback form568     * @tc.desc      : Additional information reaches the limit of 1024 characters569     */570    it('ActsAccountAddAccount_2700', 0, async function (done) {571        console.debug("====>ActsAccountAddAccount_2700 start====");572        var limitExtra = '';573        for (var i = 0; i < LENGTHLIMIT; i++) {574            limitExtra += 't';575        }576        var appAccountManager = account.createAppAccountManager();577        appAccountManager.addAccount("account_extra_callback_limit", limitExtra, (err)=>{578            console.debug("====>add account ActsAccountAddAccount_2700 err:" + JSON.stringify(err));579            expect(err.code).assertEqual(0);580            appAccountManager.deleteAccount("account_extra_callback_limit", (err)=>{581                console.debug("====>delete Account ActsAccountAddAccount_2700 err:" + JSON.stringify(err));582                expect(err.code).assertEqual(0);583                console.debug("====>ActsAccountAddAccount_2700 end====");584                done();585            });586        });587    });588    /*589     * @tc.number    : ActsAccountAddAccount_2800590     * @tc.name      : Add account promise form591     * @tc.desc      : Additional information reaches the limit of 1024 characters592     */593    it('ActsAccountAddAccount_2800', 0, async function (done) {594        console.debug("====>ActsAccountAddAccount_2800 start====");595        var extraLimit = '';596        for (var i = 0; i < LENGTHLIMIT; i++) {597            extraLimit += 't';598        }599        var appAccountManager = account.createAppAccountManager();600        try{601            await appAccountManager.addAccount("account_extra_promise_limit", extraLimit);602        }603        catch(err){604            console.error("====>add account ActsAccountAddAccount_2800 err:" + JSON.stringify(err));605            expect().assertFail();606            done();607        }608        console.debug("====>delete account ActsAccountAddAccount_2800 start====");609        appAccountManager.deleteAccount("account_extra_promise_limit");610        console.debug("====>ActsAccountAddAccount_2800 end====");611        done();612    });...DeleteAccount.test.js
Source:DeleteAccount.test.js  
...37    it('ActsAccountDeleteAccount_0100', 0, async function (done) {38        console.debug("====>ActsAccountDeleteAccount_0100 start====");39        var appAccountManager = account.createAppAccountManager();40        console.debug("====>creat finish====");41        appAccountManager.addAccount("deleteAccount_name_callback_first", "extraInfo_callback_first", (err)=>{42            console.debug("====>add account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err));43            expect(err.code).assertEqual(0);44            appAccountManager.deleteAccount("deleteAccount_name_callback_first", (err)=>{45                console.debug("====>delete Account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err));46                expect(err.code).assertEqual(0);47                console.debug("====>ActsAccountDeleteAccount_0100 end====");48                done();49            });50        });51    });52    /*53     * @tc.number    : ActsAccountDeleteAccount_020054     * @tc.name      : Delete account promise form55     * @tc.desc      : Delete the added account in promise form56     */57    it('ActsAccountDeleteAccount_0200',0,async function (done){58        console.debug("====>ActsAccountDeleteAccount_0200 start====");59        var appAccountManager = account.createAppAccountManager();60        console.debug("====>add account ActsAccountAddAccount_0200 start====");61        await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first");62        try{63            await appAccountManager.deleteAccount("deleteAccount_name_promise_first");64            console.debug("====>ActsAccountDeleteAccount_0200 end====");65            done();66        }67        catch(err){68            console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err));69            expect().assertFail();70            done();71        }72    });73    /*74     * @tc.number    : ActsAccountDeleteAccount_030075     * @tc.name      : Delete account calllback form76     * @tc.desc      : Delete unadded account in callback form77     */78    it('ActsAccountDeleteAccount_0300', 0, async function (done) {79        console.debug("====>ActsAccountDeleteAccount_0300 start====");80        var appAccountManager = account.createAppAccountManager();81        console.debug("====>creat finish====");82        appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{83            console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err));84            expect(err.code != 0).assertEqual(true);85            console.debug("====>ActsAccountDeleteAccount_0300 end====");86            done();87        });88    });89    /*90     * @tc.number    : ActsAccountDeleteAccount_040091     * @tc.name      : Delete account promise form92     * @tc.desc      : Delete unadded account in promise form93     */94    it('ActsAccountDeleteAccount_0400', 0, async function(done){95        console.debug("====>ActsAccountDeleteAccount_0400 start====");96        var appAccountManager = account.createAppAccountManager();97        try{98            await appAccountManager.deleteAccount("deleteAccount_name_promise_second");99        }100        catch(err){101            console.debug("====>delete account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err));102            expect(err.code != 0).assertEqual(true);103            console.debug("====>ActsAccountDeleteAccount_0400 end====");104            done();105        }106    });107    /*108     * @tc.number    : ActsAccountDeleteAccount_0500109     * @tc.name      : Delete account calllback form110     * @tc.desc      : Delete the added account, the first time it can be deleted, the second time the deletion fails111     */112    it('ActsAccountDeleteAccount_0500', 0, async function (done) {113        console.debug("====>ActsAccountDeleteAccount_0500 start====");114        var appAccountManager = account.createAppAccountManager();115        appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{116            console.debug("====>add account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err));117            expect(err.code).assertEqual(0);118            appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{119                console.debug("====>delete account first time  err:" + JSON.stringify(err));120                expect(err.code).assertEqual(0);121                appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{122                    console.debug("====>delete Account second time err:" + JSON.stringify(err));123                    expect(err.code != 0).assertEqual(true);124                    console.debug("====>ActsAccountDeleteAccount_0500 end====");125                    done();126                });127            });128        });129    });130    /*131     * @tc.number    : ActsAccountDeleteAccount_0600132     * @tc.name      : Delete account promise form133     * @tc.desc      : Delete the added account, the first time it can be deleted, the second time the deletion fails134     */135    it('ActsAccountDeleteAccount_0600', 0, async function (done){136        console.debug("====>ActsAccountDeleteAccount_0600 start====");137        var appAccountManager = account.createAppAccountManager();138        console.debug("====>add account ActsAccountAddAccount_0600 start====");139        await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third");140        console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start====");141        await appAccountManager.deleteAccount("deleteAccount_name_promise_third");142        console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start====");143        try{144            await appAccountManager.deleteAccount("deleteAccount_name_promise_third");145        }146        catch(err){147            console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err));148            expect(err.code != 0).assertEqual(true);149            console.debug("====>ActsAccountDeleteAccount_0600 end====");150            done();151        }152    });153    /*154     * @tc.number    : ActsAccountDeleteAccount_0700155     * @tc.name      : Delete account calllback form156     * @tc.desc      : Delete the account name exceeds the length limit of 1024157     */158    it('ActsAccountDeleteAccount_0700',0, async function (done){159        console.debug("====>ActsAccountDeleteAccount_0700 start====");160        var bigStr = '';161        for (var i = 0; i < STRCOUNT; i++) {162            bigStr += 't';163        }164        var appAccountManager = account.createAppAccountManager();165        appAccountManager.deleteAccount(bigStr, (err)=>{166            console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));167            expect(err.code != 0).assertEqual(true);168            console.debug("====>ActsAccountDeleteAccount_0700 end====");169            done();170        });171    });172    /*173     * @tc.number    : ActsAccountDeleteAccount_0800174     * @tc.name      : Delete account promise form175     * @tc.desc      : Delete the account name exceeds the length limit of 1024176     */177    it('ActsAccountDeleteAccount_0800', 0, async function (done){178        console.debug("====>ActsAccountDeleteAccount_0800 start====");179        var bigStr = '';180        for (var i = 0; i < STRCOUNT; i++) {181            bigStr += 't';182        }183        var appAccountManager = account.createAppAccountManager();184        console.debug("====>delete Account ActsAccountDeleteAccount_0800 start====");185        try{186            await appAccountManager.deleteAccount(bigStr);187        }188        catch(err){189            console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err));190            expect(err.code != 0).assertEqual(true);191            console.debug("====>ActsAccountDeleteAccount_0800 end====");192            done();193        }194    })195    /*196     * @tc.number    : ActsAccountDeleteAccount_0900197     * @tc.name      : Delete account calllback form198     * @tc.desc      : Delete the account name is an empty string199     */200    it('ActsAccountDeleteAccount_0900',0, async function (done){201        console.debug("====>ActsAccountDeleteAccount_0900 start====");202        var appAccountManager = account.createAppAccountManager();203        appAccountManager.deleteAccount("", (err)=>{204            console.debug("====>delete Account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err));205            expect(err.code != 0).assertEqual(true);206            console.debug("====>ActsAccountDeleteAccount_0900 end====");207            done();208        });209    });210    /*211     * @tc.number    : ActsAccountDeleteAccount_1000212     * @tc.name      : Delete account promise form213     * @tc.desc      : Delete the account name is an empty string214     */215    it('ActsAccountDeleteAccount_1000', 0, async function (done){216        console.debug("====>ActsAccountDeleteAccount_1000 start====");217        var appAccountManager = account.createAppAccountManager();218        console.debug("====>delete Account ActsAccountDeleteAccount_1000 start====");219        try{220            await appAccountManager.deleteAccount("");221        }222        catch(err){223            console.debug("====>delete account ActsAccountDeleteAccount_1000 err:" + JSON.stringify(err));224            expect(err.code != 0).assertEqual(true);225            console.debug("====>ActsAccountDeleteAccount_1000 end====");226            done();227        }228    })...account.service.spec.ts
Source:account.service.spec.ts  
...38  })39  //createAccount40  it('should throw and exception if name is not set', async () => {41    try {42      await accountService.createAccount({} as IAccount);43    } catch (e) {44      expect(e.message).toBe('Name is required');45    }46  });47  it('should create an account', async () => {48    const validAccount = { name: "john doe" } as IAccount;49    const createdAccount = await accountService.createAccount(validAccount);50    console.log('createdAccount', createdAccount);51    expect(validAccount.name).toBe(createdAccount.name);52    expect(createdAccount.accountNumber).toBeDefined()53    expect(createdAccount.id).toBeDefined()54  });55  //fundAccount56  it('should throw an exception if amount is less than 0', async () => {57    const testAccount = { name: 'john doe', accountNumber: '9854743932', id: 1, balance: 0 } as IAccount;58    accountsDB.push(testAccount);59    const accountNumber = '9854743932'60    try {61      await accountService.fundAccount(accountNumber, -2);62    } catch (e) {63      expect(e.message).toBe('Invalid fund amount');64    }65  });66  it('should throw an exception if account is not found', async () => {67    const testAccount = { name: 'john doe', accountNumber: '9854743932', id: 1, balance: 0 } as IAccount;68    accountsDB.push(testAccount);69    const accountNumber = '9854743933'70    try {71      const createdAccount = await accountService.fundAccount(accountNumber, 200);72    } catch (e) {73      expect(e.message).toBe('Invalid Account number');74    }75  });76  it('should add to account balance', async () => {77    const testAccount = { name: 'john doe', accountNumber: '9854743932', id: 1, balance: 0 } as IAccount;78    accountsDB.push(testAccount);79    const accountNumber = '9854743932'80    const createdAccount = await accountService.fundAccount(accountNumber, 200);81    expect(createdAccount.balance).toBe(200);82  });83  //transferToAnother84  it('should throw an exception if amount is less than 0', async () => {85    const sourceAccountNumber = '9854743932'86    const destinationAccountNo = '2854743932'87    try {88      await accountService.transferToAnother(sourceAccountNumber, destinationAccountNo, -200);89    } catch (e) {90      expect(e.message).toBe('Invalid fund amount');91    }92  });93  it('should throw an exception if source account number is the same as destination account number', async () => {94    const sourceAccountNumber = '9854743932'...account.component.ts
Source:account.component.ts  
...43    public dialog: MatDialog,44    private route: Router45  ) {}46  ngOnInit(): void {}47  selectAccount(account: Account) {48    this.route.navigate(['/realAccount/transactions', { id: account.id }]);49  }50  selectVirtualAccount(account: VirtualAccount) {51    this.route.navigate(['/virtualAccount/transactions', { id: account.id }]);52  }53  deleteAccount(account: Account) {54    this.logger.log(account, 'AccountComponent');55    // TODO delete and reload56  }57  editAccount(editedAccount: Account): void {58    let account: Account;59    if (editedAccount === null) {60      account = {61        id: null,62        name: null,63        accountType: null,64      };65    } else {66      account = editedAccount;67    }68    const isNew = editedAccount === null;69    const accountTypes = this.accountTypeService.getAccountTypes();70    const accountDialog = this.dialog.open(AccountCreationDialogComponent, {71      data: { account, accountTypes, isNew },72    });73    accountDialog.afterClosed().subscribe((result) => {74      if (result !== undefined) {75        if (editedAccount === null) {76          this.accountService77            .addAccount(result.account)78            .subscribe(() => this.refreshToken$.next(undefined));79        } else {80          this.accountService81            .updateAccount(result.account)82            .subscribe(() => this.refreshToken$.next(undefined));83        }84      } else {85        this.refreshToken$.next(undefined);86      }87    });88  }89  deleteVirtualAccount(account: VirtualAccount) {90    this.logger.log(account, 'AccountComponent');91    // TODO delete and reload92  }93  editVirtualAccount(editedAccount: VirtualAccount, account: Account): void {94    let virtualAccount: VirtualAccount;95    if (editedAccount === null) {96      virtualAccount = {97        id: null,98        name: null,99        underlyingAccount: account,100      };101    } else {102      virtualAccount = editedAccount;103    }104    const virtualAccountDialog = this.dialog.open(105      VirtualAccountCreationDialogComponent,106      {107        data: { virtualAccount },108      }109    );110    virtualAccountDialog.afterClosed().subscribe((result) => {111      if (result !== undefined) {112        if (editedAccount === null) {113          this.virtualAccountService114            .addVirtualAccount(result.virtualAccount)115            .subscribe(() => this.refreshToken$.next(undefined));116        } else {117          this.virtualAccountService118            .updateVirtualAccount(result.virtualAccount)119            .subscribe(() => this.refreshToken$.next(undefined));120        }121      } else {122        this.refreshToken$.next(undefined);123      }124    });125  }126}127@Component({128  selector: 'app-account-creation-dialog',129  templateUrl: 'account-creation-dialog.html',130  styleUrls: ['./account.component.css'],131})132export class AccountCreationDialogComponent {...account-repository.ts
Source:account-repository.ts  
1import { AddAccountRepository } from '@/data/protocols/db/account/add-account-repository'2import { FindAccountByIdRepository } from '@/data/protocols/db/account/find-account-by-id-repository'3import { RemoveAccountRepository } from '@/data/protocols/db/account/remove-account-repository'4import { UpdateAccountRepository } from '@/data/protocols/db/account/update-account-repository'5import { AccountModel, AccountModelResponse, FindAccountByEmailRepository } from '@/data/usecases/authentication/db-authentication-protocols'6import { AddAccountParams } from '@/domain/usecases/account/add-account'7import { UpdateAccountParams } from '@/domain/usecases/account/update-account'8import { getRepository } from 'typeorm'9import { AccountEntity } from './account-entity'10export class AccountRepository implements AddAccountRepository, FindAccountByEmailRepository, FindAccountByIdRepository, UpdateAccountRepository, RemoveAccountRepository {11  async add(accountData: AddAccountParams): Promise<AccountModelResponse> {12    const accountEntity = getRepository(AccountEntity)13    const account = accountEntity.create(accountData)14    return await accountEntity.save(account)15  }16  async update(accountId: string, accountData: UpdateAccountParams): Promise<number> {17    const accountEntity = getRepository(AccountEntity)18    const respondeDb = await accountEntity.update(accountId, accountData)19    return respondeDb.affected20  }21  async remove(accountId: string): Promise<number> {22    const accountEntity = getRepository(AccountEntity)23    const dbResponse = await accountEntity.delete(accountId)24    return dbResponse.affected25  }26  async findByEmail(email: string): Promise<AccountModel> {27    const accountEntity = getRepository(AccountEntity)28    const account = await accountEntity29      .createQueryBuilder('account')30      .select([31        'account.id',32        'account.name',33        'account.email',34        'account.password'35      ])36      .where('account.email = :email', { email: email })37      .getOne()38    return account39  }40  async findById(id: string): Promise<AccountModelResponse> {41    const accountEntity = getRepository(AccountEntity)42    const account = await accountEntity43      .createQueryBuilder('account')44      .select([45        'account.id',46        'account.name',47        'account.email',48        'account.created_at',49        'account.updated_at'50      ])51      .where('account.id = :id', { id: id })52      .getOne()53    return account54  }...Using AI Code Generation
1var argosy = require('argosy')2var argosyPayments = require('argosy-payments')3var argosyPatterns = require('argosy-patterns')4var argosyWeb = require('argosy-web')5var argosyIdentity = require('argosy-identity')6var argosyRpc = require('argosy-rpc')7var argosyChain = require('argosy-chain')8var argosyTransport = require('argosy-transport-http')9var argosyTransportWs = require('argosy-transport-ws')10var argosyTransportMemory = require('argosy-transport-memory')11var argosyTransportRedis = require('argosy-transport-redis')12var argosyTransport = require('argosy-transport')13var argosyKoa = require('argosy-koa')14var argosyExpress = require('argosy-express')15var argosyConsole = require('argosy-console')16var argosyRouter = require('argosy-router')17var argosyService = require('argosy-service')18var argosyResource = require('argosy-resource')19var argosyHapi = require('argosy-hapi')20var argosyHapiPlugin = require('argosy-hapi-plugin')21var argosyKoaPlugin = require('argosy-koa-plugin')22var argosyExpressPlugin = require('argosy-express-plugin')23var argosyKoaRouter = require('argosy-koa-router')24var argosyExpressRouter = require('argosy-express-router')25var argosyKoaRouter = require('argosy-koa-router')26var argosyExpressRouter = require('argosy-express-router')27var argosyKoaRouter = require('argosy-koa-router')28var argosyExpressRouter = require('argosy-express-router')29var argosyKoaRouter = require('argosy-koa-router')30var argosyExpressRouter = require('argosy-express-router')31var argosyKoaRouter = require('argosy-koa-router')32var argosyExpressRouter = require('argosy-express-router')33var argosyKoaRouter = require('argosUsing AI Code Generation
1var argosy = require('argosy');2var account = require('argosy-pattern-account');3var pattern = require('argosy-pattern');4var argosyService = argosy();5argosyService.accept(account.patterns.account);6argosyService.pipe(argosyService);7argosyService.act({Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyContract = require('argosy-contract')4var argosyAccount = require('argosy-account')5var argosyPattern = require('argosy-pattern')6var argosyContract = require('argosy-contract')7var argosy = require('argosy')8var argosyPattern = require('argosy-pattern')9var argosyAccount = require('argosy-account')10var argosyContract = require('argosy-contract')11var argosyService = require('argosy-service')12var argosy = require('argosy')13var argosyPattern = require('argosy-pattern')14var argosyAccount = require('argosy-account')15var argosyContract = require('argosy-contract')16var argosyService = require('argosy-service')17var argosy = require('argosy')18var argosyPattern = require('argosy-pattern')19var argosyAccount = require('argosy-account')20var argosyContract = require('argosy-contract')21var argosyService = require('argosy-service')22var argosy = require('argosy')23var argosyPattern = require('argosy-pattern')24var argosyAccount = require('argosy-account')25var argosyContract = require('argosy-contract')26var argosyService = require('argosy-service')27var argosy = require('argosy')28var argosyPattern = require('argosy-pattern')29var argosyAccount = require('argosy-account')30var argosyContract = require('argosy-contract')31var argosyService = require('argosy-service')32var argosy = require('argosy')33var argosyPattern = require('argosy-pattern')34var argosyAccount = require('argosy-account')35var argosyContract = require('argosy-contract')36var argosyService = require('argosy-service')37var argosy = require('argosy')38var argosyPattern = require('argosy-pattern')39var argosyAccount = require('argosyUsing AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyAccount = require('argosy-account')4var argosyService = argosy()5var argosyPatternService = argosyPattern()6var argosyAccountService = argosyAccount()7argosyService.use(argosyPatternService)8argosyService.use(argosyAccountService)9var accountPattern = {10}11var accountPattern2 = {12}13var accountPattern3 = {14}15var accountPattern4 = {16}17var accountPattern5 = {18}19var accountPattern6 = {20}21var accountPattern7 = {22}23var accountPattern8 = {24}25var accountPattern9 = {26}27var accountPattern10 = {28}29var accountPattern11 = {30}31var accountPattern12 = {32}33var accountPattern13 = {34}35var accountPattern14 = {Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = {3    account: {4    }5}6var argosyService = argosy()7    .use(argosyPattern)8    .use(argosyPattern.account.create, function (account, callback) {9        callback(null, 'account created')10    })11    .use(argosyPattern.account.get, function (account, callback) {12        callback(null, 'account retrieved')13    })14argosyService.listen(3000)15var argosy = require('argosy')16var argosyPattern = {17    account: {18    }19}20var argosyService = argosy()21    .use(argosyPattern)22    .use(argosyPattern.account.create, function (account, callback) {23        callback(null, 'account created')24    })25    .use(argosyPattern.account.get, function (account, callback) {26        callback(null, 'account retrieved')27    })28argosyService.listen(3000)29var argosy = require('argosy')30var argosyPattern = {31    account: {32    }33}34var argosyService = argosy()35    .use(argosyPattern)36    .use(argosyPattern.account.create, function (account, callback) {37        callback(null, 'account created')38    })39    .use(argosyPattern.account.get, function (account, callback) {40        callback(null, 'account retrieved')41    })42argosyService.listen(3000)43var argosy = require('argosy')44var argosyPattern = {45    account: {46    }47}48var argosyService = argosy()49    .use(argosyPattern)50    .use(argosyPattern.account.create, function (account, callback) {51        callback(null, 'account created')52    })53    .use(argosyPattern.account.get, function (account, callback) {54        callback(nullLearn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
