Skip to content

Commit

Permalink
CW-2825: Angular services tests (#15)
Browse files Browse the repository at this point in the history
* angular services tests

* remove lock file from angular package
  • Loading branch information
walaszczykm authored Jan 12, 2022
1 parent 1ee66ee commit 7aa438a
Show file tree
Hide file tree
Showing 25 changed files with 1,468 additions and 421 deletions.
1,107 changes: 979 additions & 128 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions packages/widget-angular/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"timers": "fake",
"maxWorkers": "25%",
"preset": "jest-preset-angular",
"testEnvironment": "jsdom",
"testMatch": [
"**/__tests__/*.spec.[jt]s?(x)"
],
"coveragePathIgnorePatterns": [
"node_modules",
"__tests__"
],
"setupFilesAfterEnv": [
"./jest.setup.js"
]
}
1 change: 1 addition & 0 deletions packages/widget-angular/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest'
279 changes: 0 additions & 279 deletions packages/widget-angular/package-lock.json

This file was deleted.

2 changes: 2 additions & 0 deletions packages/widget-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dist"
],
"scripts": {
"test": "jest",
"build": "rimraf lib dist && ngc && rollup -c",
"watch:ngc": "ngc --watch",
"watch:rollup": "rollup -c --watch",
Expand All @@ -34,6 +35,7 @@
"@angular/compiler": "13.0.3",
"@angular/compiler-cli": "13.0.3",
"@angular/core": "13.0.3",
"jest-preset-angular": "^11.0.1",
"rxjs": "7.4.0"
}
}
2 changes: 1 addition & 1 deletion packages/widget-angular/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import replace from '@rollup/plugin-replace'
import dts from 'rollup-plugin-dts'
import pkg from './package.json'

const extensions = ['.ts']
const extensions = ['.js', '.ts']

const baseConfig = defineConfig({
input: 'lib/index.js',
Expand Down
10 changes: 5 additions & 5 deletions packages/widget-angular/src/LiveChatWidget.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core'

import { LiveChatWidgetComponent } from './LiveChatWidget.component'
import { WidgetIsReadyService } from './WidgetIsReady.service'
import { WidgetStateService } from './WidgetState.service'
import { WidgetCustomerDataService } from './WidgetCustomerData.service'
import { WidgetChatDataService } from './WidgetChatData.service'
import { WidgetGreetingService } from './WidgetGreeting.service'
import { WidgetIsReadyService } from './services/WidgetIsReady.service'
import { WidgetStateService } from './services/WidgetState.service'
import { WidgetCustomerDataService } from './services/WidgetCustomerData.service'
import { WidgetChatDataService } from './services/WidgetChatData.service'
import { WidgetGreetingService } from './services/WidgetGreeting.service'

@NgModule({
imports: [],
Expand Down
6 changes: 1 addition & 5 deletions packages/widget-angular/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export * from './WidgetIsReady.service'
export * from './WidgetState.service'
export * from './WidgetCustomerData.service'
export * from './WidgetChatData.service'
export * from './WidgetGreeting.service'
export * from './services'
export { LiveChatWidgetModule } from './LiveChatWidget.module'
export { LiveChatWidgetComponent } from './LiveChatWidget.component'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class WidgetChatDataService implements OnDestroy {

this.onDestroy = () => {
this.subject.complete()
this.subject.unsubscribe()
subscribtion.unsubscribe()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class WidgetCustomerDataService implements OnDestroy {

this.onDestroy = () => {
this.subject.complete()
this.subject.unsubscribe()
assignEventHandlers('off', { onReady, onCustomerStatusChanged })
unsubscribeInit()
unsubscribeDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class WidgetGreetingService implements OnDestroy {
})
this.onDestroy = () => {
this.subject.complete()
this.subject.unsubscribe()
assignEventHandlers('off', { onGreetingDisplayed, onGreetingHidden })
unsubscribeInit()
unsubscribeDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class WidgetIsReadyService implements OnDestroy {
})
this.onDestroy = () => {
this.subject.complete()
this.subject.unsubscribe()
assignEventHandlers('off', { onReady })
unsubscribeInit()
unsubscribeDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class WidgetStateService implements OnDestroy {

this.onDestroy = () => {
this.subject.complete()
this.subject.unsubscribe()
assignEventHandlers('off', { onReady, onVisibilityChanged, onAvailabilityChanged })
unsubscribeInit()
unsubscribeDestroy()
Expand Down
Loading

0 comments on commit 7aa438a

Please sign in to comment.