mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
ACS-8224 Make Multi Value Pipe internal (#11530)
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { MultiValuePipe } from './multi-value.pipe';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
describe('MultiValuePipe', () => {
|
||||
let pipe: MultiValuePipe;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MultiValuePipe],
|
||||
providers: [MultiValuePipe]
|
||||
});
|
||||
pipe = TestBed.inject(MultiValuePipe);
|
||||
});
|
||||
|
||||
it('should add the separator when a string list is provided', () => {
|
||||
const values = ['cat', 'house', 'dog'];
|
||||
expect(pipe.transform(values)).toBe('cat, house, dog');
|
||||
});
|
||||
|
||||
it('should add the separator when a number list is provided', () => {
|
||||
const values = [1, 2, 3];
|
||||
expect(pipe.transform(values)).toBe('1, 2, 3');
|
||||
});
|
||||
|
||||
it('should add custom separator when set', () => {
|
||||
const values = ['cat', 'house', 'dog'];
|
||||
const customSeparator = ' - ';
|
||||
expect(pipe.transform(values, customSeparator)).toBe('cat - house - dog');
|
||||
});
|
||||
|
||||
it('should not add separator when the list has only one item', () => {
|
||||
const values = ['cat'];
|
||||
expect(pipe.transform(values)).toBe('cat');
|
||||
});
|
||||
|
||||
it('should return empty string when an empty list is passed', () => {
|
||||
const values = [];
|
||||
expect(pipe.transform(values)).toBe('');
|
||||
});
|
||||
|
||||
it('should return empty string when an empty string is passed', () => {
|
||||
const values = '';
|
||||
expect(pipe.transform(values)).toBe('');
|
||||
});
|
||||
|
||||
it('should return same string when the value passed is a string', () => {
|
||||
const values = 'cat';
|
||||
expect(pipe.transform(values)).toBe('cat');
|
||||
});
|
||||
});
|
||||
@@ -1,33 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* 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 { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'multiValue'
|
||||
})
|
||||
export class MultiValuePipe implements PipeTransform {
|
||||
static DEFAULT_SEPARATOR = ', ';
|
||||
|
||||
transform(values: any | any[], valueSeparator: string = MultiValuePipe.DEFAULT_SEPARATOR): string {
|
||||
if (values && values instanceof Array) {
|
||||
return values.join(valueSeparator);
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import { InitialUsernamePipe } from './user-initial.pipe';
|
||||
import { FullNamePipe } from './full-name.pipe';
|
||||
import { FormatSpacePipe } from './format-space.pipe';
|
||||
import { FileTypePipe } from './file-type.pipe';
|
||||
import { MultiValuePipe } from './multi-value.pipe';
|
||||
import { LocalizedDatePipe } from './localized-date.pipe';
|
||||
import { DecimalNumberPipe } from './decimal-number.pipe';
|
||||
import { DateTimePipe } from './date-time.pipe';
|
||||
@@ -38,7 +37,6 @@ export const CORE_PIPES = [
|
||||
FullNamePipe,
|
||||
FormatSpacePipe,
|
||||
FileTypePipe,
|
||||
MultiValuePipe,
|
||||
DecimalNumberPipe,
|
||||
DateTimePipe,
|
||||
InitialUsernamePipe,
|
||||
|
||||
@@ -21,7 +21,6 @@ export * from './file-type.pipe';
|
||||
export * from './format-space.pipe';
|
||||
export * from './full-name.pipe';
|
||||
export * from './localized-date.pipe';
|
||||
export * from './multi-value.pipe';
|
||||
export * from './text-highlight.pipe';
|
||||
export * from './time-ago.pipe';
|
||||
export * from './user-initial.pipe';
|
||||
|
||||
Reference in New Issue
Block a user