|
| 1 | +import { builders as b } from '@glimmer/syntax'; |
| 2 | + |
| 3 | +QUnit.module('[glimmer-syntax] AST nodes legacy interop'); |
| 4 | + |
| 5 | +QUnit.test('path.parts does not include this', (assert) => { |
| 6 | + let path = b.path('this.foo.bar'); |
| 7 | + |
| 8 | + assert.deepEqual(path.original, 'this.foo.bar', 'path.original should include this'); |
| 9 | + assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); |
| 10 | + assert.deepEqual(path.parts, ['foo', 'bar'], 'path.parts should not include this'); |
| 11 | + |
| 12 | + path.parts = ['bar', 'baz']; |
| 13 | + |
| 14 | + assert.deepEqual(path.original, 'this.bar.baz', 'path.original should include this'); |
| 15 | + assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); |
| 16 | + assert.deepEqual(path.parts, ['bar', 'baz'], 'path.parts should not include this'); |
| 17 | + |
| 18 | + path.head = b.head('@foo'); |
| 19 | + assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); |
| 20 | + |
| 21 | + // Inconsistent, but we will allow it |
| 22 | + path.parts = ['this', 'foo', 'bar', 'baz']; |
| 23 | + |
| 24 | + assert.deepEqual(path.original, 'this.foo.bar.baz', 'path.original should include this'); |
| 25 | + assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); |
| 26 | + assert.deepEqual(path.parts, ['foo', 'bar', 'baz'], 'path.parts should not include this'); |
| 27 | +}); |
| 28 | + |
| 29 | +QUnit.test('path.parts does not include @', (assert) => { |
| 30 | + let path = b.path('@foo.bar'); |
| 31 | + |
| 32 | + assert.deepEqual(path.original, '@foo.bar', 'path.original should include @'); |
| 33 | + assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); |
| 34 | + assert.deepEqual(path.parts, ['foo', 'bar'], 'path.parts should not include @'); |
| 35 | + |
| 36 | + path.parts = ['bar', 'baz']; |
| 37 | + |
| 38 | + assert.deepEqual(path.original, '@bar.baz', 'path.original should include @'); |
| 39 | + assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); |
| 40 | + assert.deepEqual(path.parts, ['bar', 'baz'], 'path.parts should not include @'); |
| 41 | + |
| 42 | + path.head = b.head('this'); |
| 43 | + assert.deepEqual(path.head.type, 'ThisHead', 'path.head should be a ThisHead'); |
| 44 | + |
| 45 | + // Inconsistent, but we will allow it |
| 46 | + path.parts = ['@foo', 'bar', 'baz']; |
| 47 | + |
| 48 | + assert.deepEqual(path.original, '@foo.bar.baz', 'path.original should include @'); |
| 49 | + assert.deepEqual(path.head.type, 'AtHead', 'path.head should be a AtHead'); |
| 50 | + assert.deepEqual(path.parts, ['foo', 'bar', 'baz'], 'path.parts should not include this'); |
| 51 | +}); |
0 commit comments