Skip to content

Commit

Permalink
Fixes for google3 import
Browse files Browse the repository at this point in the history
- tslint fixes
- swap from browser dynamic
- fix reference panel spec test
  • Loading branch information
jnthntatum committed Oct 25, 2023
1 parent 09f1666 commit 56760f2
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MatButtonModule } from '@angular/material/button';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatListModule } from '@angular/material/list';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ReferencePanelComponent } from './reference-panel-component';

describe('ReferencePanelComponent', () => {
Expand All @@ -24,7 +28,11 @@ describe('ReferencePanelComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ReferencePanelComponent ]
declarations: [ ReferencePanelComponent ],
imports: [
MatButtonModule, MatExpansionModule, MatListModule, MatFormFieldModule,
NoopAnimationsModule
]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ import { ReplExampleService, Example } from '../shared/repl-example-service';
const examples = new Map<string, Example>([
["hello-world",
{
"description":
``,
"request": {
commands: [
`"hello world!"`
]
}
}],
["variables", {
"description":
``,
"request": {
commands: [
`%let x = 10`,
Expand All @@ -39,8 +35,6 @@ const examples = new Map<string, Example>([
}
}],
["errors", {
"description":
``,
"request": {
commands: [
`%let x = 0`,
Expand All @@ -52,30 +46,26 @@ const examples = new Map<string, Example>([
}
}],
["extension-functions", {
"description":
``,
"request": {
commands: [
`%let string.prepend(prefix: string) : string -> prefix + this`,
`"def".prepend("abc")`,
`%let exp(base: double, exponent: int) : double ->
`%let exp(base: double, exponent: int) : double ->
{-2: 1.0 / base / base,
-1: 1.0 / base,
0: 1.0,
1: base,
2: base * base
2: base * base
}[exponent]`,
`exp(2.0, -2) == 0.25`,
]
}
}],
["json", {
"description":
``,
"request": {
commands: [
`%let now = timestamp("2001-01-01T00:00:01Z")`,
`%let sa_user = ""`,
`%let sa_user = "example-service"`,
`{'aud': 'my-project',
'exp': now + duration('300s'),
'extra_claims': {
Expand All @@ -90,8 +80,6 @@ const examples = new Map<string, Example>([
}
}],
["macros", {
"description":
``,
"request": {
commands: [
`[1, 2, 3, 4].exists(x, x > 3)`,
Expand All @@ -105,7 +93,6 @@ const examples = new Map<string, Example>([
}],
["optionals",
{
description: ``,
request: {
commands: [
`%option --extension "optional"`,
Expand All @@ -124,7 +111,6 @@ const examples = new Map<string, Example>([
[
"strings",
{
description: ``,
request: {
commands: [
`%option --extension "strings"`,
Expand All @@ -138,7 +124,6 @@ const examples = new Map<string, Example>([
[
"math",
{
description: ``,
request: {
commands: [
`%option --extension "math"`,
Expand All @@ -151,7 +136,6 @@ const examples = new Map<string, Example>([
[
"bind",
{
description: ``,
request: {
commands: [
`%option --extension "bindings"`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { ReplApiService, EvaluateResponse, EvaluateRequest, CommandResponse } from '../shared/repl-api-service';
import { Example, ReplExampleService } from '../shared/repl-example-service';

Expand All @@ -27,12 +27,16 @@ import { Example, ReplExampleService } from '../shared/repl-example-service';
templateUrl: './repl-console-component.html',
styleUrls: ['./repl-console-component.scss']
})
export class ReplConsoleComponent {
export class ReplConsoleComponent implements OnInit {
lastEvaluate: EvaluateResponse = {responses: [], evalTime: 0};
lastRequest: EvaluateRequest = {commands: []};

constructor (private readonly replService: ReplApiService, private readonly exampleService: ReplExampleService) {
exampleService.examplePosted$.subscribe({
constructor (
private readonly replService: ReplApiService,
private readonly exampleService: ReplExampleService) {}

ngOnInit() {
this.exampleService.examplePosted$.subscribe({
next: (ex: Example) => {
this.lastRequest = ex.request;
this.lastEvaluate = {responses: [], evalTime: 0};
Expand Down
22 changes: 19 additions & 3 deletions repl/appengine/web/src/app/shared/repl-example-service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { TestBed } from '@angular/core/testing';

import { Example, ReplExampleService } from './repl-example-service';
Expand All @@ -16,20 +32,20 @@ describe('ReplExampleService', () => {

it('should publish examples', () => {

let recorded_example: Example = {description: "", request: {commands: []}};
let recorded_example: Example = {request: {commands: []}};

service.examplePosted$.subscribe({
next: (example: Example) => {
recorded_example = example;
}
});

service.postExample({description: "description", request: {
service.postExample({request: {
commands: [
"%status"
]
}});

expect(recorded_example.description).toBe("description");
expect(recorded_example.request.commands).toHaveSize(1);
});
});
17 changes: 16 additions & 1 deletion repl/appengine/web/src/app/shared/repl-example-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { EvaluateRequest } from './repl-api-service';
Expand All @@ -6,7 +22,6 @@ import { EvaluateRequest } from './repl-api-service';
* Representation of an example REPL session.
*/
export declare interface Example {
description: string;
request: EvaluateRequest;
}

Expand Down
4 changes: 2 additions & 2 deletions repl/appengine/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';

import { AppModule } from './app/app-module';


platformBrowserDynamic().bootstrapModule(AppModule)
platformBrowser().bootstrapModule(AppModule)
.catch(err => {console.error(err);});

0 comments on commit 56760f2

Please sign in to comment.