Unit tests

This commit is contained in:
Denys Vuika
2016-06-28 15:56:17 +01:00
parent 6feb6edd02
commit 4bf94b4698
3 changed files with 57 additions and 10 deletions

View File

@@ -0,0 +1,37 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
it,
describe,
expect
} from '@angular/core/testing';
import { ContentColumnModel } from './content-column.model';
describe('ContentColumnModel', () => {
it('should init with text type from config object', () => {
let model = new ContentColumnModel({});
expect(model.type).toBe(ContentColumnModel.TYPE_TEXT);
});
it('should return supported types', () => {
expect(ContentColumnModel.getSupportedTypes().length).toBeGreaterThan(0);
});
});

View File

@@ -16,11 +16,17 @@
*/
export class ContentColumnModel {
static TYPE_TEXT: string = 'text';
static TYPE_DATE: string = 'date';
static TYPE_IMAGE: string = 'image';
// static TYPE_NUMBER: string = 'number';
title: string;
srTitle: string;
source: string;
cssClass: string;
type: string = 'text'; // text|date|image|number
type: string = ContentColumnModel.TYPE_TEXT;
format: string = 'medium';
constructor(obj?: any) {
@@ -29,8 +35,17 @@ export class ContentColumnModel {
this.srTitle = obj.srTitle;
this.source = obj.source;
this.cssClass = obj.cssClass;
this.type = obj.type || 'text';
this.type = obj.type || ContentColumnModel.TYPE_TEXT;
this.format = obj.format;
}
}
static getSupportedTypes(): string[] {
return [
ContentColumnModel.TYPE_TEXT,
ContentColumnModel.TYPE_DATE,
ContentColumnModel.TYPE_IMAGE
// ContentColumnModel.TYPE_NUMBER
];
}
}