'use strict';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { OptionsService } from './options.service';
describe('Options Service', () => {
let tmpDiv;
let optionsService;
function build(html) {
tmpDiv = document.createElement('div');
tmpDiv.innerHTML = html;
document.body.appendChild(tmpDiv);
return tmpDiv.lastChild;
}
afterEach(() => {
document.body.removeChild(tmpDiv);
});
beforeEach(() => {
optionsService = new OptionsService(new BrowserDomAdapter());
});
it('should parse numeric scrollYOffset', () => {
var elem = build(``);
optionsService.parseOptions(elem);
optionsService.options.scrollYOffset().should.be.equal(50);
});
it('should parse selector scrollYOffset', () => {
var elem = build(`
`);
optionsService.parseOptions(elem);
optionsService.options.scrollYOffset().should.be.equal(50);
});
it('should return 0 for incorrect selector scrollYOffset', () => {
var elem = build(`
`);
optionsService.parseOptions(elem);
optionsService.options.scrollYOffset().should.be.equal(0);
});
it('should handle function scrollYOffset', () => {
optionsService.options = { scrollYOffset: () => 123 };
var elem = build(``);
optionsService.parseOptions(elem);
optionsService.options.scrollYOffset().should.be.equal(123);
});
});