-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ApiCall): prevent ML-CLI from generating null results for api call (
#299)
- Loading branch information
1 parent
f324425
commit 630bd8d
Showing
3 changed files
with
219 additions
and
90 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
105 changes: 105 additions & 0 deletions
105
src/Ecotag/ClientApp/src/Local/FileTreatment/FileTreatment.spec.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,105 @@ | ||
import {compareStatusCode, mapItems, setStatusFilterItems,} from './FileTreatment'; | ||
|
||
describe('Check file treatment', () => { | ||
it('should map items properly', () => { | ||
const data = [ | ||
{ | ||
FileName: "MyFirstFileName.txt", | ||
Left: { | ||
Url: "http://localhost:5000", | ||
FileName: "MyFirstFileName.txt", | ||
FileDirectory: "folder1", | ||
ImageDirectory: "folder2", | ||
FrontDefaultStringsMatcher: "", | ||
StatusCode: 200, | ||
Body: "Blah blah blah", | ||
Headers: "", | ||
TimeMs: 4000, | ||
TicksAt: 0 | ||
}, | ||
Right: { | ||
Url: "http://localhost:5000", | ||
FileName: "MyFirstFileName.txt", | ||
FileDirectory: "folder1", | ||
ImageDirectory: "folder2", | ||
FrontDefaultStringsMatcher: "", | ||
StatusCode: 400, | ||
Body: "Blah blah blah", | ||
Headers: "", | ||
TimeMs: 4000, | ||
TicksAt: 0 | ||
} | ||
}, | ||
undefined, | ||
{ | ||
FileName: "MySecondFileName.txt", | ||
Left: { | ||
Url: "http://localhost:5000", | ||
FileName: "MySecondFileName.txt", | ||
FileDirectory: "folder1", | ||
ImageDirectory: "folder2", | ||
FrontDefaultStringsMatcher: "", | ||
StatusCode: 200, | ||
Body: "Blah blah blah", | ||
Headers: "", | ||
TimeMs: 4000, | ||
TicksAt: 0 | ||
}, | ||
Right: { | ||
Url: "http://localhost:5000", | ||
FileName: "MySecondFileName.txt", | ||
FileDirectory: "folder1", | ||
ImageDirectory: "folder2", | ||
FrontDefaultStringsMatcher: "", | ||
StatusCode: 400, | ||
Body: "Blah blah blah", | ||
Headers: "", | ||
TimeMs: 4000, | ||
TicksAt: 0 | ||
} | ||
}, | ||
null | ||
]; | ||
const mappedData = mapItems(data); | ||
expect(mappedData.length).toEqual(2); | ||
for(let item in mappedData){ | ||
expect(item).not.toBeUndefined(); | ||
expect(item).not.toBeNull(); | ||
} | ||
}); | ||
it('should add new status code properly', () => { | ||
const statusCode = 200; | ||
const result = [{value: "All", label: "All"}]; | ||
compareStatusCode(statusCode, result); | ||
|
||
expect(result.length).toEqual(2); | ||
expect(result[0]).toEqual({value: "All", label: "All"}); | ||
expect(result[1]).toEqual({value: "200", label: "200"}); | ||
}); | ||
it('should set status filter items properly', () => { | ||
const items = [ | ||
{ | ||
left: { | ||
StatusCode: 200 | ||
}, | ||
right: { | ||
StatusCode: 200 | ||
} | ||
}, | ||
{ | ||
left: { | ||
StatusCode: 200 | ||
}, | ||
right: { | ||
StatusCode: 400 | ||
} | ||
} | ||
]; | ||
const newFilters = setStatusFilterItems(items); | ||
|
||
expect(newFilters.length).toEqual(3); | ||
expect(newFilters[0]).toEqual({value: "All", label: "All"}); | ||
expect(newFilters[1]).toEqual({value: "200", label: "200"}); | ||
expect(newFilters[2]).toEqual({value: "400", label: "400"}); | ||
}); | ||
}); |
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