vsn 0.1.145 → 0.1.147

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.
@@ -1,5 +1,19 @@
1
1
  import {Tree} from "../../src/AST";
2
2
  import {Scope} from "../../src/Scope";
3
+ import {Registry} from "../../src/Registry";
4
+ import {DOM, Service, Tag} from "../../src/vsn";
5
+
6
+
7
+ @Registry.service('FunctionNodeScopeTestService')
8
+ class FunctionNodeScopeTestController extends Service {
9
+ test1() {
10
+ return this.test2();
11
+ }
12
+
13
+ test2() {
14
+ return 99;
15
+ }
16
+ }
3
17
 
4
18
 
5
19
  describe('FunctionNode', () => {
@@ -20,4 +34,18 @@ describe('FunctionNode', () => {
20
34
  const v = await tree.evaluate(scope, null, null);
21
35
  expect(v).toBe(3);
22
36
  });
37
+
38
+ it("methods should be callable with correct binding", async () => {
39
+ document.body.innerHTML = `
40
+ <div id="service-test" vsn-service:test="FunctionNodeScopeTestService"></div>
41
+ `;
42
+ const dom = new DOM(document.body);
43
+ await new Promise((resolve, reject) => {
44
+ dom.once('built', async () => {
45
+ const result = await dom.exec('test.test1()');
46
+ expect(result).toBe(99);
47
+ resolve(null);
48
+ });
49
+ });
50
+ });
23
51
  });
@@ -35,14 +35,6 @@ describe('Controller', () => {
35
35
  const tag = await dom.exec('#controller');
36
36
  expect(tag).toBeInstanceOf(Tag);
37
37
  expect(tag.scope).toBeInstanceOf(Scope);
38
- /*
39
- expect(tag.scope.keys).toEqual(['test']);
40
- expect(tag.scope.get('test').wrapped).toBeInstanceOf(TestController);
41
- expect(await tag.exec('test.isValid()')).toBe(false);
42
- expect(await tag.exec('test.test')).toBe('notTest');
43
- await tag.exec('test.test = "test"');
44
- expect(await tag.exec('test.isValid()')).toBe(true);
45
- */
46
38
  resolve(null);
47
39
  });
48
40
  });