generated from PolymeshAssociation/typescript-boilerplate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Entity } from '~/base'; | ||
import { Context } from '~/context'; | ||
|
||
/** | ||
* Represents a namespace within an Entity with the purpose of grouping related functionality | ||
*/ | ||
export class Namespace<Parent extends Entity<{}>> { | ||
protected parent: Parent; | ||
|
||
protected context: Context; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
constructor(parent: Parent, context: Context) { | ||
this.parent = parent; | ||
this.context = context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Entity } from '~/base'; | ||
import { Namespace } from '~/base/Namespace'; | ||
import { Context } from '~/context'; | ||
|
||
describe('Namespace class', () => { | ||
describe('constructor', () => { | ||
test('should assign parent and context to instance', () => { | ||
const context = ('context' as unknown) as Context; | ||
const parent = ('entity' as unknown) as Entity<{}>; | ||
const namespace = new Namespace(parent, context); | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
expect((namespace as any).parent).toEqual(parent); | ||
expect((namespace as any).context).toEqual(context); | ||
/* eslint-enable @typescript-eslint/no-explicit-any */ | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters