From 88c28ce20822918b77a3cfa3f2071a7dbe5531d0 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Sun, 8 Sep 2019 17:26:23 +0200 Subject: [PATCH] refactor(ivy): migrate debug spec from render3 (#32621) Migrate the remaining `render3/debug_spec.ts` to `acceptance` PR Close #32621 --- packages/core/test/acceptance/debug_spec.ts | 35 +++++++++++++++++ packages/core/test/render3/debug_spec.ts | 42 --------------------- 2 files changed, 35 insertions(+), 42 deletions(-) create mode 100644 packages/core/test/acceptance/debug_spec.ts delete mode 100644 packages/core/test/render3/debug_spec.ts diff --git a/packages/core/test/acceptance/debug_spec.ts b/packages/core/test/acceptance/debug_spec.ts new file mode 100644 index 0000000000..d4bfa91531 --- /dev/null +++ b/packages/core/test/acceptance/debug_spec.ts @@ -0,0 +1,35 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {Component} from '@angular/core'; +import {getLContext} from '@angular/core/src/render3/context_discovery'; +import {LViewDebug, toDebug} from '@angular/core/src/render3/instructions/lview_debug'; +import {TestBed} from '@angular/core/testing'; +import {expect} from '@angular/platform-browser/testing/src/matchers'; +import {onlyInIvy} from '@angular/private/testing'; + +describe('Debug Representation', () => { + + onlyInIvy('Ivy specific').it('should generate a human readable version', () => { + + @Component({selector: 'my-comp', template: '
Hello World
'}) + class MyComponent { + } + + TestBed.configureTestingModule({declarations: [MyComponent]}); + const fixture = TestBed.createComponent(MyComponent); + fixture.detectChanges(); + + const hostView = toDebug(getLContext(fixture.componentInstance) !.lView); + expect(hostView.host).toEqual(null); + const myCompView = hostView.childViews[0] as LViewDebug; + expect(myCompView.host).toContain('
Hello World
'); + expect(myCompView.nodes ![0].html).toEqual('
'); + expect(myCompView.nodes ![0].nodes ![0].html).toEqual('Hello World'); + }); +}); diff --git a/packages/core/test/render3/debug_spec.ts b/packages/core/test/render3/debug_spec.ts deleted file mode 100644 index e636486736..0000000000 --- a/packages/core/test/render3/debug_spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -import {getLContext} from '../../src/render3/context_discovery'; -import {RenderFlags, ɵɵdefineComponent, ɵɵelementEnd, ɵɵelementStart, ɵɵtext} from '../../src/render3/index'; -import {LViewDebug, toDebug} from '../../src/render3/instructions/lview_debug'; - -import {ComponentFixture} from './render_util'; - -describe('Debug Representation', () => { - it('should generate a human readable version', () => { - class MyComponent { - static ngFactoryDef = () => new MyComponent(); - static ngComponentDef = ɵɵdefineComponent({ - type: MyComponent, - selectors: [['my-comp']], - vars: 0, - consts: 2, - template: function(rf: RenderFlags, ctx: MyComponent) { - if (rf == RenderFlags.Create) { - ɵɵelementStart(0, 'div', ['id', '123']); - ɵɵtext(1, 'Hello World'); - ɵɵelementEnd(); - } - } - }); - } - - const fixture = new ComponentFixture(MyComponent); - const hostView = toDebug(getLContext(fixture.component) !.lView); - expect(hostView.host).toEqual(null); - const myCompView = hostView.childViews[0] as LViewDebug; - expect(myCompView.host).toEqual('
Hello World
'); - expect(myCompView.nodes ![0].html).toEqual('
'); - expect(myCompView.nodes ![0].nodes ![0].html).toEqual('Hello World'); - }); -});