Skip to content

Commit

Permalink
Adding Spacer support (#142)
Browse files Browse the repository at this point in the history
* Adding Spacer support
* Updating tests to FIXED spacers
  • Loading branch information
dr-bizz authored Oct 30, 2023
1 parent 2d6c323 commit 4ae1c2f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/app/_tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
MultiselectOption,
Flow,
FlowItem,
Card
Card,
Spacer
} from 'src/app/services/xml-parser-service/xmp-parser.service';
import { org } from '@cruglobal/godtools-shared';

Expand Down Expand Up @@ -542,3 +543,14 @@ export const mockPageComponent = {
}
}
};

export const mockSpacer = (height = 100): Spacer => {
return {
height,
mode: {
name: 'FIXED',
ordinal: 0
},
...standardTypeValues()
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.spacer {
display: block;
width: 100%;
}
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<!-- Content Spacer Goes Here -->
<div
class="spacer"
*ngIf="mode === 'FIXED'"
[ngStyle]="{ 'height.px': height }"
></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { mockSpacer } from '../../../_tests/mocks';
import { ContentSpacerNewComponent } from './content-spacer.component';

describe('ContentSpacerComponent', () => {
let component: ContentSpacerNewComponent;
let fixture: ComponentFixture<ContentSpacerNewComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ContentSpacerNewComponent]
}).compileComponents();
fixture = TestBed.createComponent(ContentSpacerNewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
}));

it('Values are assigned correctly', async () => {
component.item = mockSpacer(200);
component.ngOnChanges({
item: new SimpleChange(null, mockSpacer(200), true)
});
expect(component.height).toEqual(200);
expect(component.mode).toBe('FIXED');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class ContentSpacerNewComponent implements OnChanges {
!changes['item'].previousValue ||
changes['item'].currentValue !== changes['item'].previousValue
) {
this.mode = '';
this.height = 0;
this.mode = this.item.mode.name;
this.height = this.item.height;
this.spacer = this.item;
this.ready = false;
this.init();
Expand Down

0 comments on commit 4ae1c2f

Please sign in to comment.