test(ivy): Add small_app spec for sprint #3 (#22018)

PR Close #22018
This commit is contained in:
Misko Hevery
2018-02-03 20:34:30 -08:00
committed by Victor Berchet
parent a63b764b54
commit ac2b04a5ab
21 changed files with 697 additions and 84 deletions

View File

@ -34,6 +34,7 @@ ts_library(
srcs = ["domino_typings.d.ts"] + glob(["*_spec.ts"]),
deps = [
"//packages:types",
"//packages/core/testing",
],
)

View File

@ -1,4 +1,7 @@
[
{
"name": "CLEAN_PROMISE"
},
{
"name": "EMPTY$1"
},
@ -32,6 +35,9 @@
{
"name": "createLView"
},
{
"name": "currentView"
},
{
"name": "domRendererFactory3"
},

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {withBody} from '@angular/core/testing';
import * as fs from 'fs';
import * as path from 'path';
@ -32,39 +33,22 @@ describe('treeshaking with uglify', () => {
it('should not contain zone.js', () => { expect(content).not.toContain('scheduleMicroTask'); });
describe('functional test in domino', () => {
let document: Document;
it('should render hello world when not minified',
withBody('<hello-world></hello-world>', () => {
require(path.join(PACKAGE, 'bundle.js'));
expect(document.body.textContent).toEqual('Hello World!');
}));
beforeEach(() => {
const window = domino.createWindow('', 'http://localhost');
(global as any).document = document = window.document;
// Trick to avoid Event patching from
// https://github.com/angular/angular/blob/7cf5e95ac9f0f2648beebf0d5bd9056b79946970/packages/platform-browser/src/dom/events/dom_events.ts#L112-L132
// It fails with Domino with TypeError: Cannot assign to read only property
// 'stopImmediatePropagation' of object '#<Event>'
(global as any).Event = null;
it('should render hello world when debug minified',
withBody('<hello-world></hello-world>', () => {
require(path.join(PACKAGE, 'bundle.min_debug.js'));
expect(document.body.textContent).toEqual('Hello World!');
}));
document.body.innerHTML = '<hello-world></hello-world>';
});
afterEach(() => {
(global as any).document = undefined;
(global as any).Element = undefined;
});
it('should render hello world when not minified', () => {
require(path.join(PACKAGE, 'bundle.js'));
expect(document.body.textContent).toEqual('Hello World!');
});
it('should render hello world when debug minified', () => {
require(path.join(PACKAGE, 'bundle.min_debug.js'));
expect(document.body.textContent).toEqual('Hello World!');
});
it('should render hello world when fully minified', () => {
require(path.join(PACKAGE, 'bundle.min.js'));
expect(document.body.textContent).toEqual('Hello World!');
});
it('should render hello world when fully minified',
withBody('<hello-world></hello-world>', () => {
require(path.join(PACKAGE, 'bundle.min.js'));
expect(document.body.textContent).toEqual('Hello World!');
}));
});
});