Skip to content

Commit

Permalink
fix(progressbar): applying latest review changes
Browse files Browse the repository at this point in the history
Closes #5903
  • Loading branch information
Aleksandyr committed Jan 23, 2020
1 parent 5233d01 commit 7fdf075
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ All notable changes for each version of this project will be documented in this
- `IgxCarousel`:
- **Breaking Changes** -The carousel slides are no longer array, they are changed to QueryList.
- **Behavioural change** - When slides are more than 5, a label is shown instead of the indicators. The count limit of visible indicators can be changed with the input `maximumIndicatorsCount`
- Added `Directionality` service providing information about the text direction of the element's content.


### New Features
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`:
Expand Down Expand Up @@ -107,6 +105,9 @@ All notable changes for each version of this project will be documented in this

@include igx-progress-circular($theme);
```
- RTL support
- `IgxLinearProgressBar`:
- RTL support

## 8.2.6

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { TestBed } from '@angular/core/testing';
import { TestBed, async, inject } from '@angular/core/testing';
import { Component } from '@angular/core';
import { IgxDirectionality, DIR_DOCUMENT } from './directionality';
import { DOCUMENT } from '@angular/common';

interface FakeDoc {
body: { dir?: string };
documentElement: { dir?: string };
}

describe('IgxDirectionality', () => {
describe('IgxDirectionality DI', () => {
let fakeDoc: FakeDoc;
beforeEach(async(() => {
fakeDoc = {body: {}, documentElement: {}};
Expand All @@ -16,48 +17,65 @@ describe('IgxDirectionality', () => {
declarations: [
InjectsIgxDirectionalityComponent
],
providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDoc}],
}).compileComponents();
});
}));

it('should read dir from html if not specified on the body', () => {
const expectedRes = 'rtl';
fakeDoc.documentElement.dir = expectedRes;
it('should inject the document through the injectionToken properly', () => {
const injectionToken = TestBed.inject(DIR_DOCUMENT);
const document = TestBed.inject(DOCUMENT);

expect(injectionToken).toEqual(document);
expect(injectionToken).toEqual(jasmine.any(Document));
expect(document).toBeTruthy(jasmine.any(Document));
});

it('should read dir from html if not specified on the body', inject([DOCUMENT], () => {
const fixture = TestBed.createComponent(InjectsIgxDirectionalityComponent);
const component = fixture.debugElement.componentInstance;

expect(component.dir.value).toEqual(expectedRes);
expect(component.dir.document).not.toBeNull();
expect(component.dir.document).not.toBeUndefined();
expect(component.dir.document).toEqual(jasmine.any(Document));
}));

});
describe('IgxDirectionality', () => {
let fakeDoc: FakeDoc;
beforeEach(() => {
fakeDoc = {body: {}, documentElement: {}};
});

let expectedRes: string;
let dirInstance: IgxDirectionality;
it('should read dir from html if not specified on the body', () => {
expectedRes = 'rtl';
fakeDoc.documentElement.dir = expectedRes;

dirInstance = new IgxDirectionality(fakeDoc);
expect(dirInstance.value).toEqual(expectedRes);
});
it('should read dir from body even it is also specified on the html element', () => {
fakeDoc.documentElement.dir = 'ltr';
const expectedRes = 'rtl';
expectedRes = 'rtl';
fakeDoc.body.dir = expectedRes;

const fixture = TestBed.createComponent(InjectsIgxDirectionalityComponent);
const component = fixture.debugElement.componentInstance;

expect(component.dir.value).toEqual(expectedRes);
dirInstance = new IgxDirectionality(fakeDoc);
expect(dirInstance.value).toEqual(expectedRes);
});

it('should default to ltr if nothing specified', () => {
const expectedRes = 'ltr';
expectedRes = 'ltr';

const fixture = TestBed.createComponent(InjectsIgxDirectionalityComponent);
const component = fixture.debugElement.componentInstance;

expect(component.dir.value).toEqual(expectedRes);
dirInstance = new IgxDirectionality(fakeDoc);
expect(dirInstance.value).toEqual(expectedRes);
});

it('should default to ltr if invalid values are set both on body or html elements', () => {
fakeDoc.documentElement.dir = 'none';
fakeDoc.body.dir = 'irrelevant';

const fixture = TestBed.createComponent(InjectsIgxDirectionalityComponent);
const component = fixture.debugElement.componentInstance;

expect(component.dir.value).toEqual('ltr');
dirInstance = new IgxDirectionality(fakeDoc)
expect(dirInstance.value).toEqual('ltr');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function DIR_DOCUMENT_FACTORY(): Document {

/**
* @hidden
* @dynamic
*
* Bidirectional service that extracts the value of the direction attribute on the body or html elements.
*
Expand All @@ -47,6 +46,10 @@ export class IgxDirectionality {
return this._dir;
}

public get document() {
return this._document;
}

constructor(@Inject(DIR_DOCUMENT) document) {
this._document = <Document>document;
const bodyDir = this._document.body ? this._document.body.dir : null;
Expand Down

0 comments on commit 7fdf075

Please sign in to comment.