Permalink
Browse files

fix(loader): applying default options

properly apply default backkend options and override with user provided options

closes issue #282
#281
  • Loading branch information...
zewa666 committed Sep 10, 2018
1 parent e2ff048 commit 2ce9dbb6e165a2343e7b35e3976a97ad2835a075
Showing with 16 additions and 2 deletions.
  1. +2 −2 src/aurelia-i18n-loader.ts
  2. +14 −0 test/unit/aurelia-loader.spec.ts
@@ -34,12 +34,12 @@ export class Backend {
public init(services: any, options: AureliaBackendOptions = {}) {
this.services = services;
this.options = Object.assign({}, options, {
this.options = Object.assign({}, {
loadPath: "/locales/{{lng}}/{{ns}}.json",
addPath: "locales/add/{{lng}}/{{ns}}",
allowMultiLoading: false,
parse: JSON.parse
});
}, options);
}
public readMulti(languages: string[], namespaces: string[], callback: LoadCallback) {
@@ -0,0 +1,14 @@
import Backend from "../../src/aurelia-i18n-loader";
describe("aurelia-loader", () => {
it("should accept backend options", async () => {
const expectedValue = "./my/own/locales/{{lng}}/{{ns}}.json";
const sut = new Backend({});
sut.init({}, {
loadPath: expectedValue
});
expect(sut.options.loadPath).toBe(expectedValue);
});
});

0 comments on commit 2ce9dbb

Please sign in to comment.