@ts-graphviz/core 0.0.0-pr956-20240225073457 → 0.0.0-pr956-20240225091623

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/package.json +39 -16
  3. package/src/attribute.ts +0 -18
  4. package/src/core.ts +0 -5
  5. package/src/from-dot.ts +0 -73
  6. package/src/model-factory/index.ts +0 -2
  7. package/src/model-factory/model-factory-builder.test.ts +0 -79
  8. package/src/model-factory/model-factory-builder.ts +0 -55
  9. package/src/model-factory/model-factory.test.ts +0 -61
  10. package/src/model-factory/model-factory.ts +0 -40
  11. package/src/model-factory/types.ts +0 -46
  12. package/src/models/AttributeList.spec.ts +0 -58
  13. package/src/models/AttributeList.ts +0 -32
  14. package/src/models/AttributesBase.spec.ts +0 -79
  15. package/src/models/AttributesBase.ts +0 -62
  16. package/src/models/AttributesGroup.spec.ts +0 -18
  17. package/src/models/AttributesGroup.ts +0 -13
  18. package/src/models/Digraph.spec.ts +0 -17
  19. package/src/models/Digraph.ts +0 -11
  20. package/src/models/DotObject.ts +0 -5
  21. package/src/models/Edge.spec.ts +0 -48
  22. package/src/models/Edge.ts +0 -40
  23. package/src/models/Graph.spec.ts +0 -18
  24. package/src/models/Graph.ts +0 -11
  25. package/src/models/GraphBase.spec.ts +0 -364
  26. package/src/models/GraphBase.ts +0 -263
  27. package/src/models/Node.spec.ts +0 -25
  28. package/src/models/Node.ts +0 -37
  29. package/src/models/RootGraph.spec.ts +0 -69
  30. package/src/models/RootGraph.ts +0 -48
  31. package/src/models/Subgraph.spec.ts +0 -196
  32. package/src/models/Subgraph.ts +0 -44
  33. package/src/models/index.ts +0 -15
  34. package/src/models/registerModelContext.ts +0 -14
  35. package/src/to-dot.ts +0 -36
  36. package/tsconfig.json +0 -8
  37. package/typedoc.json +0 -4
  38. package/vite.config.ts +0 -22
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ts-graphviz/core
2
2
 
3
- ## 0.0.0-pr956-20240225073457
3
+ ## 0.0.0-pr956-20240225091623
4
4
 
5
5
  ### Major Changes
6
6
 
@@ -9,5 +9,5 @@
9
9
  ### Patch Changes
10
10
 
