Permalink
Browse files

fix(dialog-configuration): set defaults for ".renderer" and ".cssText"

fix #307
  • Loading branch information...
StrahilKazlachev committed Jun 25, 2017
1 parent c6dd762 commit fd58f2a9a3db56775c4ce721e6b2471076356d46
Showing with 31 additions and 11 deletions.
  1. +4 −4 src/dialog-configuration.ts
  2. +27 −7 test/unit/dialog-configuration.spec.ts
@@ -25,12 +25,12 @@ const defaultCSSText = `ux-dialog-container,ux-dialog-overlay{position:fixed;top
*/
export class DialogConfiguration {
private fwConfig: FrameworkConfiguration;
private renderer: RendererStatic;
private cssText: string;
private renderer: RendererStatic = defaultRenderer;
private cssText: string = defaultCSSText;
private resources: string[] = [];
/**
* The configuration settings.
* The global configuration settings.
*/
public settings: DialogSettings;
@@ -96,7 +96,7 @@ export class DialogConfiguration {
}
/**
* Configures the plugin to use specific css.
* Configures the plugin to use specific css. You can pass an empty string to clear any set css.
* @param cssText The css to use in place of the default styles.
* @return This instance.
*/
@@ -1,9 +1,9 @@
import {Container} from 'aurelia-dependency-injection';
import {FrameworkConfiguration} from 'aurelia-framework';
import {DOM} from 'aurelia-pal';
import {DialogConfiguration, Renderer} from '../../src/aurelia-dialog';
import {DefaultDialogSettings} from '../../src/dialog-settings';
import {DialogRenderer} from '../../src/dialog-renderer';
import { Container } from 'aurelia-dependency-injection';
import { FrameworkConfiguration } from 'aurelia-framework';
import { DOM } from 'aurelia-pal';
import { DialogConfiguration, Renderer } from '../../src/aurelia-dialog';
import { DefaultDialogSettings } from '../../src/dialog-settings';
import { DialogRenderer } from '../../src/dialog-renderer';
describe('DialogConfiguration', () => {
const frameworkConfig: FrameworkConfiguration = {
@@ -22,7 +22,7 @@ describe('DialogConfiguration', () => {
configuration = new DialogConfiguration(frameworkConfig, applySetterSpy);
});
describe('the constructor', () => {
describe('when instantiated', () => {
it('should get the default settings from the container', () => {
spyOn(frameworkConfig.container, 'get').and.callThrough();
// tslint:disable-next-line:no-unused-new
@@ -31,6 +31,26 @@ describe('DialogConfiguration', () => {
});
});
describe('even when ".useDefaults" is not called', () => {
it('a default Renderer should be registered', () => {
let applyConfig: () => void = null as any;
// tslint:disable-next-line:no-unused-new
new DialogConfiguration(frameworkConfig, apply => { applyConfig = apply; });
spyOn(frameworkConfig, 'transient');
applyConfig();
expect(frameworkConfig.transient).toHaveBeenCalledWith(Renderer, DialogRenderer);
});
it('the default css styles should be applied', () => {
let applyConfig: () => void = null as any;
// tslint:disable-next-line:no-unused-new
new DialogConfiguration(frameworkConfig, apply => { applyConfig = apply; });
spyOn(DOM, 'injectStyles');
applyConfig();
expect(DOM.injectStyles).toHaveBeenCalledWith(jasmine.any(String));
});
});
describe('useRenderer', () => {
it('should register a renderer as a transient', () => {
const renderer = {} as any;

0 comments on commit fd58f2a

Please sign in to comment.