enable prefer-const rule for tslint, fix issues (#4409)

* enable prefer-const rule for tslint, fix issues

* Update content-node-selector.component.spec.ts

* Update content-node-selector.component.spec.ts

* fix const

* fix lint issues

* update tests

* update tests

* update tests

* fix code

* fix page class
This commit is contained in:
Denys Vuika
2019-03-25 12:19:33 +00:00
committed by Eugenio Romano
parent 26c5982a1a
commit a7a48e8b2b
581 changed files with 5435 additions and 5402 deletions

View File

@@ -26,40 +26,40 @@ describe('FormatSpacePipe', () => {
});
it('should replace the white space with an underscore by default', () => {
let result = pipe.transform('FAKE TEST');
const result = pipe.transform('FAKE TEST');
expect(result).toBe('fake_test');
});
it('should replace all the white spaces with an underscore by default', () => {
let result = pipe.transform('FAKE TEST CHECK ');
const result = pipe.transform('FAKE TEST CHECK ');
expect(result).toBe('fake_test_check');
});
it('should trim the space at the end of the string and replace the ones in the middle', () => {
let result = pipe.transform(' FAKE TEST CHECK ');
const result = pipe.transform(' FAKE TEST CHECK ');
expect(result).toBe('fake_test_check');
});
it('should return a lower case string by default', () => {
const testString = 'FAKE_TEST_LOWERCASE';
let result = pipe.transform(testString);
const result = pipe.transform(testString);
expect(result).toBe(testString.toLocaleLowerCase());
});
it('should replace the empty space with the character given', () => {
const testString = 'FAKE TEST LOWERCASE';
let result = pipe.transform(testString, '+');
const result = pipe.transform(testString, '+');
expect(result).toBe('fake+test+lowercase');
});
it('should leave the string uppercase if explicitly set', () => {
const testString = 'FAKE TEST LOWERCASE';
let result = pipe.transform(testString, '-', false);
const result = pipe.transform(testString, '-', false);
expect(result).toBe('FAKE-TEST-LOWERCASE');
});
it('should return an empty string when input is null', () => {
let result = pipe.transform(null);
const result = pipe.transform(null);
expect(result).toBe('');
});
});

View File

@@ -48,7 +48,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(`${nodeTitle}\n${nodeDescription}`);
});
@@ -58,7 +58,7 @@ describe('NodeNameTooltipPipe', () => {
name: nodeName
}
};
let tooltip = pipe.transform(<NodeEntry> node);
const tooltip = pipe.transform(<NodeEntry> node);
expect(tooltip).toBe(nodeName);
});
@@ -69,7 +69,7 @@ describe('NodeNameTooltipPipe', () => {
properties: {}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(nodeName);
});
@@ -83,7 +83,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(`${nodeName}\n${nodeDescription}`);
});
@@ -97,7 +97,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(`${nodeName}\n${nodeTitle}`);
});
@@ -111,7 +111,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(nodeName);
});
@@ -125,7 +125,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(nodeName);
});
@@ -139,7 +139,7 @@ describe('NodeNameTooltipPipe', () => {
}
}
};
let tooltip = pipe.transform(node);
const tooltip = pipe.transform(node);
expect(tooltip).toBe(nodeName);
});
});

View File

@@ -27,12 +27,12 @@ describe('TimeAgoPipe', () => {
}));
it('should return time difference for a given date', () => {
let date = new Date();
const date = new Date();
expect(pipe.transform(date)).toBe('a few seconds ago');
});
it('should return exact date if given date is more than seven days ', () => {
let date = new Date('1990-11-03T15:25:42.749');
const date = new Date('1990-11-03T15:25:42.749');
expect(pipe.transform(date)).toBe('03/11/1990 15:25');
});
@@ -44,7 +44,7 @@ describe('TimeAgoPipe', () => {
describe('When a locale is given', () => {
it('should return a localised message', async(() => {
let date = new Date();
const date = new Date();
const transformedDate = pipe.transform(date, 'de');
/* cspell:disable-next-line */
expect(transformedDate).toBe('vor ein paar Sekunden');

View File

@@ -63,33 +63,33 @@ describe('UserInitialPipe', () => {
it('should return a div with the user initials', () => {
fakeUser.firstName = 'FAKE-NAME';
fakeUser.lastName = 'FAKE-SURNAME';
let result = pipe.transform(fakeUser);
const result = pipe.transform(fakeUser);
expect(result).toBe('<div id="user-initials-image" class="">FF</div>');
});
it('should apply the style class passed in input', () => {
fakeUser.firstName = 'FAKE-NAME';
fakeUser.lastName = 'FAKE-SURNAME';
let result = pipe.transform(fakeUser, 'fake-class-to-check');
const result = pipe.transform(fakeUser, 'fake-class-to-check');
expect(result).toBe('<div id="user-initials-image" class="fake-class-to-check">FF</div>');
});
it('should return a single letter into div when lastName is undefined', () => {
fakeUser.firstName = 'FAKE-NAME';
fakeUser.lastName = undefined;
let result = pipe.transform(fakeUser);
const result = pipe.transform(fakeUser);
expect(result).toBe('<div id="user-initials-image" class="">F</div>');
});
it('should return a single letter into div when firstname is null', () => {
fakeUser.firstName = undefined;
fakeUser.lastName = 'FAKE-SURNAME';
let result = pipe.transform(fakeUser);
const result = pipe.transform(fakeUser);
expect(result).toBe('<div id="user-initials-image" class="">F</div>');
});
it('should return an empty string when user is null', () => {
let result = pipe.transform(null);
const result = pipe.transform(null);
expect(result).toBe('');
});
});

View File

@@ -31,7 +31,7 @@ export class InitialUsernamePipe implements PipeTransform {
transform(user: UserProcessModel | EcmUserModel, className: string = '', delimiter: string = ''): SafeHtml {
let safeHtml: SafeHtml = '';
if (user) {
let initialResult = this.getInitialUserName(user.firstName, user.lastName, delimiter);
const initialResult = this.getInitialUserName(user.firstName, user.lastName, delimiter);
safeHtml = this.sanitized.bypassSecurityTrustHtml(`<div id="user-initials-image" class="${className}">${initialResult}</div>`);
}
return safeHtml;