Fix app tests and update/clean tests
This commit is contained in:
parent
0577661791
commit
2a0d780459
@ -158,7 +158,9 @@ gulp.task('test', ['test-app', 'test-api']);
|
||||
|
||||
gulp.task('test-app', ['tsc'], () => {
|
||||
return gulp.src(paths.tests_app)
|
||||
.pipe(mocha());
|
||||
.pipe(mocha({
|
||||
require: ['./test/app/mocks.js']
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('coverage', ['tsc'], () => {
|
||||
@ -166,7 +168,9 @@ gulp.task('coverage', ['tsc'], () => {
|
||||
.pipe(coverage.instrument({
|
||||
pattern: ['build/**/*.js']
|
||||
}))
|
||||
.pipe(mocha())
|
||||
.pipe(mocha({
|
||||
require: ['./test/app/mocks.js']
|
||||
}))
|
||||
.pipe(coverage.gather())
|
||||
.pipe(coverage.format())
|
||||
.pipe(gulp.dest('./'));
|
||||
|
@ -60,6 +60,7 @@
|
||||
"gulp-uglify": "^2.0.0",
|
||||
"gulp-util": "^3.0.7",
|
||||
"merge-stream": "^1.0.0",
|
||||
"mock-browser": "^0.92.12",
|
||||
"ng2-dragula": "^1.1.10",
|
||||
"reflect-metadata": "^0.1.8",
|
||||
"rxjs": "5.0.0-beta.6",
|
||||
|
@ -1,33 +1,9 @@
|
||||
/* globals expect RxJs localStorage */
|
||||
require('reflect-metadata/Reflect.js');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../build/app.',
|
||||
var path = '../../build/app.',
|
||||
apihttp = require(path + 'api-http.js'),
|
||||
ApiHttp = apihttp.ApiHttp,
|
||||
RxJs = require('rxjs/Rx');
|
||||
|
||||
global.localStorage = (function() {
|
||||
var storage = {};
|
||||
|
||||
return {
|
||||
getItem: (key) => {
|
||||
if (storage.hasOwnProperty(key)) {
|
||||
return storage[key];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
setItem: (key, value) => {
|
||||
storage[key] = value;
|
||||
},
|
||||
removeItem: (key) => {
|
||||
if (storage.hasOwnProperty(key)) {
|
||||
delete storage[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
ApiHttp = apihttp.ApiHttp;
|
||||
|
||||
describe('ApiHttp', () => {
|
||||
var apiHttp;
|
||||
@ -46,13 +22,13 @@ describe('ApiHttp', () => {
|
||||
});
|
||||
|
||||
it('injects headers', () => {
|
||||
global.localStorage.setItem('taskboard.jwt', 'testjwt');
|
||||
localStorage.setItem('taskboard.jwt', 'testjwt');
|
||||
|
||||
var headers = apiHttp.getRequestOptionArgs().headers;
|
||||
|
||||
expect(headers._headersMap.get('Content-Type')[0])
|
||||
expect(headers._headersMap.get('content-type')[0])
|
||||
.to.equal('application/json');
|
||||
expect(headers._headersMap.get('Authorization')[0])
|
||||
expect(headers._headersMap.get('authorization')[0])
|
||||
.to.equal('testjwt');
|
||||
});
|
||||
|
||||
@ -67,13 +43,13 @@ describe('ApiHttp', () => {
|
||||
|
||||
apiHttp.intercept(RxJs.Observable.of(response))
|
||||
.map(response => {
|
||||
expect(global.localStorage.getItem('taskboard.jwt'))
|
||||
expect(localStorage.getItem('taskboard.jwt'))
|
||||
.to.equal('testjwt');
|
||||
});
|
||||
|
||||
apiHttp.intercept(RxJs.Observable.throw(null, response))
|
||||
.catch((err, caught) => {
|
||||
expect(global.localStorage.getItem('taskboard.jwt'))
|
||||
expect(localStorage.getItem('taskboard.jwt'))
|
||||
.to.equal('');
|
||||
});
|
||||
});
|
||||
|
11
test/app/app.module.spec.js
Normal file
11
test/app/app.module.spec.js
Normal file
@ -0,0 +1,11 @@
|
||||
/* global expect */
|
||||
var path = '../../build/',
|
||||
AppModule = require(path + 'app.module.js').AppModule;
|
||||
|
||||
describe('Module', () => {
|
||||
it('provides an AppModule class', () => {
|
||||
var appModule = new AppModule();
|
||||
expect(appModule).to.be.an('object');
|
||||
});
|
||||
});
|
||||
|
@ -1,11 +1,14 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../build/',
|
||||
/* global expect */
|
||||
var path = '../../build/',
|
||||
routes = require(path + 'app.routes.js');
|
||||
|
||||
describe('Routes', () => {
|
||||
it('provides APP_ROUTER_PROVIDERS', () => {
|
||||
expect(routes.APP_ROUTER_PROVIDERS).to.be.an('array');
|
||||
it('provides APP_ROUTING', () => {
|
||||
expect(routes.APP_ROUTING).to.be.an('object');
|
||||
});
|
||||
|
||||
it('provides APP_COMPONENTS', () => {
|
||||
expect(routes.APP_COMPONENTS).to.be.an('array');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/dashboard/calendar/',
|
||||
/* global expect */
|
||||
var path = '../../../../build/dashboard/calendar/',
|
||||
Calendar = require(path + 'calendar.component.js').Calendar;
|
||||
|
||||
describe('Calendar', () => {
|
||||
|
@ -1,8 +1,5 @@
|
||||
require('../../mocks.js');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/dashboard/charts/',
|
||||
/* globals expect */
|
||||
var path = '../../../../build/dashboard/charts/',
|
||||
Charts = require(path + 'charts.component.js').Charts;
|
||||
|
||||
describe('Charts', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global ConstantsMock AuthServiceMock RouterMock NotificationsServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../build/login/',
|
||||
/* global expect ConstantsMock AuthServiceMock RouterMock NotificationsServiceMock */
|
||||
var path = '../../../build/login/',
|
||||
Login = require(path + 'login.component.js').Login;
|
||||
|
||||
describe('Login', () => {
|
||||
|
@ -1,4 +1,11 @@
|
||||
var RxJs = require('rxjs/Rx');
|
||||
var MockBrowser = require('mock-browser').mocks.MockBrowser,
|
||||
mockBrowser = new MockBrowser(),
|
||||
chai = require('chai');
|
||||
|
||||
global.RxJs = require('rxjs/Rx');
|
||||
global.expect = chai.expect;
|
||||
global.document = mockBrowser.getDocument();
|
||||
global.localStorage = mockBrowser.getLocalStorage();
|
||||
|
||||
global.Chartist = {
|
||||
Pie: function(id, data, opts) {
|
||||
|
24
test/app/settings/board-admin/board-admin.component.spec.js
Normal file
24
test/app/settings/board-admin/board-admin.component.spec.js
Normal file
@ -0,0 +1,24 @@
|
||||
/* global expect AuthServiceMock ModalServiceMock */
|
||||
var path = '../../../../build/settings/board-admin/',
|
||||
BoardAdmin = require(path + 'board-admin.component.js').BoardAdmin,
|
||||
DragulaService = require('../../../../node_modules/ng2-dragula/src/app/providers/dragula.provider.js')
|
||||
.DragulaService;
|
||||
|
||||
describe('BoardAdmin', () => {
|
||||
var boardAdmin;
|
||||
|
||||
beforeEach(() => {
|
||||
boardAdmin = new BoardAdmin(AuthServiceMock, new ModalServiceMock(),
|
||||
new DragulaService());
|
||||
});
|
||||
|
||||
it('has a function to get a color', () => {
|
||||
var color = boardAdmin.getColor({ defaultColor: 'test' });
|
||||
expect(color).to.equal('test');
|
||||
});
|
||||
|
||||
it('implements ngAfterContentInit', () => {
|
||||
expect(boardAdmin.ngAfterContentInit).to.be.a('function');
|
||||
});
|
||||
});
|
||||
|
125
test/app/settings/board-admin/board-data.model.spec.js
Normal file
125
test/app/settings/board-admin/board-data.model.spec.js
Normal file
@ -0,0 +1,125 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/settings/board-admin/',
|
||||
BoardData = require(path + 'board-data.model.js').BoardData;
|
||||
|
||||
describe('BoardData', () => {
|
||||
var boardData;
|
||||
|
||||
beforeEach(() => {
|
||||
boardData = new BoardData();
|
||||
});
|
||||
|
||||
it('has a boardName property', () => {
|
||||
expect(boardData.boardName).to.be.a('string');
|
||||
});
|
||||
|
||||
it('has a columns property', () => {
|
||||
expect(boardData.columns).to.be.an('array');
|
||||
});
|
||||
|
||||
it('has a categories property', () => {
|
||||
expect(boardData.categories).to.be.an('array');
|
||||
});
|
||||
|
||||
it('has an issueTrackers property', () => {
|
||||
expect(boardData.issueTrackers).to.be.an('array');
|
||||
});
|
||||
|
||||
it('has a users property', () => {
|
||||
expect(boardData.users).to.be.an('array');
|
||||
});
|
||||
|
||||
it('has a categoryDefaultColor property', () => {
|
||||
expect(boardData.categoryDefaultColor).to.be.a('string');
|
||||
});
|
||||
|
||||
it('has a newColumnName property', () => {
|
||||
expect(boardData.newColumnName).to.be.a('string');
|
||||
});
|
||||
|
||||
it('has a newCategoryName property', () => {
|
||||
expect(boardData.newCategoryName).to.be.a('string');
|
||||
});
|
||||
|
||||
it('has an issueTrackerUrl property', () => {
|
||||
expect(boardData.issueTrackerUrl).to.be.a('string');
|
||||
});
|
||||
|
||||
it('has an issueTrackerBugId property', () => {
|
||||
expect(boardData.issueTrackerBugId).to.be.a('string');
|
||||
});
|
||||
|
||||
it('allows a column to be added', () => {
|
||||
boardData.addColumn();
|
||||
expect(boardData.columns.length).to.equal(0);
|
||||
|
||||
boardData.newColumnName = 'test';
|
||||
boardData.addColumn();
|
||||
|
||||
expect(boardData.columns.length).to.equal(1);
|
||||
expect(boardData.columns[0].name).to.equal('test');
|
||||
expect(boardData.newColumnName).to.equal('');
|
||||
});
|
||||
|
||||
it('allows a column to be removed', () => {
|
||||
var column = { name: 'test' };
|
||||
boardData.removeColumn(column);
|
||||
|
||||
boardData.columns.push(column);
|
||||
expect(boardData.columns.length).to.equal(1);
|
||||
|
||||
boardData.removeColumn(column);
|
||||
expect(boardData.columns.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('allows a category to be added', () => {
|
||||
boardData.addCategory();
|
||||
expect(boardData.categories.length).to.equal(0);
|
||||
|
||||
boardData.newCategoryName = 'test';
|
||||
boardData.categoryDefaultColor = '#ffffe0';
|
||||
boardData.addCategory();
|
||||
|
||||
expect(boardData.categories.length).to.equal(1);
|
||||
expect(boardData.categories[0].name).to.equal('test');
|
||||
expect(boardData.newCategoryName).to.equal('');
|
||||
expect(boardData.categoryDefaultColor).to.equal('#ffffe0');
|
||||
});
|
||||
|
||||
it('allows a category to be removed', () => {
|
||||
var category = { name: 'test', defaultColor: '#ffffe0' };
|
||||
boardData.removeCategory(category);
|
||||
|
||||
boardData.categories.push(category);
|
||||
expect(boardData.categories.length).to.equal(1);
|
||||
|
||||
boardData.removeCategory(category);
|
||||
expect(boardData.categories.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('allows an issue tracker to be added', () => {
|
||||
boardData.addIssueTracker();
|
||||
expect(boardData.issueTrackers.length).to.equal(0);
|
||||
|
||||
boardData.issueTrackerUrl = 'test';
|
||||
boardData.issueTrackerBugId = 'test';
|
||||
boardData.addIssueTracker();
|
||||
|
||||
expect(boardData.issueTrackers.length).to.equal(1);
|
||||
expect(boardData.issueTrackers[0].url).to.equal('test');
|
||||
expect(boardData.issueTrackerUrl).to.equal('');
|
||||
expect(boardData.issueTrackerBugId).to.equal('');
|
||||
});
|
||||
|
||||
it('allows an issue tracker to be removed', () => {
|
||||
var issueTracker = { url: 'test', bugId: 'test' };
|
||||
boardData.removeIssueTracker(issueTracker);
|
||||
|
||||
boardData.issueTrackers.push(issueTracker);
|
||||
expect(boardData.issueTrackers.length).to.equal(1);
|
||||
|
||||
boardData.removeIssueTracker(issueTracker);
|
||||
expect(boardData.issueTrackers.length).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global UserAdminServiceMock NotificationsServiceMock AuthServiceMock ModalServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/settings/user-admin/',
|
||||
/* global expect UserAdminServiceMock NotificationsServiceMock AuthServiceMock ModalServiceMock */
|
||||
var path = '../../../../build/settings/user-admin/',
|
||||
UserAdmin = require(path + 'user-admin.component.js').UserAdmin;
|
||||
|
||||
describe('UserAdmin', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global HttpMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/settings/user-admin/',
|
||||
/* global expect HttpMock */
|
||||
var path = '../../../../build/settings/user-admin/',
|
||||
UserAdminService = require(path + 'user-admin.service.js').UserAdminService;
|
||||
|
||||
describe('UserAdminService', () => {
|
||||
@ -36,7 +34,7 @@ describe('UserAdminService', () => {
|
||||
userAdminService.removeUser(1).subscribe(user => {
|
||||
expect(user.endpoint).to.equal('api/users/1');
|
||||
done();
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global AuthServiceMock NotificationsServiceMock UserSettingsServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/settings/user-settings/',
|
||||
/* global expect AuthServiceMock NotificationsServiceMock UserSettingsServiceMock */
|
||||
var path = '../../../../build/settings/user-settings/',
|
||||
UserSettings = require(path + 'user-settings.component.js').UserSettings;
|
||||
|
||||
describe('UserSettings', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global AuthServiceMock HttpMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/settings/user-settings/',
|
||||
/* global expect AuthServiceMock HttpMock */
|
||||
var path = '../../../../build/settings/user-settings/',
|
||||
UserSettingsService =
|
||||
require(path + 'user-settings.service.js').UserSettingsService;
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global AuthServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/auth/',
|
||||
/* global expect AuthServiceMock */
|
||||
var path = '../../../../build/shared/auth/',
|
||||
AuthGuard = require(path + 'auth.guard.js').AuthGuard;
|
||||
|
||||
describe('AuthGuard', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global ConstantsMock, HttpMock, RouterMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/auth/',
|
||||
/* global expect ConstantsMock, HttpMock, RouterMock */
|
||||
var path = '../../../../build/shared/auth/',
|
||||
AuthService = require(path + 'auth.service.js').AuthService;
|
||||
|
||||
describe('AuthService', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../build/shared/',
|
||||
/* global expect */
|
||||
var path = '../../../build/shared/',
|
||||
Constants = require(path + 'constants.js').Constants;
|
||||
|
||||
describe('Constants', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global ModalServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/modal/',
|
||||
/* global expect ModalServiceMock */
|
||||
var path = '../../../../build/shared/modal/',
|
||||
Modal = require(path + 'modal.component.js').Modal;
|
||||
|
||||
describe('Modal', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/modal/',
|
||||
/* globals expect */
|
||||
var path = '../../../../build/shared/modal/',
|
||||
ModalService = require(path + 'modal.service.js').ModalService;
|
||||
|
||||
describe('ModalService', () => {
|
||||
@ -12,7 +11,7 @@ describe('ModalService', () => {
|
||||
modal = {
|
||||
modalId: 'testModal',
|
||||
isOpen: false
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('has an array of modals', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/models/',
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Notification = require(path + 'notification.model.js').Notification;
|
||||
|
||||
describe('Notification', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/models/',
|
||||
/* globals expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
User = require(path + 'user.model.js').User;
|
||||
|
||||
describe('User', () => {
|
||||
|
@ -1,7 +1,5 @@
|
||||
/* global NotificationsServiceMock */
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/notifications/',
|
||||
/* global expect NotificationsServiceMock */
|
||||
var path = '../../../../build/shared/notifications/',
|
||||
Notifications = require(path + 'notifications.component.js').Notifications;
|
||||
|
||||
describe('Notifications', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/notifications/',
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/notifications/',
|
||||
NotificationsService = require(path + 'notifications.service.js')
|
||||
.NotificationsService;
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
/* global ConstantsMock RouterMock AuthServiceMock NotificationsServiceMock */
|
||||
|
||||
require('../../mocks.js');
|
||||
|
||||
var chai = require('chai'),
|
||||
expect = chai.expect,
|
||||
path = '../../../../build/shared/top-nav/',
|
||||
/* global expect ConstantsMock RouterMock AuthServiceMock NotificationsServiceMock */
|
||||
var path = '../../../../build/shared/top-nav/',
|
||||
TopNav = require(path + 'top-nav.component.js').TopNav;
|
||||
|
||||
describe('TopNav', () => {
|
||||
|
Reference in New Issue
Block a user