Skip to content

Commit

Permalink
fix(dialog-configuration): set defaults for ".renderer" and ".cssText"
Browse files Browse the repository at this point in the history
fix #307
  • Loading branch information
StrahilKazlachev committed Jul 8, 2017
1 parent c6dd762 commit fd58f2a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/dialog-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
*/
Expand Down
34 changes: 27 additions & 7 deletions test/unit/dialog-configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit fd58f2a

Please sign in to comment.