"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cdk/bidi/directionality.spec.ts" between
material2-7.3.2.tar.gz and material2-7.3.3.tar.gz

About: material2 offers Material Design components for Angular.

directionality.spec.ts  (material2-7.3.2):directionality.spec.ts  (material2-7.3.3)
skipping to change at line 14 skipping to change at line 14
import {BidiModule, Directionality, Dir, Direction, DIR_DOCUMENT} from './index' ; import {BidiModule, Directionality, Dir, Direction, DIR_DOCUMENT} from './index' ;
describe('Directionality', () => { describe('Directionality', () => {
let fakeDocument: FakeDocument; let fakeDocument: FakeDocument;
beforeEach(async(() => { beforeEach(async(() => {
fakeDocument = {body: {}, documentElement: {}}; fakeDocument = {body: {}, documentElement: {}};
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [BidiModule], imports: [BidiModule],
declarations: [ElementWithDir, ElementWithPredefinedAutoDir, InjectsDirect declarations: [
ionality], ElementWithDir,
ElementWithPredefinedAutoDir,
InjectsDirectionality,
ElementWithPredefinedUppercaseDir,
],
providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDocument}], providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDocument}],
}).compileComponents(); }).compileComponents();
})); }));
describe('Service', () => { describe('Service', () => {
it('should read dir from the html element if not specified on the body', () => { it('should read dir from the html element if not specified on the body', () => {
fakeDocument.documentElement.dir = 'rtl'; fakeDocument.documentElement.dir = 'rtl';
const fixture = TestBed.createComponent(InjectsDirectionality); const fixture = TestBed.createComponent(InjectsDirectionality);
const testComponent = fixture.debugElement.componentInstance; const testComponent = fixture.debugElement.componentInstance;
skipping to change at line 137 skipping to change at line 142
'normalizing the directive value', () => { 'normalizing the directive value', () => {
const fixture = TestBed.createComponent(ElementWithPredefinedAutoDir); const fixture = TestBed.createComponent(ElementWithPredefinedAutoDir);
fixture.detectChanges(); fixture.detectChanges();
const element = fixture.nativeElement.querySelector('div'); const element = fixture.nativeElement.querySelector('div');
expect(element.getAttribute('dir')).toBe('auto'); expect(element.getAttribute('dir')).toBe('auto');
expect(fixture.componentInstance.dir.value).toBe('ltr'); expect(fixture.componentInstance.dir.value).toBe('ltr');
}); });
it('should be case-insensitive', () => {
const fixture = TestBed.createComponent(ElementWithPredefinedUppercaseDir)
;
fixture.detectChanges();
expect(fixture.componentInstance.dir.value).toBe('rtl');
});
}); });
}); });
@Component({ @Component({
template: ` template: `
<div [dir]="direction" (dirChange)="changeCount = changeCount + 1"> <div [dir]="direction" (dirChange)="changeCount = changeCount + 1">
<injects-directionality></injects-directionality> <injects-directionality></injects-directionality>
</div> </div>
` `
}) })
skipping to change at line 160 skipping to change at line 172
changeCount = 0; changeCount = 0;
} }
@Component({ @Component({
template: '<div dir="auto"></div>' template: '<div dir="auto"></div>'
}) })
class ElementWithPredefinedAutoDir { class ElementWithPredefinedAutoDir {
@ViewChild(Dir) dir: Dir; @ViewChild(Dir) dir: Dir;
} }
@Component({
template: '<div dir="RTL"></div>'
})
class ElementWithPredefinedUppercaseDir {
@ViewChild(Dir) dir: Dir;
}
/** Test component with Dir directive. */ /** Test component with Dir directive. */
@Component({ @Component({
selector: 'injects-directionality', selector: 'injects-directionality',
template: `<div></div>` template: `<div></div>`
}) })
class InjectsDirectionality { class InjectsDirectionality {
constructor(public dir: Directionality) { } constructor(public dir: Directionality) { }
} }
interface FakeDocument { interface FakeDocument {
 End of changes. 3 change blocks. 
2 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)