Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
driver-deploy-2 committed Jun 10, 2015
1 parent cd9756a commit b45fe3d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
1 change: 1 addition & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"./ServerComponents/dynamic/ClientConnection.d.ts",
"./ServerComponents/dynamic/DataSource.d.ts",
"./ServerComponents/dynamic/DynamicProject.d.ts",
"./ServerComponents/dynamic/LayerDirectory.d.ts",
"./ServerComponents/helpers/Utils.d.ts",
"./ServerComponents/import/BaseTransformer.d.ts",
"./ServerComponents/import/IImport.d.ts",
Expand Down
41 changes: 40 additions & 1 deletion test/csComp/spec/classes/group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('ProjectGroup', function() {
projectgroup = new csComp.Services.ProjectGroup();
});

describe('initial state', () => {
describe('Projectgroup initial state', () => {
it('should have an undefined id and title', function() {
expect(projectgroup.id).toBeUndefined();
expect(projectgroup.title).toBeUndefined();
Expand All @@ -35,3 +35,42 @@ describe('ProjectGroup', function() {
});
});
});


class MockColorTranslation{
then = function(translation) {
translation('color');
}
constructor() {}
};

describe('csComp.Services.GroupStyle', function() {

// load the module
beforeEach(module('csComp'));

var mockTranslate;
beforeEach(() => {
module(function($provide) {
$provide.value('$translate', mockTranslate);
});
mockTranslate = function(key) {
var mct = new MockColorTranslation();
return mct;
};
});

var groupStyle: csComp.Services.GroupStyle;
var translate;
beforeEach(inject(function($translate) {
translate = $translate;
groupStyle = new csComp.Services.GroupStyle(translate);
}));

describe('Groupstyle initial state', () => {
it('should have an undefined id and title', function() {
expect(groupStyle.id).toBeUndefined();
expect(groupStyle.title).toBeUndefined();
});
});
});
55 changes: 54 additions & 1 deletion test/csComp/spec/classes/project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Project', function() {
project = new csComp.Services.Project();
});

describe('initial state', () => {
describe('Initial state', () => {
it('should have an empty markers object', function() {
expect(project.markers).toEqual({});
});
Expand All @@ -35,7 +35,60 @@ describe('Project', function() {
expect(result).toContain('newName');
expect(result).toContain('testTitle');
});

it('should still work after deserialization', function() {
project.title = 'testTitle';
var result = project.serialize();
var dProject = csComp.Services.Project.prototype.deserialize(project);
expect(dProject.timeLine).toBeUndefined();
expect(dProject.id).toEqual(project.title);
});
});
});
});

describe('DateRange', function() {
var dr: csComp.Services.DateRange;
beforeEach(() => {
dr = new csComp.Services.DateRange();
});

it('should construct a new DateRange', () => {
expect(dr).toBeDefined();
});

it('should deserialize properly when no focus time is set', () => {
spyOn(Date, 'now').and.returnValue(new Date(100).getTime());
var result = csComp.Services.DateRange.deserialize(dr);
expect(result).toBeDefined();
expect(result.focus).toEqual(new Date(100).getTime());
expect(result.focus).not.toEqual(new Date(101).getTime());
});

it('should deserialize properly when a focus time is set', () => {
dr.focus = new Date(100).getTime();
var result = csComp.Services.DateRange.deserialize(dr);
expect(result).toBeDefined();
expect(result.focus).toEqual(new Date(100).getTime());
});

it('should set a focus time properly', () => {
expect(dr.zoomLevel).toBeUndefined();
var d = new Date(100);
var s = new Date(50);
var e = new Date(200);
dr.setFocus(d, s, e);
expect(dr.zoomLevel).toBeDefined();
});

it('should set a start and end time properly', () => {
dr.range = 1000;
var d = new Date(25);
var s = new Date(50);
var e = new Date(10);
dr.setFocus(d, s, e);
expect(dr.startDate()).toBeDefined();
expect(dr.focusDate()).toBeDefined();
expect(dr.endDate()).toBeDefined();
});
});

0 comments on commit b45fe3d

Please sign in to comment.