Skip to content

Commit

Permalink
test(admin-users): fix mock modules
Browse files Browse the repository at this point in the history
Mock modules need to run inside beforeEach blocks otherwise they can
overwrite each other if they have the same names.
  • Loading branch information
petebacondarwin committed Oct 6, 2013
1 parent f4d3d8d commit cca1cb2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
10 changes: 6 additions & 4 deletions client/test/unit/app/admin/users/admin-users-edit.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
describe('admin-users-edit', function()
{
angular.module('mocks', []).value('I18N.MESSAGES', {});
beforeEach(module('admin-users-edit', 'mocks'));
describe('admin-users-edit', function() {

beforeEach(function() {
angular.module('I18N-mock', []).value('I18N.MESSAGES', {});
});
beforeEach(module('admin-users-edit', 'I18N-mock'));

describe('UsersEditCtrl', function () {
function createLocals() {
Expand Down
12 changes: 6 additions & 6 deletions client/test/unit/app/admin/users/admin-users-list.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
describe('admin-users-list', function () {
describe('admin-users-list', function() {

angular.module('mocks', []).value('I18N.MESSAGES', {});
beforeEach(module('admin-users-edit', 'mocks'));

beforeEach(module('admin-users-list', 'mocks'));
beforeEach(function() {
angular.module('I18N-mock', []).value('I18N.MESSAGES', {});
});
beforeEach(module('admin-users-list', 'I18N-mock'));

describe('UsersListCtrl', function () {

it('should set up the scope correctly', inject(function ($controller) {
it('should set up the scope correctly', inject(function($controller) {
var locals = {
$scope: {},
crudListMethods: jasmine.createSpy('crudListMethods'),
Expand Down
14 changes: 8 additions & 6 deletions client/test/unit/app/admin/users/uniqueEmail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ describe('uniqueEmail directive', function() {
$scope.$digest();
}

// Mockup Users resource
angular.module('mocks', []).factory('Users', function() {
Users = jasmine.createSpyObj('Users', ['query']);
return Users;
beforeEach(function() {
// Mockup Users resource
angular.module('mock-Users', []).factory('Users', function() {
Users = jasmine.createSpyObj('Users', ['query']);
return Users;
});
});

beforeEach(module('admin-users-edit-uniqueEmail', 'mocks'));
beforeEach(module('admin-users-edit-uniqueEmail', 'mock-Users'));

beforeEach(inject(function($compile, $rootScope){
$scope = $rootScope;
Expand Down

0 comments on commit cca1cb2

Please sign in to comment.