-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accordion): implementa definições do AnimaliaDS
Implementa definições do AnimaliaDS no Accordion fixes DTHFUI-7691
- Loading branch information
Showing
19 changed files
with
704 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
projects/ui/src/lib/components/po-accordion/interfaces/po-accordion-literals.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @usedBy PoAccordionComponent | ||
* | ||
* @description | ||
* | ||
* Interface para definição das literais usadas no `po-accordion`. | ||
*/ | ||
export interface PoAccordionLiterals { | ||
/** Label do gerenciador de Accordion para expandir todos os itens. */ | ||
expandAllItems?: string; | ||
|
||
/** Label do gerenciador de Accordion para colapsar todos os itens */ | ||
closeAllItems?: string; | ||
} |
97 changes: 95 additions & 2 deletions
97
projects/ui/src/lib/components/po-accordion/po-accordion-base.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,102 @@ | ||
import { PoAccordionBaseComponent } from './po-accordion-base.component'; | ||
import { poLocaleDefault } from '../../services'; | ||
import { PoLanguageService } from '../../services/po-language/po-language.service'; | ||
import { expectPropertiesValues } from '../../util-test/util-expect.spec'; | ||
import { convertToBoolean } from '../../utils/util'; | ||
import { PoAccordionBaseComponent, poAccordionLiteralsDefault } from './po-accordion-base.component'; | ||
|
||
describe('PoAccordionBaseComponent:', () => { | ||
const component = new PoAccordionBaseComponent(); | ||
const languageService: PoLanguageService = new PoLanguageService(); | ||
let component: PoAccordionBaseComponent; | ||
|
||
beforeEach(() => { | ||
component = new PoAccordionBaseComponent(languageService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component instanceof PoAccordionBaseComponent).toBeTruthy(); | ||
}); | ||
|
||
it('p-literals: should be in portuguese if browser is setted with an unsupported language', () => { | ||
component['language'] = 'zw'; | ||
|
||
component.literals = {}; | ||
|
||
expect(component.literals).toEqual(poAccordionLiteralsDefault[poLocaleDefault]); | ||
}); | ||
|
||
it('p-literals: should be in portuguese if browser is setted with `pt`', () => { | ||
component['language'] = 'pt'; | ||
|
||
component.literals = {}; | ||
|
||
expect(component.literals).toEqual(poAccordionLiteralsDefault.pt); | ||
}); | ||
|
||
it('p-literals: should be in english if browser is setted with `en`', () => { | ||
component['language'] = 'en'; | ||
|
||
component.literals = {}; | ||
|
||
expect(component.literals).toEqual(poAccordionLiteralsDefault.en); | ||
}); | ||
|
||
it('p-literals: should be in spanish if browser is setted with `es`', () => { | ||
component['language'] = 'es'; | ||
|
||
component.literals = {}; | ||
|
||
expect(component.literals).toEqual(poAccordionLiteralsDefault.es); | ||
}); | ||
|
||
it('p-literals: should be in russian if browser is setted with `ru`', () => { | ||
component['language'] = 'ru'; | ||
|
||
component['_literals'] = undefined; | ||
|
||
expect(component.literals).toEqual(poAccordionLiteralsDefault.ru); | ||
}); | ||
|
||
it('p-literals: should accept custom literals', () => { | ||
component['language'] = poLocaleDefault; | ||
|
||
const customLiterals = Object.assign({}, poAccordionLiteralsDefault[poLocaleDefault]); | ||
|
||
customLiterals.closeAllItems = 'Close'; | ||
|
||
component.literals = customLiterals; | ||
|
||
expect(component.literals).toEqual(customLiterals); | ||
}); | ||
|
||
it('p-literals: should update property with default literals if is setted with invalid values', () => { | ||
const invalidValues = [null, undefined, false, true, '', 'literals', 0, 10, [], [1, 2], () => {}]; | ||
|
||
component['language'] = poLocaleDefault; | ||
|
||
expectPropertiesValues(component, 'literals', invalidValues, poAccordionLiteralsDefault[poLocaleDefault]); | ||
}); | ||
|
||
it('showManagerAccordion: should set property `p-show-manager-accordion` to `false` if invalid value', () => { | ||
component.showManagerAccordion = convertToBoolean(3); | ||
|
||
expect(component.showManagerAccordion).toBe(false); | ||
}); | ||
|
||
it('hideRemoveAllDisclaimer: should update property `p-show-manager-accordion` to `true` with valid values', () => { | ||
component.showManagerAccordion = convertToBoolean(1); | ||
|
||
expect(component.showManagerAccordion).toBe(true); | ||
}); | ||
|
||
it('allowExpandItems: should set property `p-allow-expand-all-items` to `false` if invalid value', () => { | ||
component.allowExpandItems = convertToBoolean(3); | ||
|
||
expect(component.allowExpandItems).toBe(false); | ||
}); | ||
|
||
it('hideRemoveAllDisclaimer: should update property `p-allow-expand-all-items` to `true` with valid values', () => { | ||
component.allowExpandItems = convertToBoolean(1); | ||
|
||
expect(component.allowExpandItems).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
.../components/po-accordion/po-accordion-item-header/po-accordion-item-header.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
<header class="po-accordion-item-header"> | ||
<button class="po-accordion-item-header-button po-clickable" (click)="onClick()"> | ||
<div class="po-text-ellipsis po-accordion-item-header-title">{{ label }}</div> | ||
<span #icon class="po-icon po-accordion-item-header-icon po-icon-arrow-down"> </span> | ||
<div class="po-accordion-item-header"> | ||
<button | ||
[disabled]="disabledItem" | ||
[attr.aria-label]="label" | ||
[attr.aria-expanded]="expanded || false" | ||
class="po-accordion-item-header-button po-clickable" | ||
(click)="onClick()" | ||
> | ||
<div class="po-accordion-item-header-button-content"> | ||
<div class="po-text-ellipsis po-accordion-item-header-title">{{ label }}</div> | ||
<po-tag *ngIf="labelTag" class="po-accordion-item-header-tag" [p-value]="labelTag" [p-type]="typeTag"> </po-tag> | ||
</div> | ||
<po-icon p-icon="po-icon-arrow-down" class="po-icon po-accordion-item-header-icon"></po-icon> | ||
</button> | ||
</header> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
...ib/components/po-accordion/po-accordion-item-header/po-accordion-item-header.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.