Update tests to fail build and fix failing tests

This commit is contained in:
kiswa 2017-03-10 01:45:36 +00:00
parent 169ab817fb
commit 7ee796149d
6 changed files with 97 additions and 96 deletions

View File

@ -13,7 +13,7 @@ before_script:
- chmod a+w tests.db
script:
- ./src/api/vendor/phpunit/phpunit/phpunit -c test/api/phpunit.xml
- gulp coverage
- gulp test-app && gulp coverage
after_success:
- echo -e "<?php\n print phpversion();" > version.php
- curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh

View File

@ -2,7 +2,78 @@
var MockBrowser = require('mock-browser').mocks.MockBrowser,
mockBrowser = new MockBrowser(),
chai = require('chai');
chai = require('chai'),
users = [
{
id: '1',
default_board_id: '0',
username: 'tester',
security_level: '2',
user_option_id: '0',
board_access: []
},
{
id: '2',
default_board_id: '0',
username: 'test',
security_level: '3',
user_option_id: '0',
board_access: []
}
],
boards = [
{
id: 1,
name: 'testing',
is_active: true,
columns: [{
id: 1,
name: 'Column 1',
position: 0,
board_id: 1,
tasks: []
}],
categories: [{
id: 1,
name: 'Category 1'
}],
issue_trackers: [],
users: [ users[1] ]
},
{
id: 2,
name: 'test',
is_active: false,
columns: [{
id: 2,
name: 'Column 1',
position: 0,
board_id: 2,
tasks: []
}],
categories: [],
issue_trackers: [],
users
}
],
actions = [
{
id: 1,
trigger: 1,
source_id: 1,
type: 1,
change_to: 'test',
board_id: 1
},
{
id: 2,
trigger: 2,
source_id: 2,
type: 2,
change_to: 'testing',
board_id: 2
}
];
global.window = mockBrowser.getWindow();
global.document = mockBrowser.getDocument();
@ -57,12 +128,7 @@ global.AuthServiceMock = {
userOptions: {
show_animations: false
},
userChanged: RxJs.Observable.of({
id: 1,
username: 'tester',
default_board_id: 0,
security_level: 2
}),
userChanged: RxJs.Observable.of(users[0]),
updateUser: user => {
},
login: () => {
@ -127,85 +193,15 @@ global.ModalServiceMock = function() {
};
};
var users = [
{
id: '1',
default_board_id: '0',
username: 'tester',
security_level: '2',
user_option_id: '0',
board_access: []
},
{
id: '2',
default_board_id: '0',
username: 'test',
security_level: '3',
user_option_id: '0',
board_access: []
}
];
var boards = [
{
id: 1,
name: 'testing',
is_active: true,
columns: [{
id: 1,
name: 'Column 1',
position: 0,
board_id: 1,
tasks: []
}],
categories: [{
id: 1,
name: 'Category 1'
}],
issue_trackers: [],
users: [ users[1] ]
},
{
id: 2,
name: 'test',
is_active: false,
columns: [{
id: 2,
name: 'Column 1',
position: 0,
board_id: 2,
tasks: []
}],
categories: [],
issue_trackers: [],
users
}
];
var actions = [
{
id: 1,
trigger: 1,
source_id: 1,
type: 1,
change_to: 'test',
board_id: 1
},
{
id: 2,
trigger: 2,
source_id: 2,
type: 2,
change_to: 'testing',
board_id: 2
}
];
global.StringsServiceMock = {
stringsChanged: {
subscribe: function() {}
subscribe(callback) {
callback({
settings: 'Settings'
});
}
},
loadStrings: function() {}
loadStrings() {}
};
global.SettingsServiceMock = function() {
@ -254,6 +250,8 @@ global.SettingsServiceMock = function() {
};
global.UserAdminServiceMock = function() {
var userList = users.slice();
return {
addUser: user => {
return RxJs.Observable.of({
@ -261,7 +259,7 @@ global.UserAdminServiceMock = function() {
alerts: [],
data: [
null,
users.concat(user)
userList.concat(user)
]
});
},
@ -271,8 +269,8 @@ global.UserAdminServiceMock = function() {
alerts: [],
data: [
null,
JSON.stringify(users[1]),
users
JSON.stringify(userList[1]),
userList
]
});
},
@ -282,7 +280,7 @@ global.UserAdminServiceMock = function() {
alerts: [],
data: [
null,
users.slice(1)
userList.slice(1)
]
});
}

View File

@ -1,5 +1,5 @@
/* global expect AuthServiceMock SettingsServiceMock BoardAdminServiceMock
ModalServiceMock NotificationsServiceMock */
ModalServiceMock NotificationsServiceMock StringsServiceMock */
var dirs = '../../../../',
path = dirs + 'build/settings/board-admin/',
pathDrag = dirs + 'node_modules/ng2-dragula/components/',
@ -15,7 +15,8 @@ describe('BoardAdmin', () => {
boardAdmin = new BoardAdmin(AuthServiceMock, modalService,
new SettingsServiceMock(), new BoardAdminServiceMock(),
new NotificationsServiceMock(), new DragulaService());
new NotificationsServiceMock(), StringsServiceMock,
new DragulaService());
});
it('has a function to get a color', () => {

View File

@ -1,4 +1,4 @@
/* global expect TitleMock */
/* global expect TitleMock StringsServiceMock */
var path = '../../../build/settings/',
Settings = require(path + 'settings.component.js').Settings;
@ -8,7 +8,7 @@ describe('Settings', () => {
beforeEach(() => {
title = new TitleMock();
// Just need to create Settings to set Title
var settings = new Settings(null, title);
var settings = new Settings(null, StringsServiceMock, title);
settings;
});

View File

@ -26,7 +26,7 @@ describe('UserAdmin', () => {
});
it('has a function to add or edit a user - Add', done => {
userAdmin.modalProps.title = 'Add';
userAdmin.modalProps.prefix = true;
userAdmin.modalProps.user = newUser;
userAdmin.addEditUser();
@ -38,8 +38,9 @@ describe('UserAdmin', () => {
});
it('has a function to add or edit a user - Edit', done => {
userAdmin.modalProps.title = 'Edit';
userAdmin.modalProps.prefix = false;
userAdmin.modalProps.user = newUser;
userAdmin.modalProps.user.id = 2;
userAdmin.addEditUser();

View File

@ -1,4 +1,4 @@
/* global expect ConstantsMock RouterMock AuthServiceMock NotificationsServiceMock */
/* global expect ConstantsMock RouterMock AuthServiceMock NotificationsServiceMock StringsServiceMock */
var path = '../../../../build/shared/top-nav/',
TopNav = require(path + 'top-nav.component.js').TopNav;
@ -9,7 +9,8 @@ describe('TopNav', () => {
beforeEach(() => {
router = new RouterMock();
topNav = new TopNav(ConstantsMock, router,
AuthServiceMock, new NotificationsServiceMock());
AuthServiceMock, new NotificationsServiceMock(),
StringsServiceMock);
});
it('has pageName', () => {