forked from geosolutions-it/geonode-mapstore-client
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
140c608
commit abb3937
Showing
4 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
export const getUploadErrorMessageFromCode = (code) => { | ||
switch (code) { | ||
case 'upload_parallelism_limit_exceeded': { | ||
return 'parallelLimitError'; | ||
} | ||
case 'total_upload_size_exceeded': { | ||
return 'fileExceeds'; | ||
} | ||
case 'upload_exception': | ||
default: | ||
return 'invalidUploadMessageErrorTooltip'; | ||
} | ||
}; |
20 changes: 20 additions & 0 deletions
20
geonode_mapstore_client/client/js/utils/__tests__/ErrorUtils-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
/* | ||
* Copyright 2022, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import { getUploadErrorMessageFromCode } from '../ErrorUtils'; | ||
|
||
describe('Test error utilities', () => { | ||
it('should test getUploadErrorMessageFromCode', () => { | ||
expect(getUploadErrorMessageFromCode('upload_parallelism_limit_exceeded')).toEqual('parallelLimitError'); | ||
expect(getUploadErrorMessageFromCode('total_upload_size_exceeded')).toEqual('fileExceeds'); | ||
expect(getUploadErrorMessageFromCode('upload_exception')).toEqual('invalidUploadMessageErrorTooltip'); | ||
expect(getUploadErrorMessageFromCode()).toEqual('invalidUploadMessageErrorTooltip'); | ||
}); | ||
}); |