Permalink
Browse files

fix(resources): use named exports instead of default

  • Loading branch information...
StrahilKazlachev committed Aug 22, 2018
1 parent 0718b63 commit 4033216d3bd0fdb32108429b25919cb60b1ab58a
@@ -7,11 +7,11 @@ import { DOM } from 'aurelia-pal';
const defaultRenderer: RendererStatic = DialogRenderer;
const resources: { [key: string]: () => Promise<any> } = {
'ux-dialog': () => import('./resources/ux-dialog'),
'ux-dialog-header': () => import('./resources/ux-dialog-header'),
'ux-dialog-body': () => import('./resources/ux-dialog-body'),
'ux-dialog-footer': () => import('./resources/ux-dialog-footer'),
'attach-focus': () => import('./resources/attach-focus')
'ux-dialog': () => import('./resources/ux-dialog').then(m => m.UxDialog),
'ux-dialog-header': () => import('./resources/ux-dialog-header').then(m => m.UxDialogHeader),
'ux-dialog-body': () => import('./resources/ux-dialog-body').then(m => m.UxDialogBody),
'ux-dialog-footer': () => import('./resources/ux-dialog-footer').then(m => m.UxDialogFooter),
'attach-focus': () => import('./resources/attach-focus').then(m => m.AttachFocus)
};
// tslint:disable-next-line:max-line-length
@@ -27,7 +27,7 @@ export class DialogConfiguration {
private fwConfig: FrameworkConfiguration;
private renderer: RendererStatic = defaultRenderer;
private cssText: string = defaultCSSText;
private resources: string[] = [];
private resources: DialogResourceName[] = [];
/**
* The global configuration settings.
@@ -52,9 +52,7 @@ export class DialogConfiguration {
if (this.resources.length) {
return Promise.all(this.resources.map(name => resources[name]()))
.then(modules => {
this.fwConfig.globalResources(modules.map(m => m.default as () => void));
});
.then(modules => { this.fwConfig.globalResources(modules); });
}
}
@@ -3,7 +3,7 @@ import { customAttribute, ComponentAttached } from 'aurelia-templating';
import { DOM } from 'aurelia-pal';
@customAttribute('attach-focus', bindingMode.oneTime)
export default class AttachFocus implements ComponentAttached {
export class AttachFocus implements ComponentAttached {
public value: boolean | string;
/**
@@ -6,6 +6,6 @@ import { customElement, inlineView } from 'aurelia-templating';
<slot></slot>
</template>
`)
export default class UxDialogBody {
export class UxDialogBody {
}
@@ -19,7 +19,7 @@ import { DialogController } from '../dialog-controller';
</template>
`)
export default class UxDialogFooter {
export class UxDialogFooter {
public static isCancelButton(value: string) {
return value === 'Cancel';
}
@@ -19,7 +19,7 @@ import { DialogController } from '../dialog-controller';
</template>
`)
export default class UxDialogHeader implements ComponentBind {
export class UxDialogHeader implements ComponentBind {
@bindable() public showCloseButton: boolean | undefined;
/**
@@ -6,6 +6,6 @@ import { customElement, inlineView } from 'aurelia-templating';
<slot></slot>
</template>
`)
export default class UxDialog {
export class UxDialog {
}
@@ -4,7 +4,11 @@ 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 UxDialog from '../../src/resources/ux-dialog';
import { UxDialog } from '../../src/resources/ux-dialog';
import { UxDialogHeader } from '../../src/resources/ux-dialog-header';
import { UxDialogBody } from '../../src/resources/ux-dialog-body';
import { UxDialogFooter } from '../../src/resources/ux-dialog-footer';
import { AttachFocus } from '../../src/resources/attach-focus';
describe('DialogConfiguration', () => {
const frameworkConfig: FrameworkConfiguration = {
@@ -93,6 +97,23 @@ describe('DialogConfiguration', () => {
});
});
describe('useStandardResources', () => {
it('should register all standard resources as global', async done => {
spyOn(frameworkConfig, 'globalResources');
configuration.useStandardResources();
await whenConfigured(applyConfig, done);
const expectedContents = [
UxDialog,
UxDialogHeader,
UxDialogBody,
UxDialogFooter,
AttachFocus
];
expect(frameworkConfig.globalResources).toHaveBeenCalledWith(jasmine.arrayContaining(expectedContents));
done();
});
});
describe('useDefaults', () => {
it('should call useRenderer with the default renderer', async done => {
spyOn(configuration, 'useRenderer').and.callThrough();

0 comments on commit 4033216

Please sign in to comment.