mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-2375] Contextmenu - RTL support (#1099)
* direction element wrapper * use CONTEXT_MENU_DIRECTION injection * direction injection token * refactor positionStrategy * set CONTEXT_MENU_DIRECTION value * test
This commit is contained in:
committed by
Denys Vuika
parent
7e4b635154
commit
996975fdb5
@@ -31,36 +31,85 @@ import { of } from 'rxjs';
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
import { ContextMenuService } from './context-menu.service';
|
||||
import { ContextMenuModule } from './context-menu.module';
|
||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||
|
||||
describe('ContextMenuService', () => {
|
||||
let contextMenuService;
|
||||
let overlay;
|
||||
let injector;
|
||||
let userPreferencesService;
|
||||
const overlayConfig = {
|
||||
hasBackdrop: false,
|
||||
backdropClass: '',
|
||||
panelClass: 'test-panel'
|
||||
panelClass: 'test-panel',
|
||||
source: {
|
||||
x: 1,
|
||||
y: 1
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CoreModule.forRoot(), ContextMenuModule],
|
||||
providers: [Overlay, { provide: Store, useValue: { select: () => of() } }]
|
||||
providers: [
|
||||
Overlay,
|
||||
{ provide: Store, useValue: { select: () => of() } },
|
||||
UserPreferencesService
|
||||
]
|
||||
});
|
||||
|
||||
const injector = TestBed.get(Injector);
|
||||
const overlay = TestBed.get(Overlay);
|
||||
|
||||
contextMenuService = new ContextMenuService(injector, overlay);
|
||||
injector = TestBed.get(Injector);
|
||||
overlay = TestBed.get(Overlay);
|
||||
userPreferencesService = TestBed.get(UserPreferencesService);
|
||||
});
|
||||
|
||||
it('should create a custom overlay', () => {
|
||||
contextMenuService = new ContextMenuService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
|
||||
contextMenuService.open(overlayConfig);
|
||||
|
||||
expect(document.querySelector('.test-panel')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should render component', () => {
|
||||
contextMenuService = new ContextMenuService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
|
||||
contextMenuService.open(overlayConfig);
|
||||
|
||||
expect(document.querySelector('aca-context-menu')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should have default LTR direction value', () => {
|
||||
contextMenuService = new ContextMenuService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
|
||||
contextMenuService.open(overlayConfig);
|
||||
|
||||
expect(document.body.querySelector('div[dir="ltr"]')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should change direction on textOrientation event', () => {
|
||||
spyOn(userPreferencesService, 'select').and.returnValue(of('rtl'));
|
||||
|
||||
contextMenuService = new ContextMenuService(
|
||||
injector,
|
||||
overlay,
|
||||
userPreferencesService
|
||||
);
|
||||
|
||||
contextMenuService.open(overlayConfig);
|
||||
|
||||
expect(document.body.querySelector('div[dir="rtl"]')).not.toBe(null);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user