Update models and test coverage
This commit is contained in:
parent
bdf7393ca4
commit
c5dcce74c4
@ -25,7 +25,6 @@ export class BoardService {
|
||||
|
||||
updateActiveBoard(board: Board): void {
|
||||
let newBoard = this.convertBoardData(board);
|
||||
console.log(newBoard); // tslint:disable-line
|
||||
this.activeBoard.next(newBoard);
|
||||
}
|
||||
|
||||
|
@ -82,15 +82,12 @@ export class AuthService {
|
||||
}
|
||||
|
||||
private convertOpts(opts: any): UserOptions {
|
||||
let converted = <UserOptions> {};
|
||||
|
||||
converted.id = +opts.id;
|
||||
converted.new_tasks_at_bottom = opts.new_tasks_at_bottom === '1';
|
||||
converted.show_animations = opts.show_animations === '1';
|
||||
converted.show_assignee = opts.show_assignee === '1';
|
||||
converted.multiple_tasks_per_row = opts.multiple_tasks_per_row === '1';
|
||||
converted.language = opts.language;
|
||||
|
||||
let converted = new UserOptions(+opts.id,
|
||||
opts.new_tasks_at_bottom === '1',
|
||||
opts.show_animations === '1',
|
||||
opts.show_assignee === '1',
|
||||
opts.multiple_tasks_per_row === '1',
|
||||
opts.language);
|
||||
return converted;
|
||||
}
|
||||
}
|
||||
|
11
src/app/shared/models/attachment.model.ts
Normal file
11
src/app/shared/models/attachment.model.ts
Normal file
@ -0,0 +1,11 @@
|
||||
export class Attachment {
|
||||
constructor(public id: number = 0,
|
||||
public filename: string = '',
|
||||
public name: string = '',
|
||||
public type: string = '',
|
||||
public user_id: number = 0, // tslint:disable-line
|
||||
public timestamp: Date = null,
|
||||
public task_id: number = 0) { // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,67 @@ import { IssueTracker } from './issue-tracker.model';
|
||||
import { User } from './user.model';
|
||||
|
||||
export class Board {
|
||||
public columns: Array<Column>;
|
||||
public categories: Array<Category>;
|
||||
public auto_actions: Array<AutoAction>; // tslint:disable-line
|
||||
public issue_trackers: Array<IssueTracker>; // tslint:disable-line
|
||||
public users: Array<User>;
|
||||
|
||||
constructor(public id: number = 0,
|
||||
public name: string = '',
|
||||
public is_active: boolean = true, // tslint:disable-line
|
||||
public columns: Array<Column> = [],
|
||||
public categories: Array<Category> = [],
|
||||
public auto_actions: Array<AutoAction> = [], // tslint:disable-line
|
||||
public issue_trackers: Array<IssueTracker> = [], // tslint:disable-line
|
||||
public users: Array<User> = []) {
|
||||
columnArray: Array<any> = [],
|
||||
categoryArray: Array<any> = [],
|
||||
actionsArray: Array<any> = [],
|
||||
trackerArray: Array<any> = [],
|
||||
userArray: Array<any> = []) {
|
||||
this.columns = [];
|
||||
this.categories = [];
|
||||
this.auto_actions = [];
|
||||
this.issue_trackers = [];
|
||||
this.users = [];
|
||||
|
||||
columnArray.forEach((column: any) => {
|
||||
this.columns.push(new Column(+column.id,
|
||||
column.name,
|
||||
+column.position,
|
||||
+column.board_id,
|
||||
column.ownTask));
|
||||
});
|
||||
|
||||
categoryArray.forEach((category: any) => {
|
||||
this.categories.push(new Category(+category.id,
|
||||
category.name,
|
||||
category.default_task_color,
|
||||
+category.board_id));
|
||||
});
|
||||
|
||||
actionsArray.forEach((action: any) => {
|
||||
this.auto_actions.push(new AutoAction(+action.id,
|
||||
+action.trigger,
|
||||
+action.source_id,
|
||||
+action.type,
|
||||
action.change_to,
|
||||
+action.board_id));
|
||||
});
|
||||
|
||||
trackerArray.forEach((tracker: any) => {
|
||||
this.issue_trackers.push(new IssueTracker(+tracker.id,
|
||||
tracker.url,
|
||||
tracker.regex));
|
||||
});
|
||||
|
||||
userArray.forEach((user: any) => {
|
||||
this.users.push(new User(+user.default_board_id,
|
||||
user.email,
|
||||
+user.id,
|
||||
user.last_login,
|
||||
+user.security_level,
|
||||
+user.user_option_id,
|
||||
user.username,
|
||||
user.board_access,
|
||||
user.collapsed));
|
||||
});
|
||||
}
|
||||
|
||||
addColumn(name: string): void {
|
||||
|
@ -1,11 +1,29 @@
|
||||
import { Task } from './task.model';
|
||||
|
||||
export class Column {
|
||||
public tasks: Array<Task>;
|
||||
|
||||
constructor(public id: number = 0,
|
||||
public name: string = '',
|
||||
public position: number = 0,
|
||||
public board_id: number = 0, // tslint:disable-line
|
||||
public tasks: Array<Task> = []) {
|
||||
ownTask: Array<any> = []) {
|
||||
this.tasks = [];
|
||||
|
||||
ownTask.forEach((task: any) => {
|
||||
this.tasks.push(new Task(+task.id,
|
||||
task.title,
|
||||
task.description,
|
||||
task.color,
|
||||
task.due_date,
|
||||
+task.points,
|
||||
+task.position,
|
||||
+task.column_id,
|
||||
task.comments,
|
||||
task.attachments,
|
||||
task.assignees,
|
||||
task.categories));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
8
src/app/shared/models/comment.model.ts
Normal file
8
src/app/shared/models/comment.model.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export class Comment {
|
||||
constructor(public id: number = 0,
|
||||
public text: string = '',
|
||||
public user_id: number = 0, // tslint:disable-line
|
||||
public task_id: number = 0) { // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
export * from './api-response.model';
|
||||
export * from './attachment.model';
|
||||
export * from './auto-actions.model';
|
||||
export * from './board.model';
|
||||
export * from './category.model';
|
||||
export * from './column.model';
|
||||
export * from './comment.model';
|
||||
export * from './issue-tracker.model';
|
||||
export * from './notification.model';
|
||||
export * from './task.model';
|
||||
export * from './user-options.model';
|
||||
export * from './user.model';
|
||||
export * from './task.model';
|
||||
|
||||
|
@ -1,7 +1,14 @@
|
||||
import { Attachment } from './attachment.model';
|
||||
import { Category } from './category.model';
|
||||
import { Comment } from './comment.model';
|
||||
import { User } from './user.model';
|
||||
|
||||
export class Task {
|
||||
public comments: Array<Comment>;
|
||||
public attachments: Array<Attachment>;
|
||||
public assignees: Array<User>;
|
||||
public categories: Array<Category>;
|
||||
|
||||
constructor(public id: number = 0,
|
||||
public title: string = '',
|
||||
public description: string = '',
|
||||
@ -10,10 +17,50 @@ export class Task {
|
||||
public points: number = 0,
|
||||
public position: number = 0,
|
||||
public column_id: number = 0, // tslint:disable-line
|
||||
public comments: Array<any> = [], // TODO: Use model
|
||||
public attachments: Array<any> = [], // TODO: Use model
|
||||
public assignees: Array<User> = [],
|
||||
public categories: Array<Category> = []) {
|
||||
commentArray: Array<any> = [],
|
||||
attachmentArray: Array<any> = [],
|
||||
assigneeArray: Array<any> = [],
|
||||
categoryArray: Array<any> = []) {
|
||||
this.comments = [];
|
||||
this.attachments = [];
|
||||
this.assignees = [];
|
||||
this.categories = [];
|
||||
|
||||
commentArray.forEach((comment: any) => {
|
||||
this.comments.push(new Comment(+comment.id,
|
||||
comment.text,
|
||||
+comment.user_id,
|
||||
+comment.task_id));
|
||||
});
|
||||
|
||||
attachmentArray.forEach((attachment: any) => {
|
||||
this.attachments.push(new Attachment(+attachment.id,
|
||||
attachment.filename,
|
||||
attachment.name,
|
||||
attachment.type,
|
||||
+attachment.user_id,
|
||||
attachment.timestamp,
|
||||
+attachment.task_id));
|
||||
});
|
||||
|
||||
assigneeArray.forEach((user: any) => {
|
||||
this.assignees.push(new User(+user.default_board_id,
|
||||
user.email,
|
||||
+user.id,
|
||||
user.last_login,
|
||||
+user.security_level,
|
||||
+user.user_option_id,
|
||||
user.username,
|
||||
user.board_access,
|
||||
user.collapsed));
|
||||
});
|
||||
|
||||
categoryArray.forEach((category: any) => {
|
||||
this.categories.push(new Category(+category.id,
|
||||
category.name,
|
||||
category.default_task_color,
|
||||
+category.board_id));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
export interface UserOptions {
|
||||
id: number;
|
||||
new_tasks_at_bottom: boolean;
|
||||
show_animations: boolean;
|
||||
show_assignee: boolean;
|
||||
multiple_tasks_per_row: boolean;
|
||||
language: string;
|
||||
export class UserOptions {
|
||||
constructor(public id: number = 0,
|
||||
public new_tasks_at_bottom: boolean = true, // tslint:disable-line
|
||||
public show_animations: boolean = true, // tslint:disable-line
|
||||
public show_assignee: boolean = true, // tslint:disable-line
|
||||
public multiple_tasks_per_row: boolean = false, // tslint:disable-line
|
||||
public language: string = 'en') {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,32 @@ describe('ApiResponse', () => {
|
||||
var apiResponse;
|
||||
|
||||
beforeEach(() => {
|
||||
apiResponse = new ApiResponse([{ type: 'error', text: 'test' }],
|
||||
[{ data: 'whatever' }],
|
||||
'success');
|
||||
});
|
||||
|
||||
it('has sane defaults', () => {
|
||||
apiResponse = new ApiResponse();
|
||||
|
||||
expect(apiResponse.alerts.length).to.equal(0);
|
||||
expect(apiResponse.data.length).to.equal(0);
|
||||
expect(apiResponse.status).to.equal('');
|
||||
});
|
||||
|
||||
it('has an alerts array', () => {
|
||||
expect(apiResponse.alerts).to.be.an('array');
|
||||
expect(apiResponse.alerts.length).to.equal(0);
|
||||
expect(apiResponse.alerts.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a data array', () => {
|
||||
expect(apiResponse.data).to.be.an('array');
|
||||
expect(apiResponse.data.length).to.equal(0);
|
||||
expect(apiResponse.data.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a status string', () => {
|
||||
expect(apiResponse.status).to.be.a('string');
|
||||
expect(apiResponse.status).to.equal('');
|
||||
expect(apiResponse.status).to.equal('success');
|
||||
});
|
||||
});
|
||||
|
||||
|
50
test/app/shared/models/attachment.model.spec.js
Normal file
50
test/app/shared/models/attachment.model.spec.js
Normal file
@ -0,0 +1,50 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Attachment = require(path + 'attachment.model.js').Attachment;
|
||||
|
||||
describe('Attachment', () => {
|
||||
var attachment,
|
||||
now = new Date();
|
||||
|
||||
beforeEach(() => {
|
||||
attachment = new Attachment();
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(attachment.id).to.be.a('number');
|
||||
expect(attachment.id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a filename', () => {
|
||||
expect(attachment.filename).to.be.a('string');
|
||||
expect(attachment.filename).to.equal('');
|
||||
});
|
||||
|
||||
it('has a name', () => {
|
||||
expect(attachment.name).to.be.a('string');
|
||||
expect(attachment.name).to.equal('');
|
||||
});
|
||||
|
||||
it('has a type', () => {
|
||||
expect(attachment.type).to.be.a('string');
|
||||
expect(attachment.type).to.equal('');
|
||||
});
|
||||
|
||||
it('has a user_id', () => {
|
||||
expect(attachment.user_id).to.be.a('number');
|
||||
expect(attachment.user_id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a timestamp', () => {
|
||||
attachment = new Attachment(0, '', '', '', 0, now, 0);
|
||||
|
||||
expect(attachment.timestamp).to.be.a('date');
|
||||
expect(attachment.timestamp).to.equal(now);
|
||||
});
|
||||
|
||||
it('has a task_id', () => {
|
||||
expect(attachment.task_id).to.be.a('number');
|
||||
expect(attachment.task_id).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
39
test/app/shared/models/auto-actions.model.spec.js
Normal file
39
test/app/shared/models/auto-actions.model.spec.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
AutoAction = require(path + 'auto-actions.model.js').AutoAction;
|
||||
|
||||
describe('AutoAction', () => {
|
||||
var autoAction;
|
||||
|
||||
beforeEach(() => {
|
||||
autoAction = new AutoAction();
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(autoAction.id).to.be.a('number');
|
||||
expect(autoAction.id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a trigger', () => {
|
||||
expect(autoAction.trigger).to.be.a('number');
|
||||
expect(autoAction.trigger).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a source_id', () => {
|
||||
expect(autoAction.source_id).to.equal(null);
|
||||
});
|
||||
|
||||
it('has a type', () => {
|
||||
expect(autoAction.type).to.be.a('number');
|
||||
expect(autoAction.type).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a change_to', () => {
|
||||
expect(autoAction.change_to).to.equal(null);
|
||||
});
|
||||
|
||||
it('has a board_id', () => {
|
||||
expect(autoAction.board_id).to.equal(null);
|
||||
});
|
||||
});
|
||||
|
@ -6,17 +6,46 @@ describe('Board', () => {
|
||||
var board;
|
||||
|
||||
beforeEach(() => {
|
||||
var cols = [
|
||||
{ id: 1, name: 'col1', position: 0, board_id: 1,
|
||||
ownTask: [{ id: 1 }] }
|
||||
],
|
||||
cats = [
|
||||
{ id: 1, name: 'cat1', default_task_color: '#ffffe0', board_id: 1 }
|
||||
],
|
||||
acts = [
|
||||
{ id: 1, trigger: 1, source_id: 1, type: 1, change_to: '', board_id: 1 }
|
||||
],
|
||||
tracks = [
|
||||
{ id: 1, url: '', regex: '' }
|
||||
],
|
||||
users = [
|
||||
{
|
||||
default_board_id: 0, email: '', id: 1, last_login: null,
|
||||
security_level: 1, user_option_id: 1, username: 'tester',
|
||||
board_access: [ 1 ], collapsed: []
|
||||
}
|
||||
];
|
||||
|
||||
board = new Board(1, 'test', true, cols, cats, acts, tracks, users);
|
||||
});
|
||||
|
||||
it('has sane defaults', () => {
|
||||
board = new Board();
|
||||
|
||||
expect(board.id).to.equal(0);
|
||||
expect(board.name).to.equal('');
|
||||
expect(board.is_active).to.equal(true);
|
||||
});
|
||||
|
||||
it('has id', () => {
|
||||
expect(board.id).to.be.a('number');
|
||||
expect(board.id).to.equal(0);
|
||||
expect(board.id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has name', () => {
|
||||
expect(board.name).to.be.a('string');
|
||||
expect(board.name).to.equal('');
|
||||
expect(board.name).to.equal('test');
|
||||
});
|
||||
|
||||
it('has is_active', () => {
|
||||
@ -26,50 +55,50 @@ describe('Board', () => {
|
||||
|
||||
it('has columns', () => {
|
||||
expect(board.columns).to.be.an('array');
|
||||
expect(board.columns.length).to.equal(0);
|
||||
expect(board.columns.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has categories', () => {
|
||||
expect(board.categories).to.be.an('array');
|
||||
expect(board.categories.length).to.equal(0);
|
||||
expect(board.categories.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has auto_actions', () => {
|
||||
expect(board.auto_actions).to.be.an('array');
|
||||
expect(board.auto_actions.length).to.equal(0);
|
||||
expect(board.auto_actions.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has issue_trackers', () => {
|
||||
expect(board.issue_trackers).to.be.an('array');
|
||||
expect(board.issue_trackers.length).to.equal(0);
|
||||
expect(board.issue_trackers.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has users', () => {
|
||||
expect(board.users).to.be.an('array');
|
||||
expect(board.users.length).to.equal(0);
|
||||
expect(board.users.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a method to add a column', () => {
|
||||
expect(board.addColumn).to.be.a('function');
|
||||
|
||||
board.addColumn('test');
|
||||
expect(board.columns[0].name).to.equal('test');
|
||||
expect(board.columns[1].name).to.equal('test');
|
||||
});
|
||||
|
||||
it('has a method to add a category', () => {
|
||||
expect(board.addCategory).to.be.a('function');
|
||||
|
||||
board.addCategory('test', 'color');
|
||||
expect(board.categories[0].name).to.equal('test');
|
||||
expect(board.categories[0].default_task_color).to.equal('color');
|
||||
expect(board.categories[1].name).to.equal('test');
|
||||
expect(board.categories[1].default_task_color).to.equal('color');
|
||||
});
|
||||
|
||||
it('has a method to add an issue tracker', () => {
|
||||
expect(board.addIssueTracker).to.be.a('function');
|
||||
|
||||
board.addIssueTracker('testUrl', 'testRegex');
|
||||
expect(board.issue_trackers[0].url).to.equal('testUrl');
|
||||
expect(board.issue_trackers[0].regex).to.equal('testRegex');
|
||||
expect(board.issue_trackers[1].url).to.equal('testUrl');
|
||||
expect(board.issue_trackers[1].regex).to.equal('testRegex');
|
||||
});
|
||||
});
|
||||
|
||||
|
32
test/app/shared/models/category.model.spec.js
Normal file
32
test/app/shared/models/category.model.spec.js
Normal file
@ -0,0 +1,32 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Category = require(path + 'category.model.js').Category;
|
||||
|
||||
describe('Category', () => {
|
||||
var category;
|
||||
|
||||
beforeEach(() => {
|
||||
category = new Category();
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(category.id).to.be.a('number');
|
||||
expect(category.id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a name', () => {
|
||||
expect(category.name).to.be.a('string');
|
||||
expect(category.name).to.equal('');
|
||||
});
|
||||
|
||||
it('has a default_task_color', () => {
|
||||
expect(category.default_task_color).to.be.a('string');
|
||||
expect(category.default_task_color).to.equal('');
|
||||
});
|
||||
|
||||
it('has a board_id', () => {
|
||||
expect(category.board_id).to.be.a('number');
|
||||
expect(category.board_id).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
37
test/app/shared/models/column.model.spec.js
Normal file
37
test/app/shared/models/column.model.spec.js
Normal file
@ -0,0 +1,37 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Column = require(path + 'column.model.js').Column;
|
||||
|
||||
describe('ApiResponse', () => {
|
||||
var column;
|
||||
|
||||
beforeEach(() => {
|
||||
column = new Column();
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(column.id).to.be.a('number');
|
||||
expect(column.id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a name', () => {
|
||||
expect(column.name).to.be.a('string');
|
||||
expect(column.name).to.equal('');
|
||||
});
|
||||
|
||||
it('has a position', () => {
|
||||
expect(column.position).to.be.a('number');
|
||||
expect(column.position).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a board_id', () => {
|
||||
expect(column.board_id).to.be.a('number');
|
||||
expect(column.board_id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has tasks', () => {
|
||||
expect(column.tasks).to.be.an('array');
|
||||
expect(column.tasks.length).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
41
test/app/shared/models/comment.model.spec.js
Normal file
41
test/app/shared/models/comment.model.spec.js
Normal file
@ -0,0 +1,41 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Comment = require(path + 'comment.model.js').Comment;
|
||||
|
||||
describe('Comment', () => {
|
||||
var comment;
|
||||
|
||||
beforeEach(() => {
|
||||
comment = new Comment(1, 'text', 1, 1);
|
||||
});
|
||||
|
||||
it('has sane defauls', () => {
|
||||
comment =new Comment();
|
||||
|
||||
expect(comment.id).to.equal(0);
|
||||
expect(comment.text).to.equal('');
|
||||
expect(comment.user_id).to.equal(0);
|
||||
expect(comment.task_id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(comment.id).to.be.a('number');
|
||||
expect(comment.id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a text', () => {
|
||||
expect(comment.text).to.be.a('string');
|
||||
expect(comment.text).to.equal('text');
|
||||
});
|
||||
|
||||
it('has a user_id', () => {
|
||||
expect(comment.user_id).to.be.a('number');
|
||||
expect(comment.user_id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a task_id', () => {
|
||||
expect(comment.task_id).to.be.a('number');
|
||||
expect(comment.task_id).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
35
test/app/shared/models/issue-tracker.model.spec.js
Normal file
35
test/app/shared/models/issue-tracker.model.spec.js
Normal file
@ -0,0 +1,35 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
IssueTracker = require(path + 'issue-tracker.model.js').IssueTracker;
|
||||
|
||||
describe('IssueTracker', () => {
|
||||
var issueTracker;
|
||||
|
||||
beforeEach(() => {
|
||||
issueTracker = new IssueTracker(1, 'url', 'regex');
|
||||
});
|
||||
|
||||
it('has sane defaults', () => {
|
||||
issueTracker = new IssueTracker();
|
||||
|
||||
expect(issueTracker.id).to.equal(0);
|
||||
expect(issueTracker.url).to.equal('');
|
||||
expect(issueTracker.regex).to.equal('');
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(issueTracker.id).to.be.a('number');
|
||||
expect(issueTracker.id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a url', () => {
|
||||
expect(issueTracker.url).to.be.a('string');
|
||||
expect(issueTracker.url).to.equal('url');
|
||||
});
|
||||
|
||||
it('has a regex', () => {
|
||||
expect(issueTracker.regex).to.be.a('string');
|
||||
expect(issueTracker.regex).to.equal('regex');
|
||||
});
|
||||
});
|
||||
|
101
test/app/shared/models/task.model.spec.js
Normal file
101
test/app/shared/models/task.model.spec.js
Normal file
@ -0,0 +1,101 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Task = require(path + 'task.model.js').Task;
|
||||
|
||||
describe('Task', () => {
|
||||
var task;
|
||||
|
||||
beforeEach(() => {
|
||||
task = new Task(1, 'title', 'desc', 'color', 'today', 3, 1, 1,
|
||||
[{ id: 1, text: '', user_id: 1, task_id: 1 }],
|
||||
[{
|
||||
id: 1, filename: '', name: '', type: '',
|
||||
user_id: 1, timestamp: '', task_id: 1
|
||||
}],
|
||||
[{
|
||||
default_board_id: 0, email: '', id: 1,
|
||||
last_login: null, security_level: 1,
|
||||
user_option_id: 1, username: '',
|
||||
board_access: [], collapsed: []
|
||||
}],
|
||||
[{ id: 1, name: '', default_task_color: '', board_id: 1 }]);
|
||||
});
|
||||
|
||||
it('has sane defaults', () => {
|
||||
task = new Task();
|
||||
|
||||
expect(task.id).to.equal(0);
|
||||
expect(task.title).to.equal('');
|
||||
expect(task.description).to.equal('');
|
||||
expect(task.color).to.equal('#ffffe0');
|
||||
expect(task.due_date).to.equal('');
|
||||
expect(task.points).to.equal(0);
|
||||
expect(task.position).to.equal(0);
|
||||
expect(task.column_id).to.equal(0);
|
||||
expect(task.comments.length).to.equal(0);
|
||||
expect(task.attachments.length).to.equal(0);
|
||||
expect(task.assignees.length).to.equal(0);
|
||||
expect(task.categories.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(task.id).to.be.a('number');
|
||||
expect(task.id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a title', () => {
|
||||
expect(task.title).to.be.a('string');
|
||||
expect(task.title).to.equal('title');
|
||||
});
|
||||
|
||||
it('has a description', () => {
|
||||
expect(task.description).to.be.a('string');
|
||||
expect(task.description).to.equal('desc');
|
||||
});
|
||||
|
||||
it('has a color', () => {
|
||||
expect(task.color).to.be.a('string');
|
||||
expect(task.color).to.equal('color');
|
||||
});
|
||||
|
||||
it('has a due_date', () => {
|
||||
expect(task.due_date).to.be.a('string');
|
||||
expect(task.due_date).to.equal('today');
|
||||
});
|
||||
|
||||
it('has points', () => {
|
||||
expect(task.points).to.be.a('number');
|
||||
expect(task.points).to.equal(3);
|
||||
});
|
||||
|
||||
it('has a position', () => {
|
||||
expect(task.position).to.be.a('number');
|
||||
expect(task.position).to.equal(1);
|
||||
});
|
||||
|
||||
it('has a column_id', () => {
|
||||
expect(task.column_id).to.be.a('number');
|
||||
expect(task.column_id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has comments', () => {
|
||||
expect(task.comments).to.be.an('array');
|
||||
expect(task.comments.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has attachments', () => {
|
||||
expect(task.attachments).to.be.an('array');
|
||||
expect(task.attachments.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has assignees', () => {
|
||||
expect(task.assignees).to.be.an('array');
|
||||
expect(task.assignees.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('has categories', () => {
|
||||
expect(task.categories).to.be.an('array');
|
||||
expect(task.categories.length).to.equal(1);
|
||||
});
|
||||
});
|
||||
|
47
test/app/shared/models/user-options.model.spec.js
Normal file
47
test/app/shared/models/user-options.model.spec.js
Normal file
@ -0,0 +1,47 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
UserOptions = require(path + 'user-options.model.js').UserOptions;
|
||||
|
||||
describe('UserOptions', () => {
|
||||
var userOptions;
|
||||
|
||||
beforeEach(() => {
|
||||
userOptions = new UserOptions(1, false, false, false, true, 'es');
|
||||
});
|
||||
|
||||
it('has sane defaults', () => {
|
||||
userOptions = new UserOptions();
|
||||
|
||||
expect(userOptions.id).to.equal(0);
|
||||
expect(userOptions.new_tasks_at_bottom).to.equal(true);
|
||||
expect(userOptions.show_animations).to.equal(true);
|
||||
expect(userOptions.show_assignee).to.equal(true);
|
||||
expect(userOptions.multiple_tasks_per_row).to.equal(false);
|
||||
expect(userOptions.language).to.equal('en');
|
||||
});
|
||||
|
||||
it('has an id', () => {
|
||||
expect(userOptions.id).to.be.a('number');
|
||||
expect(userOptions.id).to.equal(1);
|
||||
});
|
||||
|
||||
it('has boolean settings', () => {
|
||||
expect(userOptions.new_tasks_at_bottom).to.be.a('boolean');
|
||||
expect(userOptions.new_tasks_at_bottom).to.equal(false);
|
||||
|
||||
expect(userOptions.show_animations).to.be.a('boolean');
|
||||
expect(userOptions.show_animations).to.equal(false);
|
||||
|
||||
expect(userOptions.show_assignee).to.be.a('boolean');
|
||||
expect(userOptions.show_assignee).to.equal(false);
|
||||
|
||||
expect(userOptions.multiple_tasks_per_row).to.be.a('boolean');
|
||||
expect(userOptions.multiple_tasks_per_row).to.equal(true);
|
||||
});
|
||||
|
||||
it('has a language', () => {
|
||||
expect(userOptions.language).to.be.a('string');
|
||||
expect(userOptions.language).to.equal('es');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user