Skip to content
Snippets Groups Projects
Commit 4afa5098 authored by rhenck's avatar rhenck
Browse files

[player] Fix tests to use the new Page class

parent eb6008f9
No related branches found
No related tags found
No related merge requests found
Pipeline #38411 passed
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageComponent } from './page.component'; import { PageComponent } from './page.component';
import { Page } from 'common/models/page';
describe('PageComponent', () => { describe('PageComponent', () => {
let component: PageComponent; let component: PageComponent;
...@@ -15,16 +16,7 @@ describe('PageComponent', () => { ...@@ -15,16 +16,7 @@ describe('PageComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(PageComponent); fixture = TestBed.createComponent(PageComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.page = { component.page = new Page();
sections: [],
hasMaxWidth: false,
maxWidth: 0,
margin: 0,
backgroundColor: 'white',
alwaysVisible: false,
alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50
};
fixture.detectChanges(); fixture.detectChanges();
}); });
......
...@@ -4,7 +4,7 @@ import { Page } from 'common/models/page'; ...@@ -4,7 +4,7 @@ import { Page } from 'common/models/page';
describe('AlwaysVisiblePagePipe', () => { describe('AlwaysVisiblePagePipe', () => {
const page: Page = { const page: Page = new Page({
hasMaxWidth: false, hasMaxWidth: false,
maxWidth: 0, maxWidth: 0,
margin: 0, margin: 0,
...@@ -13,13 +13,13 @@ describe('AlwaysVisiblePagePipe', () => { ...@@ -13,13 +13,13 @@ describe('AlwaysVisiblePagePipe', () => {
alwaysVisiblePagePosition: 'left', alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50, alwaysVisibleAspectRatio: 50,
sections: [] sections: []
}; });
const pipe = new AlwaysVisiblePagePipe(); const pipe = new AlwaysVisiblePagePipe();
it('should transform an array of pages to the always visible page of the array', () => { it('should transform an array of pages to the always visible page of the array', () => {
const pages = [page, page, { ...page, alwaysVisible: true }]; const pages = [page, page, { ...page, alwaysVisible: true } as Page];
expect(pipe.transform(pages)).toEqual({ ...page, alwaysVisible: true }); expect(pipe.transform(pages)).toEqual({ ...page, alwaysVisible: true } as Page);
}); });
it('should transform an array of pages without any always visible page to null', () => { it('should transform an array of pages without any always visible page to null', () => {
......
...@@ -3,7 +3,7 @@ import { Page } from 'common/models/page'; ...@@ -3,7 +3,7 @@ import { Page } from 'common/models/page';
describe('PageIndexPipe', () => { describe('PageIndexPipe', () => {
const page: Page = { const page: Page = new Page({
hasMaxWidth: false, hasMaxWidth: false,
maxWidth: 0, maxWidth: 0,
margin: 0, margin: 0,
...@@ -12,9 +12,9 @@ describe('PageIndexPipe', () => { ...@@ -12,9 +12,9 @@ describe('PageIndexPipe', () => {
alwaysVisiblePagePosition: 'left', alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50, alwaysVisibleAspectRatio: 50,
sections: [] sections: []
}; });
const page2: Page = { const page2: Page = new Page({
hasMaxWidth: false, hasMaxWidth: false,
maxWidth: 0, maxWidth: 0,
margin: 0, margin: 0,
...@@ -23,33 +23,33 @@ describe('PageIndexPipe', () => { ...@@ -23,33 +23,33 @@ describe('PageIndexPipe', () => {
alwaysVisiblePagePosition: 'left', alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50, alwaysVisibleAspectRatio: 50,
sections: [] sections: []
}; });
const pipe = new PageIndexPipe(); const pipe = new PageIndexPipe();
it('should transform pages to the index of given page (0)', () => { it('should transform pages to the index of given page (0)', () => {
const pages = [page, page2, { ...page2, alwaysVisible: true }]; const pages = [page, page2, { ...page2, alwaysVisible: true } as Page];
expect(pipe.transform(pages, page)).toEqual(0); expect(pipe.transform(pages, page)).toEqual(0);
}); });
it('should transform pages to the index of given page (not 1)', () => { it('should transform pages to the index of given page (not 1)', () => {
const pages = [page, page2, { ...page2, alwaysVisible: true }]; const pages = [page, page2, { ...page2, alwaysVisible: true } as Page];
expect(pipe.transform(pages, page)).not.toEqual(1); expect(pipe.transform(pages, page)).not.toEqual(1);
}); });
it('should transform pages to the index of given page2 (1)', () => { it('should transform pages to the index of given page2 (1)', () => {
const pages = [page, page2, { ...page2, alwaysVisible: true }]; const pages = [page, page2, { ...page2, alwaysVisible: true } as Page];
expect(pipe.transform(pages, page2)).toEqual(1); expect(pipe.transform(pages, page2)).toEqual(1);
}); });
it('should transform pages to the index of unknown page (-1)', () => { it('should transform pages to the index of unknown page (-1)', () => {
const pages = [page, { ...page2, alwaysVisible: true }]; const pages = [page, { ...page2, alwaysVisible: true } as Page];
expect(pipe.transform(pages, page2)).toEqual(-1); expect(pipe.transform(pages, page2)).toEqual(-1);
}); });
it('should transform pages to the index of unknown page (-1)', () => { it('should transform pages to the index of unknown page (-1)', () => {
const pages = [page, { ...page2, alwaysVisible: true }]; const pages = [page, { ...page2, alwaysVisible: true } as Page];
expect(pipe.transform(pages, { ...page2, alwaysVisible: true })).toEqual(-1); expect(pipe.transform(pages, { ...page2, alwaysVisible: true } as Page)).toEqual(-1);
}); });
}); });
...@@ -3,7 +3,7 @@ import { Page } from 'common/models/page'; ...@@ -3,7 +3,7 @@ import { Page } from 'common/models/page';
describe('ScrollPagesPipe', () => { describe('ScrollPagesPipe', () => {
const page: Page = { const page: Page = new Page({
hasMaxWidth: false, hasMaxWidth: false,
maxWidth: 0, maxWidth: 0,
margin: 0, margin: 0,
...@@ -12,12 +12,12 @@ describe('ScrollPagesPipe', () => { ...@@ -12,12 +12,12 @@ describe('ScrollPagesPipe', () => {
alwaysVisiblePagePosition: 'left', alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50, alwaysVisibleAspectRatio: 50,
sections: [] sections: []
}; });
const pipe = new ScrollPagesPipe(); const pipe = new ScrollPagesPipe();
it('should transform 3 pages to 2 scroll pages', () => { it('should transform 3 pages to 2 scroll pages', () => {
const pages = [page, page, { ...page, alwaysVisible: true }]; const pages = [page, page, { ...page, alwaysVisible: true } as Page];
expect(pipe.transform(pages).length).toBe(2); expect(pipe.transform(pages).length).toBe(2);
}); });
......
...@@ -13,7 +13,7 @@ describe('ValidPagesPipe', () => { ...@@ -13,7 +13,7 @@ describe('ValidPagesPipe', () => {
} }
}; };
const page: Page = { const page = new Page({
hasMaxWidth: false, hasMaxWidth: false,
maxWidth: 0, maxWidth: 0,
margin: 0, margin: 0,
...@@ -22,7 +22,7 @@ describe('ValidPagesPipe', () => { ...@@ -22,7 +22,7 @@ describe('ValidPagesPipe', () => {
alwaysVisiblePagePosition: 'left', alwaysVisiblePagePosition: 'left',
alwaysVisibleAspectRatio: 50, alwaysVisibleAspectRatio: 50,
sections: [] sections: []
}; });
beforeEach(() => { beforeEach(() => {
TestBed TestBed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment