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?
angularjs protractor mockito
New contributor
add a comment |
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?
angularjs protractor mockito
New contributor
add a comment |
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?
angularjs protractor mockito
New contributor
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
angularjs protractor mockito
New contributor
New contributor
New contributor
asked Nov 8 at 9:14
Peter Lappin
61
61
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password