@oncehub/knowledgeowl-angular 5.0.0-beta.2 → 5.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/esm2022/lib/index.mjs +3 -0
  2. package/esm2022/lib/knowledge-owl-link/knowledge-owl-link-module.mjs +18 -0
  3. package/esm2022/lib/knowledge-owl-link/knowledge-owl-link.mjs +92 -0
  4. package/esm2022/lib/knowledge-owl-link/knowledge-owl-widget-errors.mjs +3 -0
  5. package/esm2022/lib/knowledge-owl-link/public-api.mjs +3 -0
  6. package/esm2022/lib/knowledge-owl-widget/knowledge-owl-widget-errors.mjs +4 -0
  7. package/esm2022/lib/knowledge-owl-widget/knowledge-owl-widget-module.mjs +19 -0
  8. package/esm2022/lib/knowledge-owl-widget/knowledge-owl-widget.mjs +143 -0
  9. package/esm2022/lib/knowledge-owl-widget/public-api.mjs +3 -0
  10. package/esm2022/oncehub-knowledgeowl-angular.mjs +5 -0
  11. package/esm2022/public_api.mjs +2 -0
  12. package/fesm2022/oncehub-knowledgeowl-angular.mjs +275 -0
  13. package/fesm2022/oncehub-knowledgeowl-angular.mjs.map +1 -0
  14. package/index.d.ts +5 -0
  15. package/lib/knowledge-owl-link/knowledge-owl-link-module.d.ts +8 -0
  16. package/lib/knowledge-owl-link/knowledge-owl-link.d.ts +37 -0
  17. package/lib/knowledge-owl-link/knowledge-owl-widget-errors.d.ts +2 -0
  18. package/lib/knowledge-owl-widget/knowledge-owl-widget-errors.d.ts +3 -0
  19. package/lib/knowledge-owl-widget/knowledge-owl-widget-module.d.ts +8 -0
  20. package/lib/knowledge-owl-widget/knowledge-owl-widget.d.ts +63 -0
  21. package/package.json +23 -53
  22. package/.eslintrc.json +0 -82
  23. package/.github/workflows/ci.yml +0 -29
  24. package/.github/workflows/codeql-analysis.yml +0 -71
  25. package/.github/workflows/npm-publish.yml +0 -23
  26. package/.prettierignore +0 -2
  27. package/.prettierrc +0 -3
  28. package/CHANGELOG.md +0 -257
  29. package/LICENSE +0 -21
  30. package/OWNERS +0 -4
  31. package/OWNERS_ALIASES +0 -20
  32. package/angular.json +0 -55
  33. package/src/README.md +0 -5
  34. package/src/lib/knowledge-owl-link/index.ts +0 -1
  35. package/src/lib/knowledge-owl-link/knowledge-owl-link-module.ts +0 -10
  36. package/src/lib/knowledge-owl-link/knowledge-owl-link.spec.ts +0 -51
  37. package/src/lib/knowledge-owl-link/knowledge-owl-link.ts +0 -97
  38. package/src/lib/knowledge-owl-link/knowledge-owl-widget-errors.ts +0 -3
  39. package/src/lib/knowledge-owl-widget/index.ts +0 -1
  40. package/src/lib/knowledge-owl-widget/knowledge-owl-widget-errors.ts +0 -6
  41. package/src/lib/knowledge-owl-widget/knowledge-owl-widget-module.ts +0 -11
  42. package/src/lib/knowledge-owl-widget/knowledge-owl-widget.spec.ts +0 -66
  43. package/src/lib/knowledge-owl-widget/knowledge-owl-widget.ts +0 -162
  44. package/src/lib/tsconfig.json +0 -10
  45. package/src/ng-package.json +0 -7
  46. package/src/package-lock.json +0 -111
  47. package/src/package.json +0 -14
  48. package/src/polyfills.ts +0 -76
  49. package/src/tsconfig.lib.json +0 -30
  50. package/src/tsconfig.spec.json +0 -18
  51. package/test/karma.conf.js +0 -44
  52. package/test/test.ts +0 -18
  53. package/tsconfig.json +0 -35
  54. package/tsconfig.lib.prod.json +0 -9
  55. /package/{src/lib/index.ts → lib/index.d.ts} +0 -0
  56. /package/{src/lib/knowledge-owl-link/public-api.ts → lib/knowledge-owl-link/public-api.d.ts} +0 -0
  57. /package/{src/lib/knowledge-owl-widget/public-api.ts → lib/knowledge-owl-widget/public-api.d.ts} +0 -0
  58. /package/{src/public_api.ts → public_api.d.ts} +0 -0
