File tree Expand file tree Collapse file tree 4 files changed +5
-33
lines changed
test/unit/compas-services Expand file tree Collapse file tree 4 files changed +5
-33
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import {get, translate} from 'lit-translate';
3
3
import { newLogEvent , newWizardEvent , Wizard } from "../foundation.js" ;
4
4
5
5
import { CompasSclDataService , SDS_NAMESPACE } from "../compas-services/CompasSclDataService.js" ;
6
- import { createLogEvent , isNotFoundError , NOT_FOUND_ERROR } from "../compas-services/foundation.js" ;
6
+ import { createLogEvent } from "../compas-services/foundation.js" ;
7
7
import { getTypeFromDocName , updateDocumentInOpenSCD } from "../compas/foundation.js" ;
8
8
import { getElementByName , getOpenScdElement , styles } from './foundation.js' ;
9
9
import { addVersionToCompasWizard } from "../compas/CompasUploadVersion.js" ;
@@ -54,10 +54,8 @@ export default class CompasVersionsPlugin extends LitElement {
54
54
. then ( xmlResponse => {
55
55
this . scls = Array . from ( xmlResponse . querySelectorAll ( 'Item' ) ?? [ ] ) ;
56
56
} )
57
- . catch ( reason => {
58
- if ( isNotFoundError ( reason ) ) {
59
- this . scls = [ ] ;
60
- }
57
+ . catch ( ( ) => {
58
+ this . scls = [ ] ;
61
59
} ) ;
62
60
}
63
61
Original file line number Diff line number Diff line change @@ -69,10 +69,6 @@ export function handleError(error: Error): Promise<never> {
69
69
return Promise . reject ( { type : SERVER_ERROR , message : error . message } ) ;
70
70
}
71
71
72
- export function isNotFoundError ( reason : any ) : boolean {
73
- return ( reason . type !== undefined && reason . type === NOT_FOUND_ERROR ) ;
74
- }
75
-
76
72
export function createLogEvent ( reason : any ) : void {
77
73
let message = reason . message ;
78
74
if ( reason . status ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import {property} from "lit-element";
3
3
import { LitElementConstructor , Mixin } from "../foundation.js" ;
4
4
5
5
import { CompasSclDataService } from "../compas-services/CompasSclDataService.js" ;
6
- import { isNotFoundError , NOT_FOUND_ERROR } from "../compas-services/foundation.js" ;
7
6
import { getTypeFromDocName } from "./foundation.js" ;
8
7
9
8
export type CompasExistsInElement = Mixin < typeof CompasExistsIn > ;
@@ -32,10 +31,8 @@ export function CompasExistsIn<TBase extends LitElementConstructor>(Base: TBase)
32
31
const docType = getTypeFromDocName ( this . docName ) ;
33
32
this . callService ( docType , this . docId )
34
33
. then ( ( ) => this . existInCompas = true )
35
- . catch ( reason => {
36
- if ( isNotFoundError ( reason ) ) {
37
- this . existInCompas = false ;
38
- }
34
+ . catch ( ( ) => {
35
+ this . existInCompas = false ;
39
36
} ) ;
40
37
} else {
41
38
this . existInCompas = false ;
Original file line number Diff line number Diff line change 1
1
import { expect } from "@open-wc/testing" ;
2
2
3
3
import {
4
- isNotFoundError ,
5
- NOT_FOUND_ERROR ,
6
4
processErrorMessage ,
7
- SERVER_ERROR
8
5
} from "../../../src/compas-services/foundation.js" ;
9
6
10
7
const errorBody =
@@ -32,21 +29,5 @@ describe('compas-services-foundation', () => {
32
29
expect ( result ) . to . be . equal ( expectedMessage ) ;
33
30
34
31
} )
35
-
36
- it ( 'when the error is caused by a status 404 then return true' , ( ) => {
37
- const reason = { type : NOT_FOUND_ERROR } ;
38
- const result = isNotFoundError ( reason ) ;
39
- expect ( result ) . to . be . true ;
40
- } )
41
- it ( 'when the error is caused by other status then return false' , ( ) => {
42
- const reason = { type : SERVER_ERROR } ;
43
- const result = isNotFoundError ( reason ) ;
44
- expect ( result ) . to . be . false ;
45
- } )
46
- it ( 'when no type of error found then return false' , ( ) => {
47
- const reason = { } ;
48
- const result = isNotFoundError ( reason ) ;
49
- expect ( result ) . to . be . false ;
50
- } )
51
32
} ) ;
52
33
You can’t perform that action at this time.
0 commit comments