11
11
  - Updated dependencies [[`6b2f0e8`](https://github.com/ts-graphviz/ts-graphviz/commit/6b2f0e8349605b4fe0dd950147ba3a8285b24b24)]:
12
- - @ts-graphviz/common@0.0.0-pr956-20240225073457
13
- - @ts-graphviz/ast@0.0.0-pr956-20240225073457
12
+ - @ts-graphviz/common@0.0.0-pr956-20240225091623
13
+ - @ts-graphviz/ast@0.0.0-pr956-20240225091623
package/package.json CHANGED
@@ -1,36 +1,59 @@
1
1
  {
2
2
  "name": "@ts-graphviz/core",
3
- "version": "0.0.0-pr956-20240225073457",
3
+ "version": "0.0.0-pr956-20240225091623",
4
4
  "description": "",
5
- "type": "module",
6
- "main": "lib/core.cjs",
7
- "module": "lib/core.js",
8
- "types": "lib/core.d.ts",
5
+ "keywords": [
6
+ "graphviz",
7
+ "dot"
8
+ ],
9
+ "homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/ts-graphviz/ts-graphviz/issues"
12
+ },
9
13
  "repository": {
10
14
  "type": "git",
11
15
  "url": "git+https://github.com/ts-graphviz/ts-graphviz.git",
12
16
  "directory": "packages/core"
13
17
  },
14
- "publishConfig": {
15
- "access": "public",
16
- "provenance": true
17
- },
18
- "author": "Yuki Yamazaki <yuki@kamiazya.tech>",
18
+ "funding": [
19
+ {
20
+ "type": "github",
21
+ "url": "https://github.com/sponsors/ts-graphviz"
22
+ },
23
+ {
24
+ "type": "opencollective",
25
+ "url": "https://opencollective.com/ts-graphviz"
26
+ }
27
+ ],
19
28
  "license": "MIT",
20
- "bugs": {
21
- "url": "https://github.com/ts-graphviz/ts-graphviz/issues"
22
- },
23
- "homepage": "https://github.com/ts-graphviz/ts-graphviz#readme",
29
+ "author": "Yuki Yamazaki <yuki@kamiazya.tech>",
24
30
  "sideEffects": true,
31
+ "type": "module",
32
+ "main": "lib/core.cjs",
33
+ "module": "lib/core.js",
34
+ "types": "lib/core.d.ts",
35
+ "files": [
36
+ "lib",
37
+ "README.md",
38
+ "CHANGELOG.md",
39
+ "LICENSE"
40
+ ],
25
41
  "dependencies": {
26
- "@ts-graphviz/ast": "^0.0.0-pr956-20240225073457",
27
- "@ts-graphviz/common": "^0.0.0-pr956-20240225073457"
42
+ "@ts-graphviz/ast": "^0.0.0-pr956-20240225091623",
43
+ "@ts-graphviz/common": "^0.0.0-pr956-20240225091623"
28
44
  },
29
45
  "devDependencies": {
30
46
  "typescript": "^5.3.3",
31
47
  "vite": "^5.1.3",
32
48
  "vite-plugin-dts": "^3.7.2"
33
49
  },
50
+ "engines": {
51
+ "node": ">=18"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "provenance": true
56
+ },
34
57
  "scripts": {
35
58
  "build": "vite build"
36
59
  }
package/src/attribute.ts DELETED
@@ -1,18 +0,0 @@
1
- import { Attribute } from '@ts-graphviz/common';
2
-
3
- /**
4
- * @group Attribute
5
- *
6
- * @deprecated Use {@link Attribute.keys} instead.
7
- */
8
- export type AttributeKeyDict = Attribute.keys;
9
-
10
- /**
11
- * @group Attribute
12
- */
13
- export const attribute: Attribute.keys = new Proxy(
14
- Object.freeze({}) as Attribute.keys,
15
- {
16
- get: (_, key: string) => key,
17
- },
18
- );
package/src/core.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './attribute.js';
2
- export * from './models/index.js';
3
- export * from './model-factory/index.js';
4
- export * from './to-dot.js';
5
- export * from './from-dot.js';
package/src/from-dot.ts DELETED
@@ -1,73 +0,0 @@
1
- import {
2
- ConvertToModelOptions,
3
- ParseOptions,
4
- parse,
5
- toModel,
6
- } from '@ts-graphviz/ast';
7
- import {
8
- EdgeModel,
9
- NodeModel,
10
- RootGraphModel,
11
- SubgraphModel,
12
- } from '@ts-graphviz/common';
13
-
14
- /**
15
- * This interface provides options for converting DOT to a model.
16
- * @group Convert DOT to Model
17
- */
18
- export interface FromDotOptions<
19
- T extends 'Dot' | 'Graph' | 'Node' | 'Edge' | 'Subgraph',
20
- > {
21
- /**
22
- * Options for parsing DOT.
23
- */
24
- parse?: ParseOptions<T>;
25
- /**
26
- * Options for converting the parsed DOT to a model.
27
- */
28
- convert?: ConvertToModelOptions;
29
- }
30
-
31
- /**
32
- * fromDot is a function that converts a DOT string to a model.
33
- *
34
- * @group Convert DOT to Model
35
- *
36
- * @param dot The DOT string to convert.
37
- * @param options Options for converting the DOT string to a model.
38
- * @returns A model of type {@link RootGraphModel}, {@link NodeModel}, {@link EdgeModel}, or {@link SubgraphModel},
39
- * depending on the type specified in the options.
40
- */
41
- export function fromDot(
42
- dot: string,
43
- options?: FromDotOptions<'Dot' | 'Graph'>,
44
- ): RootGraphModel;
45
- export function fromDot(
46
- dot: string,
47
- options?: FromDotOptions<'Node'>,
48
- ): NodeModel;
49
- export function fromDot(
50
- dot: string,
51
- options?: FromDotOptions<'Edge'>,
52
- ): EdgeModel;
53
- export function fromDot(
54
- dot: string,
55
- options?: FromDotOptions<'Subgraph'>,
56
- ): SubgraphModel;
57
- export function fromDot<
58
- T extends 'Dot' | 'Graph' | 'Node' | 'Edge' | 'Subgraph',
59
- >(dot: string, options?: FromDotOptions<T>) {
60
- const ast = parse(dot, options?.parse);
61
- if (
62
- Array.isArray(ast) ||
63
- ast.type === 'Attribute' ||
64
- ast.type === 'AttributeList' ||
65
- ast.type === 'Comment' ||
66
- ast.type === 'NodeRef' ||
67
- ast.type === 'NodeRefGroup' ||
68
- ast.type === 'Literal'
69
- ) {
70
- throw new Error();
71
- }
72
- return toModel(ast, options?.convert);
73
- }
@@ -1,2 +0,0 @@
1
- export * from './types.js';
2
- export * from './model-factory.js';
@@ -1,79 +0,0 @@
1
- import { describe, expect, test, vi } from 'vitest';
2
-
3
- import { RootModelsContext } from '@ts-graphviz/common';
4
- import { attribute as _ } from '../attribute.js';
5
- import '../models/registerModelContext.js';
6
- import { ModelFactoryBuilder } from './model-factory-builder.js';
7
-
8
- describe.each([
9
- { directed: true, strict: true },
10
- { directed: false, strict: true },
11
- { directed: false, strict: false },
12
- { directed: true, strict: false },
13
- ])('strict: %s, directed: %s', ({ strict, directed }) => {
14
- const factory = ModelFactoryBuilder.call(RootModelsContext, directed, strict);
15
-
16
- test('no arguments', () => {
17
- const g = factory();
18
- expect(g.directed).toStrictEqual(directed);
19
- expect(g.strict).toStrictEqual(strict);
20
- });
21
-
22
- test('first argument is id', () => {
23
- const g = factory('foo');
24
- expect(g.id).toStrictEqual('foo');
25
-
26
- expect(g.directed).toStrictEqual(directed);
27
- expect(g.strict).toStrictEqual(strict);
28
- });
29
-
30
- test('first argument is callback', () => {
31
- const callback = vi.fn();
32
- const g = factory(callback);
33
- expect(g.id).toBeUndefined();
34
- expect(callback).toHaveBeenCalledWith(g);
35
-
36
- expect(g.directed).toStrictEqual(directed);
37
- expect(g.strict).toStrictEqual(strict);
38
- });
39
-
40
- test('first argument is attribute object', () => {
41
- const g = factory({ [_.label]: 'Test label' });
42
- expect(g.id).toBeUndefined();
43
- expect(g.values).toStrictEqual([[_.label, 'Test label']]);
44
-
45
- expect(g.directed).toStrictEqual(directed);
46
- expect(g.strict).toStrictEqual(strict);
47
- });
48
-
49
- test('first argument is attribute object, seccond argument is callback', () => {
50
- const callback = vi.fn();
51
- const g = factory({ [_.label]: 'Test label' }, callback);
52
- expect(g.id).toBeUndefined();
53
- expect(g.values).toStrictEqual([[_.label, 'Test label']]);
54
- expect(callback).toHaveBeenCalledWith(g);
55
-
56
- expect(g.directed).toStrictEqual(directed);
57
- expect(g.strict).toStrictEqual(strict);
58
- });
59
-
60
- test('first argument is id, seccond argument is attribute object', () => {
61
- const g = factory('foo', { [_.label]: 'Test label' });
62
- expect(g.id).toStrictEqual('foo');
63
- expect(g.values).toStrictEqual([[_.label, 'Test label']]);
64
-
65
- expect(g.directed).toStrictEqual(directed);
66
- expect(g.strict).toStrictEqual(strict);
67
- });
68
-
69
- test('first argument is id, seccond argument is attribute object, third arguments is callback', () => {
70
- const callback = vi.fn();
71
- const g = factory('foo', { [_.label]: 'Test label' }, callback);
72
- expect(g.id).toStrictEqual('foo');
73
- expect(g.values).toStrictEqual([[_.label, 'Test label']]);
74
- expect(callback).toHaveBeenCalledWith(g);
75
-
76
- expect(g.directed).toStrictEqual(directed);
77
- expect(g.strict).toStrictEqual(strict);
78
- });
79
- });
@@ -1,55 +0,0 @@
1
- import {
2
- GraphAttributesObject,
3
- ModelsContext,
4
- RootGraphModel,
5
- RootModelsContext,
6
- } from '@ts-graphviz/common';
7
- import { ModelFactory } from './types.js';
8
-
9
- /**
10
- * ModelFactoryBuilder is a function that takes two parameters, directed and strictMode, and returns a ModelFactory.
11
- *
12
- * @param directed A boolean value indicating whether the graph should be directed or not.
13
- * @param strictMode A boolean value indicating whether the graph should be in strict mode or not.
14
- * @returns A ModelFactory that takes an array of unknowns as parameters and returns a RootGraphModel.
15
- * @hidden
16
- */
17
- export function ModelFactoryBuilder(
18
- this: ModelsContext,
19
- directed: boolean,
20
- strictMode: boolean,
21
- ): ModelFactory {
22
- return (...args: unknown[]) => {
23
- const G = directed ? this.Digraph : this.Graph;
24
- const id = args.find((arg): arg is string => typeof arg === 'string');
25
- const attributes = args.find(
26
- (arg): arg is GraphAttributesObject => typeof arg === 'object',
27
- );
28
- const callback = args.find(
29
- (arg): arg is (g: RootGraphModel) => void => typeof arg === 'function',
30
- );
31
- const g = new G(id, strictMode, attributes);
32
- g.with(this);
33
- if (typeof callback === 'function') {
34
- callback(g);
35
- }
36
- return g;
37
- };
38
- }
39
-
40
- /**
41
- * createModelFactories is a function that takes a boolean value, strict, and an optional ModelsContext parameter, context, and returns an object containing two ModelFactories.
42
- *
43
- * @param strict A boolean value indicating whether the graph should be in strict mode or not.
44
- * @param context An optional ModelsContext parameter.
45
- * @returns An object containing two ModelFactories, one for directed graphs and one for undirected graphs.
46
- */
47
- export function createModelFactories(
48
- strict: boolean,
49
- context: ModelsContext = RootModelsContext,
50
- ) {
51
- return Object.freeze({
52
- digraph: ModelFactoryBuilder.call(context, true, strict),
53
- graph: ModelFactoryBuilder.call(context, false, strict),
54
- });
55
- }
@@ -1,61 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { Digraph, Graph } from '../models/index.js';
3
- import { digraph, graph, strict, withContext } from './model-factory.js';
4
-
5
- test('digraph function returns an object of Digraph, and the strict property is false', () => {
6
- const g = digraph();
7
- expect(g).toBeInstanceOf(Digraph);
8
- expect(g.strict).toStrictEqual(false);
9
- });
10
-
11
- test('graph function returns an object of Graph, and the strict property is false', () => {
12
- const g = graph();
13
- expect(g).toBeInstanceOf(Graph);
14
- expect(g.strict).toStrictEqual(false);
15
- });
16
-
17
- test('strict.digraph function returns an object of Digraph', () => {
18
- const g = strict.digraph();
19
- expect(g).toBeInstanceOf(Digraph);
20
- expect(g.strict).toStrictEqual(true);
21
- });
22
-
23
- test('strict.graph function returns an object of Graph', () => {
24
- const g = strict.graph();
25
- expect(g).toBeInstanceOf(Graph);
26
- expect(g.strict).toStrictEqual(true);
27
- });
28
-
29
- describe('withContext function allows the class RootGraph to be generated with a custom class.', () => {
30
- class TestDigraph extends Digraph {}
31
- class TestGraph extends Graph {}
32
-
33
- const { digraph, graph, strict } = withContext({
34
- Digraph: TestDigraph,
35
- Graph: TestGraph,
36
- });
37
-
38
- test('digraph function returns an object of TestDigraph, and the strict property is false', () => {
39
- const g = digraph();
40
- expect(g).toBeInstanceOf(TestDigraph);
41
- expect(g.strict).toStrictEqual(false);
42
- });
43
-
44
- test('graph function returns an object of TestGraph, and the strict property is false', () => {
45
- const g = graph();
46
- expect(g).toBeInstanceOf(TestGraph);
47
- expect(g.strict).toStrictEqual(false);
48
- });
49
-
50
- test('strict.digraph function returns an object of TestDigraph', () => {
51
- const g = strict.digraph();
52
- expect(g).toBeInstanceOf(TestDigraph);
53
- expect(g.strict).toStrictEqual(true);
54
- });
55
-
56
- test('strict.graph function returns an object of TestGraph', () => {
57
- const g = strict.graph();
58
- expect(g).toBeInstanceOf(TestGraph);
59
- expect(g.strict).toStrictEqual(true);
60
- });
61
- });
@@ -1,40 +0,0 @@
1
- import { ModelsContext, createModelsContext } from '@ts-graphviz/common';
2
- import { createModelFactories } from './model-factory-builder.js';
3
- import { ModelFactories, ModelFactoriesWithStrict } from './types.js';
4
-
5
- const noStrict: ModelFactories = createModelFactories(false);
6
-
7
- /**
8
- * digraph is a factory for creating Digraph objects.
9
- * @group Model Factory
10
- */
11
- export const digraph = noStrict.digraph;
12
-
13
- /**
14
- * graph is a factory for creating Graph objects.
15
- * @group Model Factory
16
- */
17
- export const graph = noStrict.graph;
18
-
19
- /**
20
- * Provides a strict mode API.
21
- * @group Model Factory
22
- */
23
- export const strict: ModelFactories = createModelFactories(true);
24
-
25
- /**
26
- * withContext creates a {@link ModelFactoriesWithStrict} object with the given context.
27
- *
28
- * @param models - An object containing the models to be used in the context.
29
- *
30
- * @returns A ModelFactoriesWithStrict object containing the factories. * @group Model Factory
31
- */
32
- export function withContext(
33
- models: Partial<ModelsContext>,
34
- ): ModelFactoriesWithStrict {
35
- const context = createModelsContext(models);
36
- return Object.freeze({
37
- ...createModelFactories(false, context),
38
- strict: createModelFactories(true, context),
39
- });
40
- }
@@ -1,46 +0,0 @@
1
- import { GraphAttributesObject, RootGraphModel } from '@ts-graphviz/common';
2
-
3
- /**
4
- * ModelFactory is an interface that provides a way to create a {@link RootGraphModel} object.
5
- *
6
- * @param id - Optional string parameter that specifies the id of the {@link RootGraphModel} object.
7
- * @param attributes - Optional GraphAttributesObject parameter that specifies the attributes of the {@link RootGraphModel} object.
8
- * @param callback - Optional callback function that takes a {@link RootGraphModel} object as a parameter.
9
- *
10
- * @returns {@link RootGraphModel} - Returns a {@link RootGraphModel} object.
11
- * @group Model Factory
12
- */
13
- export interface ModelFactory {
14
- (
15
- id?: string,
16
- attributes?: GraphAttributesObject,
17
- callback?: (g: RootGraphModel) => void,
18
- ): RootGraphModel;
19
- (
20
- attributes?: GraphAttributesObject,
21
- callback?: (g: RootGraphModel) => void,
22
- ): RootGraphModel;
23
- (id?: string, callback?: (g: RootGraphModel) => void): RootGraphModel;
24
- (callback?: (g: RootGraphModel) => void): RootGraphModel;
25
- }
26
-
27
- /**
28
- * @group Model Factory
29
- */
30
- export interface ModelFactories {
31
- /**
32
- * API for creating directional graph objects.
33
- */
34
- digraph: ModelFactory;
35
- /**
36
- * API for creating omnidirectional graph objects.
37
- */
38
- graph: ModelFactory;
39
- }
40
-
41
- /**
42
- * @group Model Factory
43
- */
44
- export interface ModelFactoriesWithStrict extends ModelFactories {
45
- strict: ModelFactories;
46
- }
@@ -1,58 +0,0 @@
1
- import { AttributeListKind } from '@ts-graphviz/common';
2
- import { beforeEach, describe, expect, it, test } from 'vitest';
3
- import { attribute as _ } from '../attribute.js';
4
- import { AttributeList } from './AttributeList.js';
5
- import { AttributesBase } from './AttributesBase.js';
6
- import { DotObject } from './DotObject.js';
7
-
8
- let attrs: AttributeList<AttributeListKind>;
9
- beforeEach(() => {
10
- attrs = new AttributeList('Node');
11
- });
12
-
13
- describe('object', () => {
14
- it('should be instance of AttributeList/AttributesBase/DotObject', () => {
15
- expect(attrs).toBeInstanceOf(AttributeList);
16
- expect(attrs).toBeInstanceOf(AttributesBase);
17
- expect(attrs).toBeInstanceOf(DotObject);
18
- });
19
-
20
- it('size should be 0 by default', () => {
21
- expect(attrs.size).toBe(0);
22
- });
23
-
24
- it('$$type property should returns "AttributeList"', () => {
25
- expect(attrs.$$type).toStrictEqual('AttributeList');
26
- });
27
- });
28
-
29
- describe('constructor', () => {
30
- describe('1st argument is kind of AttributeList', () => {
31
- test.each(['Node', 'Edge', 'Graph'] as AttributeListKind[])(
32
- 'AttributeList kind is %s',
33
- (kind) => {
34
- attrs = new AttributeList(kind);
35
- expect(attrs.$$kind).toStrictEqual(kind);
36
- },
37
- );
38
- });
39
-
40
- test('2nd argument is attribute object', () => {
41
- attrs = new AttributeList('Node', {
42
- [_.label]: 'Label',
43
- });
44
- expect(attrs.size).toBe(1);
45
- expect(attrs.get(_.label)).toBe('Label');
46
- });
47
- });
48
-
49
- describe('comment', () => {
50
- test('default value to be undefined', () => {
51
- expect(attrs.comment).toBeUndefined();
52
- });
53
-
54
- test('comment can be set', () => {
55
- attrs.comment = 'test';
56
- expect(attrs.comment).toStrictEqual('test');
57
- });
58
- });
@@ -1,32 +0,0 @@
1
- import {
2
- AttributeKey,
3
- AttributeListKind,
4
- AttributeListModel,
5
- AttributesObject,
6
- } from '@ts-graphviz/common';
7
- import { AttributesBase } from './AttributesBase.js';
8
-
9
- /**
10
- * A set of attribute values for any object.
11
- * @group Models
12
- */
13
- export class AttributeList<
14
- K extends AttributeListKind,
15
- T extends AttributeKey = AttributeKey,
16
- >
17
- extends AttributesBase<T>
18
- implements AttributeListModel<K, T>
19
- {
20
- public get $$type(): 'AttributeList' {
21
- return 'AttributeList';
22
- }
23
-
24
- public comment?: string;
25
-
26
- constructor(
27
- public readonly $$kind: K,
28
- attributes?: AttributesObject<T>,
29
- ) {
30
- super(attributes);
31
- }
32
- }
@@ -1,79 +0,0 @@
1
- import { Attributes } from '@ts-graphviz/common';
2
- import { beforeEach, describe, expect, it, test } from 'vitest';
3
- import { attribute as _ } from '../attribute.js';
4
- import { AttributesBase } from './AttributesBase.js';
5
- import { DotObject } from './DotObject.js';
6
-
7
- class TestAttributes extends AttributesBase<any> {}
8
-
9
- let attrs: Attributes<any>;
10
- beforeEach(() => {
11
- attrs = new TestAttributes();
12
- });
13
-
14
- describe('object', () => {
15
- it('should be instance of AttributesBase/DotObject', () => {
16
- expect(attrs).toBeInstanceOf(DotObject);
17
- expect(attrs).toBeInstanceOf(AttributesBase);
18
- });
19
-
20
- it('size should be 0 by default', () => {
21
- expect(attrs.size).toBe(0);
22
- });
23
- });
24
-
25
- describe('constructor', () => {
26
- test('with no attribute object', () => {
27
- attrs = new TestAttributes();
28
- expect(attrs.size).toBe(0);
29
- expect(attrs.get(_.label)).toBeUndefined();
30
- });
31
-
32
- test('with attribute object', () => {
33
- attrs = new TestAttributes({
34
- [_.label]: 'Label',
35
- });
36
- expect(attrs.size).toBe(1);
37
- expect(attrs.get(_.label)).toBe('Label');
38
- });
39
- });
40
-
41
- describe('apply method', () => {
42
- test('with attributes object', () => {
43
- attrs.apply({
44
- [_.label]: 'this is test',
45
- [_.color]: 'red',
46
- [_.fontsize]: 16,
47
- });
48
- expect(attrs.size).toBe(3);
49
- });
50
-
51
- test('with attributes entities', () => {
52
- attrs.apply([
53
- [_.label, 'this is test'],
54
- [_.color, 'red'],
55
- [_.fontsize, 16],
56
- ]);
57
- expect(attrs.size).toBe(3);
58
- });
59
- });
60
-
61
- test('clear method', () => {
62
- attrs = new TestAttributes({
63
- [_.label]: 'this is test',
64
- [_.color]: 'red',
65
- [_.fontsize]: 16,
66
- });
67
-
68
- expect(attrs.size).toBe(3);
69
- attrs.clear();
70
- expect(attrs.size).toBe(0);
71
- });
72
-
73
- test('set/get/delete methods', () => {
74
- const id = 'test';
75
- attrs.set('label', id);
76
- expect(attrs.get('label')).toBe(id);
77
- attrs.delete('label');
78
- expect(attrs.get('label')).toBeUndefined();
79
- });