Skip to content

Commit

Permalink
Merge pull request #24 from Exabyte-io/fix/SOF-6197
Browse files Browse the repository at this point in the history
chore: rename static class variables
  • Loading branch information
timurbazhirov authored Aug 31, 2022
2 parents a9cc8ff + 3743d96 commit cd3f9ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/context/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const ApplicationContextMixin = (superclass) =>
class extends superclass {
constructor(config) {
super(config);
if (!this.constructor.applicationCls)
throw Error("ApplicationContextMixin: applicationCls is undefined");
if (!this.constructor.Application)
throw Error("ApplicationContextMixin: Application is undefined");
this._application =
(config.context && config.context.application) ||
this.constructor.applicationCls.createDefault();
this.constructor.Application.createDefault();
}

get application() {
Expand All @@ -23,11 +23,11 @@ export const MaterialContextMixin = (superclass) =>
class extends superclass {
constructor(config) {
super(config);
if (!this.constructor.materialCls) {
throw Error("MaterialContextMixin: materialCls is undefined");
if (!this.constructor.Material) {
throw Error("MaterialContextMixin: Material is undefined");
}
this._material = config.context && config.context.material;
if (!this._material) this._material = this.constructor.materialCls.createDefault();
if (!this._material) this._material = this.constructor.Material.createDefault();
this.updateMaterialHash();
}

Expand Down Expand Up @@ -82,13 +82,13 @@ export const MaterialsContextMixin = (superclass) =>
constructor(config) {
super(config);
const materials = this.config.context && this.config.context.materials;
if (!this.constructor.materialCls) {
throw Error("MaterialsContextMixin: materialCls is undefined");
if (!this.constructor.Material) {
throw Error("MaterialsContextMixin: Material is undefined");
}
this._materials =
materials && materials.length
? materials
: [this.constructor.materialCls.createDefault()];
: [this.constructor.Material.createDefault()];
}

get materials() {
Expand Down
8 changes: 4 additions & 4 deletions tests/context.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class ProviderEntity extends mix(InMemoryEntity).with(
MaterialContextMixin,
ApplicationContextMixin,
) {
static materialCls = MockMaterial;
static Material = MockMaterial;

static applicationCls = MockApplication;
static Application = MockApplication;
}

class DerivedProviderEntity extends ProviderEntity {
static materialCls = SpecificMockMaterial;
static Material = SpecificMockMaterial;

static applicationCls = SpecificMockApplication;
static Application = SpecificMockApplication;
}

describe("Material & Application ContextMixin", () => {
Expand Down

0 comments on commit cd3f9ba

Please sign in to comment.