package/CHANGELOG.md DELETED
@@ -1,257 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [4.1.4] - 2024-02-01
9
-
10
- - [ONCEHUB-77374](https://scheduleonce.atlassian.net/browse/ONCEHUB-77374) fixed vulnerability found in package vite
11
-
12
- ## [4.1.3] - 2023-09-29
13
-
14
- - [ONCEHUB-65303](https://scheduleonce.atlassian.net/browse/ONCEHUB-65303) Final upgrade to Angular version 16 on knowledge-owl
15
-
16
- ## [4.1.3-beta.0] - 2023-07-14
17
-
18
- - [ONCEHUB-65303] Upgrade Angular app to version 16 on knowledge-owl
19
-
20
- ## [4.1.2-beta.0] - 2023-06-16
21
-
22
- - [ONCEHUB-65303] Upgrade Angular app to version 15 on knowledge-owl
23
-
24
- ## [4.1.1] - 2023-06-14
25
-
26
- - [ONCEHUB-62023] engine.io, socket.io, socket.io-parser vulnerability has been fixed in project knowledgeowl-angular
27
-
28
- ## [4.0.9] - 2023-01-04
29
-
30
- - [ONCEHUB-62023](https://scheduleonce.atlassian.net/browse/ONCEHUB-62023): CVE-2022-46175 vulnerability found in package json5 in project knowledgeowl-angular
31
-
32
- ## [4.0.8] - 2022-12-13
33
-
34
- - [ONCEHUB-60847](https://scheduleonce.atlassian.net/browse/ONCEHUB-60847): CVE-2022-38900 vulnerability found in package decode-uri-component
35
-
36
- ## [4.0.7] - 2022-11-22
37
-
38
- ### Updated
39
-
40
- - [ONCEHUB-60383](https://scheduleonce.atlassian.net/browse/ONCEHUB-60383): CVE-2022-37603 vulnerability found in package loader-utils
41
- - [ONCEHUB-60450](https://scheduleonce.atlassian.net/browse/ONCEHUB-60450): CVE-2022-41940 vulnerability found in package engine.io
42
-
43
- ## [4.0.6] - 2022-11-09
44
-
45
- ### Updated
46
-
47
- - Fixed loader-utils vulnerability.
48
-
49
- ## [4.0.5] - 2022-10-31
50
-
51
- ### Updated
52
-
53
- - Fixed socket.io-parser vulnerability.
54
-
55
- ## [4.0.4] - 2022-07-21
56
-
57
- ### Updated
58
-
59
- - Updated @angular-devkit/build-angular packges to v13 latest.
60
-
61
- ## [4.0.3] - 2022-07-06
62
-
63
- ### Added
64
-
65
- - Added readme documentation on NPM.
66
-
67
- ## [4.0.2] - 2022-04-28
68
-
69
- ### Added
70
-
71
- - NA
72
-
73
- ### Changed
74
-
75
- - NA
76
-
77
- ### Removed
78
-
79
- - NA
80
-
81
- ### Fixed
82
-
83
- - Vulnerability fixes [ONCEHUB-53689](https://scheduleonce.atlassian.net/browse/ONCEHUB-53689)
84
-
85
- ## [4.0.0] - 2022-03-01
86
-
87
- ### Added
88
-
89
- - NA
90
-
91
- ### Changed
92
-
93
- - Updated project knowledgeowl-angular to use Angular 13
94
-
95
- ### Removed
96
-
97
- - NA
98
-
99
- ### Fixed
100
-
101
- - NA
102
-
103
- ## [3.0.2] - 2022-02-07
104
-
105
- ### Added
106
-
107
- - NA
108
-
109
- ### Changed
110
-
111
- - NA
112
-
113
- ### Removed
114
-
115
- - NA
116
-
117
- ### Fixed
118
-
119
- - [`ONCEHUB-50833`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50833) Fixed package vulnerabilities
120
- - [`ONCEHUB-50603`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50603) Fixed package vulnerabilities
121
- - [`ONCEHUB-47262`](https://scheduleonce.atlassian.net/browse/ONCEHUB-47262) Fixed package vulnerabilities
122
-
123
- ## [3.0.1] - 2022-01-24
124
-
125
- ### Added
126
-
127
- - NA
128
-
129
- ### Changed
130
-
131
- - NA
132
-
133
- ### Removed
134
-
135
- - NA
136
-
137
- ### Fixed
138
-
139
- - [`ONCEHUB-50115`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50115) Fixed package vulnerabilities
140
- - [`ONCEHUB-50604`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50604) Fixed package vulnerabilities
141
- - [`ONCEHUB-50609`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50609) Fixed package vulnerabilities
142
- - [`ONCEHUB-50641`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50641) Fixed package vulnerabilities
143
- - [`ONCEHUB-50756`](https://scheduleonce.atlassian.net/browse/ONCEHUB-50756) Fixed package vulnerabilities
144
-
145
- ## [2.0.4] - 2021-06-23
146
-
147
- ### Added
148
-
149
- - NA
150
-
151
- ### Changed
152
-
153
- - NA
154
-
155
- ### Removed
156
-
157
- - NA
158
-
159
- ### Fixed
160
-
161
- - [`ONCEHUB-43676`](https://scheduleonce.atlassian.net/browse/ONCEHUB-43676) Fixed package vulnerabilities
162
- - [`ONCEHUB-42560`](https://scheduleonce.atlassian.net/browse/ONCEHUB-42560) Fixed package vulnerabilities
163
- - [`ONCEHUB-42564`](https://scheduleonce.atlassian.net/browse/ONCEHUB-42564) Fixed package vulnerabilities
164
- - [`ONCEHUB-43237`](https://scheduleonce.atlassian.net/browse/ONCEHUB-43237) Fixed package vulnerabilities
165
-
166
- ## [2.0.1] - 2021-04-16
167
-
168
- ### Added
169
-
170
- - NA
171
-
172
- ### Changed
173
-
174
- - NA
175
-
176
- ### Removed
177
-
178
- - NA
179
-
180
- ### Fixed
181
-
182
- - [`ONCEHUB-40864`](https://scheduleonce.atlassian.net/browse/ONCEHUB-40864) Fixed package vulnerabilities for ssri
183
-
184
- ## [1.0.0] - 2020-09-15
185
-
186
- ### Added
187
-
188
- - NA
189
-
190
- ### Changed
191
-
192
- - Updated project knowledgeowl-angular to use Angular 9
193
-
194
- ### Removed
195
-
196
- - NA
197
-
198
- ### Fixed
199
-
200
- - [`ONCEHUB-32452`](https://scheduleonce.atlassian.net/browse/ONCEHUB-32452) Fixed package vulnerabilities for npm-registry-fetch
201
-
202
- ## [0.1.9] - 2020-07-07
203
-
204
- ### Added
205
-
206
- - NA
207
-
208
- ### Changed
209
-
210
- - NA
211
-
212
- ### Removed
213
-
214
- - NA
215
-
216
- ### Fixed
217
-
218
- - [`ONCEHUB-32349`](https://scheduleonce.atlassian.net/browse/ONCEHUB-32349) Fixed package vulnerabilities
219
-
220
- ## [0.1.8] - 2019-09-02
221
-
222
- ### Added
223
-
224
- - NA
225
-
226
- ### Changed
227
-
228
- - Converted knowledgeOwlLink component into directive [`ONCEHUB-16716`](https://scheduleonce.atlassian.net/browse/ONCEHUB-16716)
229
-
230
- ### Removed
231
-
232
- - NA
233
-
234
- ### Fixed
235
-
236
- -NA
237
-
238
- ## [0.1.7] - 2019-08-20
239
-
240
- ### Added
241
-
242
- - NA
243
-
244
- ### Changed
245
-
246
- - NA
247
-
248
- ### Removed
249
-
250
- - NA
251
-
252
- ### Fixed
253
-
254
- Dependency upgrades
255
-
256
- - [`ONCEHUB-15146`](https://scheduleonce.atlassian.net/browse/ONCEHUB-15146)
257
- - [`ONCEHUB-15340`](https://scheduleonce.atlassian.net/browse/ONCEHUB-15340)
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Oncehub
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/OWNERS DELETED
@@ -1,4 +0,0 @@
1
- approvers:
2
- - developers
3
- reviewers:
4
- - developers
package/OWNERS_ALIASES DELETED
@@ -1,20 +0,0 @@
1
- aliases:
2
- developers:
3
- - mderazon
4
- - so-abahadur
5
- - amanpreetSO
6
- - AmitPandeyScheduleonce
7
- - ashishsatiSO
8
- - SO-ashusrivastava
9
- - BharatSinghoh
10
- - giladgoraly
11
- - sohimanshu
12
- - so-kaushal
13
- - nalingarg
14
- - so-sdhawan
15
- - ShivamKe
16
- - ushankar208
17
- - vaibhavso
18
- - vinaykumar01
19
- - SoniRani
20
- - ryadavso
package/angular.json DELETED
@@ -1,55 +0,0 @@
1
- {
2
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
- "cli": {
4
- "analytics": "47c16505-5eb3-4e8a-a186-dc68f7f3ea3b"
5
- },
6
- "version": 1,
7
- "newProjectRoot": "projects",
8
- "projects": {
9
- "knowledgeowl-angular": {
10
- "root": "",
11
- "sourceRoot": "src",
12
- "projectType": "library",
13
- "prefix": "",
14
- "architect": {
15
- "build": {
16
- "builder": "@angular-devkit/build-angular:ng-packagr",
17
- "options": {
18
- "tsConfig": "src/tsconfig.lib.json",
19
- "project": "src/ng-package.json"
20
- },
21
- "configurations": {
22
- "production": {
23
- "tsConfig": "tsconfig.lib.prod.json"
24
- }
25
- }
26
- },
27
- "test": {
28
- "builder": "@angular-devkit/build-angular:karma",
29
- "options": {
30
- "main": "test/test.ts",
31
- "tsConfig": "src/tsconfig.spec.json",
32
- "karmaConfig": "test/karma.conf.js"
33
- }
34
- },
35
- "lint": {
36
- "builder": "@angular-eslint/builder:lint",
37
- "options": {
38
- "lintFilePatterns": [
39
- "src/**/*.ts",
40
- "src/**/*.html"
41
- ]
42
- }
43
- }
44
- }
45
- }
46
- },
47
- "schematics": {
48
- "@angular-eslint/schematics:application": {
49
- "setParserOptionsProject": true
50
- },
51
- "@angular-eslint/schematics:library": {
52
- "setParserOptionsProject": true
53
- }
54
- }
55
- }
package/src/README.md DELETED
@@ -1,5 +0,0 @@
1
- # KnowledgeOwl Angular
2
-
3
- The sources for this package are in the main [KnowledgeOwl Angular](https://github.com/scheduleonce/knowledgeowl-angular) repo. Please file issues and pull requests against that repo.
4
-
5
- License: MIT
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,10 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { NgModule } from '@angular/core';
3
- import { KnowledgeOwlLink } from './knowledge-owl-link';
4
-
5
- @NgModule({
6
- imports: [CommonModule],
7
- exports: [KnowledgeOwlLink],
8
- declarations: [KnowledgeOwlLink],
9
- })
10
- export class KnowledgeOwlLinkModule {}
@@ -1,51 +0,0 @@
1
- import { Component, Provider, Type } from '@angular/core';
2
- import { ComponentFixture, TestBed } from '@angular/core/testing';
3
- import { KnowledgeOwlLinkModule } from './index';
4
- import { getKnowledgeLinkArticleMissingError } from './knowledge-owl-widget-errors';
5
-
6
- @Component({
7
- template: `<a knowledgeOwlLink>Test link</a>`,
8
- })
9
- class KnowledgeOwlLinkWithoutArticle {}
10
-
11
- @Component({
12
- template: `
13
- <a knowledgeOwlLink="https://knowledgeowl.article.com/help/test-article"
14
- >Test link</a
15
- >
16
- `,
17
- })
18
- class KnowledgeOwlLinkWithValidInputs {}
19
-
20
- describe('KnowledgeOwl link with missing credentials', () => {
21
- it('should throw error without knowledgeOwlLink', () => {
22
- const fixture = createComponent(KnowledgeOwlLinkWithoutArticle, [
23
- { provide: 'KOProjectURL', useValue: 'https://knowledgeowl.com' },
24
- ]);
25
- expect(() => fixture.detectChanges()).toThrowError(
26
- getKnowledgeLinkArticleMissingError().message
27
- );
28
- });
29
- });
30
-
31
- describe('KnowledgeOwl link', () => {
32
- it('should not throw error when given correct inputs', () => {
33
- const fixture = createComponent(KnowledgeOwlLinkWithValidInputs, [
34
- { provide: 'KOProjectURL', useValue: 'https://knowledgeowl.com' },
35
- ]);
36
- expect(() => fixture.detectChanges()).not.toThrowError();
37
- });
38
- });
39
-
40
- const createComponent = <T>(
41
- component: Type<T>,
42
- providers: Provider[] = []
43
- ): ComponentFixture<T> => {
44
- TestBed.configureTestingModule({
45
- imports: [KnowledgeOwlLinkModule],
46
- declarations: [component],
47
- providers,
48
- }).compileComponents();
49
-
50
- return TestBed.createComponent<T>(component);
51
- };
@@ -1,97 +0,0 @@
1
- import {
2
- AfterContentInit,
3
- ElementRef,
4
- HostListener,
5
- Inject,
6
- Input,
7
- Directive,
8
- } from '@angular/core';
9
- import { getKnowledgeLinkArticleMissingError } from './knowledge-owl-widget-errors';
10
-
11
- /**
12
- * Knowledge Owl Link
13
- */
14
- @Directive({
15
- selector: `a[knowledgeOwlLink]`,
16
- exportAs: 'knowledgeOwlLink',
17
- })
18
- export class KnowledgeOwlLink implements AfterContentInit {
19
- @Input()
20
- knowledgeOwlLink: string;
21
-
22
- constructor(
23
- protected elementRef: ElementRef,
24
- @Inject('KOProjectURL') private projectURL: string
25
- ) {}
26
-
27
- getHostElement(): HTMLElement {
28
- return this.elementRef.nativeElement;
29
- }
30
-
31
- ngAfterContentInit(): void {
32
- this._validateLinkInputs();
33
- this._initLink();
34
- }
35
-
36
- @HostListener('click', ['$event'])
37
- openArticle(event: Event): void {
38
- event.preventDefault();
39
- // Convert the KO link into the widget link
40
- let widgetHref;
41
- if (this.knowledgeOwlLink.includes('#')) {
42
- const widgetlink = this.knowledgeOwlLink.split('#');
43
- const widgetlink1 =
44
- widgetlink[0].replace('/help/', '/help/fetch-article/hash/') +
45
- '?widget=true';
46
- const widgetlink2 = '#' + widgetlink[1];
47
- widgetHref = widgetlink1.concat(widgetlink2);
48
- } else {
49
- widgetHref =
50
- this.knowledgeOwlLink.replace('/help/', '/help/fetch-article/hash/') +
51
- '?widget=true';
52
- }
53
-
54
- if (window['__ko16']) {
55
- // Wait until widget loads completely
56
- window['__ko16'].openArticle(widgetHref);
57
- }
58
- }
59
-
60
- /**
61
- * Private methods
62
- */
63
-
64
- /**
65
- * Initialize link
66
- *
67
- * @private
68
- */
69
- private _initLink() {
70
- this.knowledgeOwlLink = `${this.projectURL}/help/${this.knowledgeOwlLink}`; // Updating article link to have complete URL
71
- const nativeElement = this.getHostElement();
72
- if (nativeElement.tagName === 'A') {
73
- // Updating link for <a>
74
- nativeElement.setAttribute('href', this.knowledgeOwlLink);
75
- }
76
- }
77
-
78
- /**
79
- * Validates all required inputs of knowledge-owl-link
80
- *
81
- * @private
82
- */
83
- private _validateLinkInputs() {
84
- this._validateArticlePresence();
85
- }
86
-
87
- /**
88
- * Validates presence of article URL for link
89
- *
90
- * @private
91
- */
92
- private _validateArticlePresence() {
93
- if (!this.knowledgeOwlLink) {
94
- throw getKnowledgeLinkArticleMissingError();
95
- }
96
- }
97
- }
@@ -1,3 +0,0 @@
1
- /** @docs-private */
2
- export const getKnowledgeLinkArticleMissingError = (): Error =>
3
- Error('knowledge-owl-link requires article URL as input.');
@@ -1 +0,0 @@
1
- export * from './public-api';
@@ -1,6 +0,0 @@
1
- /** @docs-private */
2
- export const getKnowledgeWidgetPoductKeyMissingError = (): Error =>
3
- Error('knowledge-owl-widget requires product key as input.');
4
-
5
- export const getKnowledgeWidgetInvalidProductURLError = (): Error =>
6
- Error('knowledge-owl-widget requires valid product URL as provider.');
@@ -1,11 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { KnowledgeOwlWidget } from './knowledge-owl-widget';
4
-
5
- @NgModule({
6
- imports: [CommonModule],
7
- exports: [KnowledgeOwlWidget],
8
- declarations: [KnowledgeOwlWidget],
9
- providers: [],
10
- })
11
- export class KnowledgeOwlWidgetModule {}
@@ -1,66 +0,0 @@
1
- import { Component, Provider, Type } from '@angular/core';
2
- import { ComponentFixture, TestBed } from '@angular/core/testing';
3
- import { KnowledgeOwlWidgetModule } from './index';
4
- import {
5
- getKnowledgeWidgetPoductKeyMissingError,
6
- getKnowledgeWidgetInvalidProductURLError,
7
- } from './knowledge-owl-widget-errors';
8
-
9
- @Component({
10
- template: `<knowledge-owl-widget></knowledge-owl-widget>`,
11
- })
12
- class KnowledgeOwlWidgetWithoutCredentials {}
13
-
14
- @Component({
15
- template: `<knowledge-owl-widget></knowledge-owl-widget>`,
16
- })
17
- class KnowledgeOwlWidgetWithoutProjectKey {}
18
-
19
- @Component({
20
- template: `
21
- <knowledge-owl-widget [projectKey]="'testkey'"></knowledge-owl-widget>
22
- `,
23
- })
24
- class KnowledgeOwlWidgetWithCredentials {}
25
-
26
- describe('KnowledgeOwl widget with missing credentials', () => {
27
- it('should throw KnowledgeWidgetProductURLMissingError error', () => {
28
- const fixture = createComponent(KnowledgeOwlWidgetWithoutCredentials, [
29
- { provide: 'KOProjectURL', useValue: 'https://' },
30
- ]);
31
- expect(() => fixture.detectChanges()).toThrowError(
32
- getKnowledgeWidgetInvalidProductURLError().message
33
- );
34
- });
35
-
36
- it('should throw KnowledgeWidgetProductKeyMissingError error', () => {
37
- const fixture = createComponent(KnowledgeOwlWidgetWithoutProjectKey, [
38
- { provide: 'KOProjectURL', useValue: 'https://knowledgeowl.com' },
39
- ]);
40
- expect(() => fixture.detectChanges()).toThrowError(
41
- getKnowledgeWidgetPoductKeyMissingError().message
42
- );
43
- });
44
- });
45
-
46
- describe('KnowledgeOwl widget', () => {
47
- it('should not throw error when given correct inputs', () => {
48
- const fixture = createComponent(KnowledgeOwlWidgetWithCredentials, [
49
- { provide: 'KOProjectURL', useValue: 'https://knowledgeowl.com' },
50
- ]);
51
- expect(() => fixture.detectChanges()).not.toThrowError();
52
- });
53
- });
54
-
55
- const createComponent = <T>(
56
- component: Type<T>,
57
- providers: Provider[] = []
58
- ): ComponentFixture<T> => {
59
- TestBed.configureTestingModule({
60
- imports: [KnowledgeOwlWidgetModule],
61
- declarations: [component],
62
- providers,
63
- }).compileComponents();
64
-
65
- return TestBed.createComponent<T>(component);
66
- };