javascript - sorting feature in ngTable using Jasmine Testing -


I have created an application using ng-table, the application is working fine but I do not know how to The test is to write that sorting and GetData case

Can someone tell me some solution for testing that functionality

My code is given below

Jasmine test case

Workstation / Main.JS

  Angular Modules ('wsd.workstations', []). Controller ('Work Controller', Function ($ Rootscope, $ Scope, $ Filter, NGT Perm) {$ scope.myValues ​​= [{Name: "Moroni", Age: 50}, {Name: "Tianqum" Age: 43}, {Name: "Jacob", Age: 27}, {Name: "Nefe", Age: 29}, {Name: "ANOS", Age: 34}, {Name: "Tianjum", Age : {Name: "Nafie", Age: 29}, {Name: "Name": "Name": "Yakub" name "" named ", Age: 43}, {Name:" Yakub "," Age "}, {Name: Anoos ", Age: 34}, {Name:" Tianqum ", Age: 43} Age: 43}, {Name:" Yakub ", Age: 27}, {Name:" Nefe ", Age: 29}, { Name: "ANOS", Age: 34}, {Name: "Tiến" 27}, {name: "Ne Phi ", age: 29}, {name:" enos ", age: 34}] $ scope.tableParams = new ngTableParams ({sorting: {name: 'asc'}}, {getData: function ($ defer, params) {$ Scope.myValues ​​= $ filter ('orderby') ($ scope.myValues, Parameters; buyer by); $ defer.resolve ($ scope.myValues);}}); $ Scope.searchDocuments = function () {// some other logic};});   

update 2

I did this for testing, but < / P>

  & lt; receiving failure type = "" & gt; Type error: & amp; Apos; Undefined & amp; Apos;   

Testing cases < Sort the order ($ Q) (injection ($ Q) {var deferred = $ q.defer (); var promise = deferred; launch; Promise; Promise; (Name: "yakub", age: 27}, {name: "Nafie.") "Name" "Yakub", Age: 27}, Name: "Yakub", Name: "Enos", Age: 34}, {Name: "Tiankum", Age: 43}, {name: "Yakub", Age: 27} Age: 27}, {Name: "Nefe", Age: 2 9}, {Name: "Enos", Revenue Age: 43} {Name: "Neffe", Age: 2 9}, {Name: "Enos", Age: 34}, {Name: "Tianjum", Age: 43 }, {Name: "yakub", age: 27}, {name: "nephi", age: 2 9}, {name: "anos", age: 34}]; $ scope.getData (promise, $ scope. TableParams;}));

You could:

Announce the getData function on the controller's $ radius, thus making it available in your testing:

  $ scope.tableParams = new ngTableParams ({sorting: {name: 'asc '}}, {GetData: $ scope.getData}); $ Scope.getData = function ($ defer, params) {$ scope.myValues ​​= $ Filters ('orderby') ($ scope.myValues, Parameters.ready ()); $ Defer.resolve ($ scope.myValues); }   

Inject into the first $ q ().

Create a wired object using $ q.

Test your unit to some $ scope.myValues.

Declare a variable that has the expected result - which is your sort of $ scope.myValues ​​array. Then:

  Promise. Then (work (result) {hope (results) .tall (expected result);} $ scope.getData (deferred, $ scope.tableParams);    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -