Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(browser): remove subsequent duplicate module
Browse files Browse the repository at this point in the history
browser.removeMockModule() misses next duplicate module because of
iteration over an array it's modifying.
  • Loading branch information
donataswix authored and juliemr committed Apr 2, 2015
1 parent e3d4ad1 commit b783dd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Protractor.prototype.clearMockModules = function() {
Protractor.prototype.removeMockModule = function(name) {
for (var i = 0; i < this.mockModules_.length; ++i) {
if (this.mockModules_[i].name == name) {
this.mockModules_.splice(i, 1);
this.mockModules_.splice(i--, 1);
}
}
};
Expand Down
10 changes: 10 additions & 0 deletions spec/basic/mockmodule_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ describe('mock modules', function() {
expect(element(by.css('[app-version]')).getText()).toEqual('2');
});

it('should remove duplicate mock modules', function () {
browser.addMockModule('moduleA', mockModuleA);
browser.addMockModule('moduleA', mockModuleA);
browser.removeMockModule('moduleA');

browser.get('index.html');

expect(element(by.css('[app-version]')).getText()).toEqual('0.1');
});

it('should be a noop to remove a module which does not exist', function() {
browser.addMockModule('moduleA', mockModuleA);
browser.removeMockModule('moduleB');
Expand Down

0 comments on commit b783dd8

Please sign in to comment.