Why isn't my mock of table data working? (Protractor/AngularJS)











up vote
1
down vote

favorite












I'm using Mockito and Protractor to do front end tests on an Angular app. I'm trying to add mock data to a table to test functionality but no matter what I do the table is never populated. Here is my beforeEach() :



   'use strict';

var mock = require('protractor-http-mock');
var ipWhitelistPage = require('./ipWhitelist.page');
var IPWhitelistingRulesBuilder = require(__rootPath + 'mocks/ipWhitelisting/ipWhitelistingRules.get.builder')
var page;

fdescribe('IP Whitelist Page - ', function () {
beforeEach(function() {
var rulesMock = new IPWhitelistingRulesBuilder().createRule(1, "Rule 1", "127.0.0.1", false).build();
console.log(rulesMock);
mock([rulesMock]);
page = new ipWhitelistPage();
page.goTo();
browser.waitForAngular();
});


Here is my builder :



    'use strict'
module.exports = IPWhitelistingRulesBuilder;

function IPWhitelistingRulesBuilder() {

var mockedRules = {
ipAddresses:
};

var response = {
data: mockedRules,
status: 200
};

this.createRule = function(id, name, address, enabled) {
new RuleBuilder(this, getRule(), mockedRules.ipAddresses)
.withId(id)
.withName(name)
.withAddress(address)
.withEnabled(enabled)
.addToTable();

return this;
}


this.build = function() {
return {
request : {
path: browser.params.smartHost + 'ipWhitelist',
method: 'GET'
},
response : response
};
};
};

function RuleBuilder(ipWhitelistRuleBuilder, rule, rulesTable) {

this.withId = function(id) {
rule.id = id;
return this;
};

this.withName = function(name) {
rule.name = name;
return this;
};

this.withAddress = function(address) {
rule.address = address;
return this;
};

this.withEnabled = function(enabled) {
rule.enabled = enabled;
return this;
};

this.addToTable = function() {
rulesTable.push(rule);
return this;
};
};

function getRule() {
var rule = {
id:1,
name:"Example Rule",
address:"127.0.0.1",
enabled:false
};
return rule;
};


My table always appears to have nothing in it when the tests run even though I add a row before each test. Any ideas whats wrong?










share|improve this question







New contributor




Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    1
    down vote

    favorite












    I'm using Mockito and Protractor to do front end tests on an Angular app. I'm trying to add mock data to a table to test functionality but no matter what I do the table is never populated. Here is my beforeEach() :



       'use strict';

    var mock = require('protractor-http-mock');
    var ipWhitelistPage = require('./ipWhitelist.page');
    var IPWhitelistingRulesBuilder = require(__rootPath + 'mocks/ipWhitelisting/ipWhitelistingRules.get.builder')
    var page;

    fdescribe('IP Whitelist Page - ', function () {
    beforeEach(function() {
    var rulesMock = new IPWhitelistingRulesBuilder().createRule(1, "Rule 1", "127.0.0.1", false).build();
    console.log(rulesMock);
    mock([rulesMock]);
    page = new ipWhitelistPage();
    page.goTo();
    browser.waitForAngular();
    });


    Here is my builder :



        'use strict'
    module.exports = IPWhitelistingRulesBuilder;

    function IPWhitelistingRulesBuilder() {

    var mockedRules = {
    ipAddresses:
    };

    var response = {
    data: mockedRules,
    status: 200
    };

    this.createRule = function(id, name, address, enabled) {
    new RuleBuilder(this, getRule(), mockedRules.ipAddresses)
    .withId(id)
    .withName(name)
    .withAddress(address)
    .withEnabled(enabled)
    .addToTable();

    return this;
    }


    this.build = function() {
    return {
    request : {
    path: browser.params.smartHost + 'ipWhitelist',
    method: 'GET'
    },
    response : response
    };
    };
    };

    function RuleBuilder(ipWhitelistRuleBuilder, rule, rulesTable) {

    this.withId = function(id) {
    rule.id = id;
    return this;
    };

    this.withName = function(name) {
    rule.name = name;
    return this;
    };

    this.withAddress = function(address) {
    rule.address = address;
    return this;
    };

    this.withEnabled = function(enabled) {
    rule.enabled = enabled;
    return this;
    };

    this.addToTable = function() {
    rulesTable.push(rule);
    return this;
    };
    };

    function getRule() {
    var rule = {
    id:1,
    name:"Example Rule",
    address:"127.0.0.1",
    enabled:false
    };
    return rule;
    };


    My table always appears to have nothing in it when the tests run even though I add a row before each test. Any ideas whats wrong?










    share|improve this question







    New contributor




    Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm using Mockito and Protractor to do front end tests on an Angular app. I'm trying to add mock data to a table to test functionality but no matter what I do the table is never populated. Here is my beforeEach() :



         'use strict';

      var mock = require('protractor-http-mock');
      var ipWhitelistPage = require('./ipWhitelist.page');
      var IPWhitelistingRulesBuilder = require(__rootPath + 'mocks/ipWhitelisting/ipWhitelistingRules.get.builder')
      var page;

      fdescribe('IP Whitelist Page - ', function () {
      beforeEach(function() {
      var rulesMock = new IPWhitelistingRulesBuilder().createRule(1, "Rule 1", "127.0.0.1", false).build();
      console.log(rulesMock);
      mock([rulesMock]);
      page = new ipWhitelistPage();
      page.goTo();
      browser.waitForAngular();
      });


      Here is my builder :



          'use strict'
      module.exports = IPWhitelistingRulesBuilder;

      function IPWhitelistingRulesBuilder() {

      var mockedRules = {
      ipAddresses:
      };

      var response = {
      data: mockedRules,
      status: 200
      };

      this.createRule = function(id, name, address, enabled) {
      new RuleBuilder(this, getRule(), mockedRules.ipAddresses)
      .withId(id)
      .withName(name)
      .withAddress(address)
      .withEnabled(enabled)
      .addToTable();

      return this;
      }


      this.build = function() {
      return {
      request : {
      path: browser.params.smartHost + 'ipWhitelist',
      method: 'GET'
      },
      response : response
      };
      };
      };

      function RuleBuilder(ipWhitelistRuleBuilder, rule, rulesTable) {

      this.withId = function(id) {
      rule.id = id;
      return this;
      };

      this.withName = function(name) {
      rule.name = name;
      return this;
      };

      this.withAddress = function(address) {
      rule.address = address;
      return this;
      };

      this.withEnabled = function(enabled) {
      rule.enabled = enabled;
      return this;
      };

      this.addToTable = function() {
      rulesTable.push(rule);
      return this;
      };
      };

      function getRule() {
      var rule = {
      id:1,
      name:"Example Rule",
      address:"127.0.0.1",
      enabled:false
      };
      return rule;
      };


      My table always appears to have nothing in it when the tests run even though I add a row before each test. Any ideas whats wrong?










      share|improve this question







      New contributor




      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I'm using Mockito and Protractor to do front end tests on an Angular app. I'm trying to add mock data to a table to test functionality but no matter what I do the table is never populated. Here is my beforeEach() :



         'use strict';

      var mock = require('protractor-http-mock');
      var ipWhitelistPage = require('./ipWhitelist.page');
      var IPWhitelistingRulesBuilder = require(__rootPath + 'mocks/ipWhitelisting/ipWhitelistingRules.get.builder')
      var page;

      fdescribe('IP Whitelist Page - ', function () {
      beforeEach(function() {
      var rulesMock = new IPWhitelistingRulesBuilder().createRule(1, "Rule 1", "127.0.0.1", false).build();
      console.log(rulesMock);
      mock([rulesMock]);
      page = new ipWhitelistPage();
      page.goTo();
      browser.waitForAngular();
      });


      Here is my builder :



          'use strict'
      module.exports = IPWhitelistingRulesBuilder;

      function IPWhitelistingRulesBuilder() {

      var mockedRules = {
      ipAddresses:
      };

      var response = {
      data: mockedRules,
      status: 200
      };

      this.createRule = function(id, name, address, enabled) {
      new RuleBuilder(this, getRule(), mockedRules.ipAddresses)
      .withId(id)
      .withName(name)
      .withAddress(address)
      .withEnabled(enabled)
      .addToTable();

      return this;
      }


      this.build = function() {
      return {
      request : {
      path: browser.params.smartHost + 'ipWhitelist',
      method: 'GET'
      },
      response : response
      };
      };
      };

      function RuleBuilder(ipWhitelistRuleBuilder, rule, rulesTable) {

      this.withId = function(id) {
      rule.id = id;
      return this;
      };

      this.withName = function(name) {
      rule.name = name;
      return this;
      };

      this.withAddress = function(address) {
      rule.address = address;
      return this;
      };

      this.withEnabled = function(enabled) {
      rule.enabled = enabled;
      return this;
      };

      this.addToTable = function() {
      rulesTable.push(rule);
      return this;
      };
      };

      function getRule() {
      var rule = {
      id:1,
      name:"Example Rule",
      address:"127.0.0.1",
      enabled:false
      };
      return rule;
      };


      My table always appears to have nothing in it when the tests run even though I add a row before each test. Any ideas whats wrong?







      angularjs protractor mockito






      share|improve this question







      New contributor




      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 8 at 9:14









      Peter Lappin

      61




      61




      New contributor




      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Peter Lappin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Peter Lappin is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204596%2fwhy-isnt-my-mock-of-table-data-working-protractor-angularjs%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Peter Lappin is a new contributor. Be nice, and check out our Code of Conduct.










           

          draft saved


          draft discarded


















          Peter Lappin is a new contributor. Be nice, and check out our Code of Conduct.













          Peter Lappin is a new contributor. Be nice, and check out our Code of Conduct.












          Peter Lappin is a new contributor. Be nice, and check out our Code of Conduct.















           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204596%2fwhy-isnt-my-mock-of-table-data-working-protractor-angularjs%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Liste der Kulturdenkmale in Wilsdruff

          Android Play Services Check