Skip to content

Commit 64c3ced

Browse files
committed
Completed @kephas/ngx-ace
1 parent b975854 commit 64c3ced

File tree

13 files changed

+574
-92
lines changed

13 files changed

+574
-92
lines changed

src/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@
3535
"@angular/compiler-cli": "~12.2.3",
3636
"@types/jasmine": "~3.8.2",
3737
"@types/node": "^16.7.8",
38+
"brace": "^0.11.1",
3839
"codelyzer": "^6.0.2",
3940
"jasmine-core": "~3.9.0",
4041
"jasmine-spec-reporter": "~7.0.0",
42+
"js-sha256": "^0.9.0",
4143
"karma": "~6.3.4",
4244
"karma-chrome-launcher": "~3.1.0",
4345
"karma-coverage": "~2.0.3",

src/projects/kephas/ngx-ace/ng-package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
33
"dest": "../../../dist/kephas/ngx-ace",
44
"lib": {
5-
"entryFile": "src/public-api.ts"
5+
"entryFile": "src/public-api.ts",
6+
"umdModuleIds": {
7+
"@kephas/ngx-core": "@kephas/ngx-core",
8+
"@kephas/core": "@kephas/core",
9+
"@kephas/commands": "@kephas/commands",
10+
"@kephas/messaging": "@kephas/messaging",
11+
"@kephas/ui": "@kephas/ui",
12+
"brace": "brace",
13+
"jwt-decode": "jwt-decode"
14+
}
615
}
7-
}
16+
}

src/projects/kephas/ngx-ace/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"peerDependencies": {
2020
"@angular/common": "^12.2.0",
2121
"@angular/core": "^12.2.0",
22+
"@angular/platform-browser": "^12.2.0",
2223
"@kephas/commands": "^1.0.0-preview.1",
2324
"@kephas/core": "^1.0.0-preview.1",
2425
"@kephas/messaging": "^1.0.0-preview.1",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { NgModule } from '@angular/core';
3+
import { AceComponent } from './components/ace.component';
4+
5+
6+
@NgModule({
7+
declarations: [
8+
AceComponent,
9+
],
10+
exports: [
11+
AceComponent,
12+
],
13+
imports: [
14+
BrowserModule,
15+
],
16+
})
17+
export class AceModule { }
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
//#region ZoneSetup
2+
3+
import 'zone.js/dist/zone';
4+
import 'zone.js/dist/long-stack-trace-zone';
5+
import 'zone.js/dist/async-test';
6+
import 'zone.js/dist/fake-async-test';
7+
import 'zone.js/dist/sync-test';
8+
import 'zone.js/dist/proxy';
9+
10+
//#endregion
11+
12+
//#region Simulate window in node.js
13+
14+
import { JSDOM } from 'jsdom';
15+
16+
const window = (new JSDOM('<!doctype html><html><body></body></html>')).window;
17+
const document = window.document;
18+
const testGlobal: any = global;
19+
testGlobal.window = window;
20+
testGlobal.document = document;
21+
testGlobal.Document = document;
22+
testGlobal.HTMLElement = window.HTMLElement;
23+
testGlobal.XMLHttpRequest = window.XMLHttpRequest;
24+
testGlobal.Node = window.Node;
25+
testGlobal.Event = window.Event;
26+
testGlobal.Element = window.Element;
27+
testGlobal.navigator = window.navigator;
28+
testGlobal.KeyboardEvent = window.KeyboardEvent;
29+
30+
testGlobal.localStorage = {
31+
store: {},
32+
33+
getItem(key: any) {
34+
return this.store[key] || null;
35+
},
36+
setItem(key: any, value: any) {
37+
this.store[key] = value;
38+
},
39+
clear() {
40+
this.store = {};
41+
}
42+
};
43+
44+
testGlobal.sessionStorage = {
45+
store: {},
46+
47+
getItem(key: any) {
48+
return this.store[key] || null;
49+
},
50+
setItem(key: any, value: any) {
51+
this.store[key] = value;
52+
},
53+
clear() {
54+
this.store = {};
55+
}
56+
};
57+
58+
// https://github.com/angular/material2/issues/7101
59+
Object.defineProperty(
60+
document.body.style,
61+
'transform',
62+
{
63+
value: () => ({ enumerable: true, configurable: true })
64+
});
65+
66+
//#endregion
67+
68+
// //#region Mocha setup
69+
70+
// import * as Mocha from 'mocha';
71+
72+
// testGlobal.Mocha = testGlobal.Mocha ?? Mocha;
73+
// testGlobal.window.Mocha = testGlobal.window.Mocha ?? testGlobal.Mocha ?? Mocha;
74+
// testGlobal.window.Zone = testGlobal.window.Zone ?? testGlobal.Zone;
75+
76+
// import 'zone.js/dist/mocha-patch';
77+
78+
// //#endregion
79+
80+
import { expect } from 'chai';
81+
import 'mocha';
82+
83+
import { AceComponent } from '..';
84+
import { AppServiceInfoRegistry } from '@kephas/core';
85+
import { AngularAppServiceInfoRegistry } from '@kephas/ngx-core';
86+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
87+
88+
describe('AceComponent.constructor', () => {
89+
let component: AceComponent;
90+
let fixture: ComponentFixture<AceComponent>;
91+
92+
beforeEach(async(() => {
93+
const angularRegistry = new AngularAppServiceInfoRegistry(AppServiceInfoRegistry.Instance);
94+
return TestBed.configureTestingModule(
95+
{
96+
declarations: [AceComponent],
97+
providers: angularRegistry.getRootProviders(),
98+
})
99+
.compileComponents();
100+
}));
101+
102+
beforeEach(() => {
103+
fixture = TestBed.createComponent(AceComponent);
104+
component = fixture.componentInstance;
105+
fixture.detectChanges();
106+
});
107+
108+
it('should initialize editor type', () => {
109+
const widget = fixture.componentRef.instance;
110+
expect(widget.editorType).is.equal('json');
111+
});
112+
});

0 commit comments

Comments
 (0)