test(ivy): make sure `goog.getMsg()` is defined before being used (#22998)
PR Close #22998
This commit is contained in:
parent
ab348ee2be
commit
d28ce50067
|
@ -27,7 +27,7 @@
|
|||
"name": "HelloWorld"
|
||||
},
|
||||
{
|
||||
"name": "INeedToExistEvenThoughtIAmNotNeeded"
|
||||
"name": "INeedToExistEvenThoughIAmNotNeeded"
|
||||
},
|
||||
{
|
||||
"name": "Immediate"
|
||||
|
|
|
@ -14,7 +14,7 @@ export class HelloWorld {
|
|||
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
|
||||
|
||||
@NgModule({declarations: [HelloWorld]})
|
||||
export class INeedToExistEvenThoughtIAmNotNeeded {
|
||||
export class INeedToExistEvenThoughIAmNotNeeded {
|
||||
}
|
||||
// TODO(misko): Package should not be required to make this work.
|
||||
|
||||
|
|
|
@ -14,7 +14,12 @@ ivy_ng_module(
|
|||
|
||||
ng_rollup_bundle(
|
||||
name = "bundle",
|
||||
# Remove once #22913 lands
|
||||
# TODO(alexeagle): This is inconsistent.
|
||||
# We try to teach users to always have their workspace at the start of a
|
||||
# path, to disambiguate from other workspaces.
|
||||
# Here, the rule implementation is looking in an execroot where the layout
|
||||
# has an "external" directory for external dependencies.
|
||||
# This should probably start with "angular/" and let the rule deal with it.
|
||||
entry_point = "packages/core/test/bundling/hello_world_i18n/index.js",
|
||||
deps = [
|
||||
":hello_world_i18n",
|
||||
|
@ -29,8 +34,5 @@ ts_devserver(
|
|||
":bundle.min.js",
|
||||
"index.html",
|
||||
],
|
||||
deps = [
|
||||
# fix for ibazel until https://github.com/angular/angular/pull/22912 gets merged
|
||||
"//packages/compiler",
|
||||
],
|
||||
deps = [],
|
||||
)
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
property renaming.
|
||||
-->
|
||||
<script>
|
||||
// `goog.getMsg()` will be provided by Closure
|
||||
const translations = {
|
||||
'Hello World!': 'Bonjour Monde!',
|
||||
'Hello Title!': 'Bonjour Titre!',
|
||||
};
|
||||
window.goog = window.goog || {};
|
||||
window.goog.getMsg = (key) => translations[key] || key;
|
||||
|
||||
document.write('<script src="' +
|
||||
(document.location.search.endsWith('debug') ? '/bundle.min_debug.js' : '/bundle.min.js') +
|
||||
'"></' + 'script>');
|
||||
|
|
|
@ -8,15 +8,6 @@
|
|||
|
||||
import {Component, NgModule, ɵrenderComponent as renderComponent} from '@angular/core';
|
||||
|
||||
// simulate translations for now
|
||||
const translations: {[key: string]: string} = {
|
||||
'Hello World!': 'Bonjour Monde!',
|
||||
'Hello Title!': 'Bonjour Titre!',
|
||||
};
|
||||
|
||||
// simulate Google Closure getMsg for now
|
||||
(window as any).goog = {getMsg: (key: string) => { return translations[key] || key; }};
|
||||
|
||||
@Component({
|
||||
selector: 'hello-world',
|
||||
template: `<div i18n i18n-title title="Hello Title!">Hello World!</div>`
|
||||
|
@ -26,7 +17,7 @@ export class HelloWorld {
|
|||
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
|
||||
|
||||
@NgModule({declarations: [HelloWorld]})
|
||||
export class INeedToExistEvenThoughtIAmNotNeeded {
|
||||
export class INeedToExistEvenThoughIAmNotNeeded {
|
||||
}
|
||||
// TODO(misko): Package should not be required to make this work.
|
||||
|
||||
|
|
Loading…
Reference in New Issue