-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a more readable check for responses
- Loading branch information
Felix Ruf
committed
Jul 12, 2023
1 parent
ce296e2
commit 423f4a2
Showing
13 changed files
with
112 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Ref } from "vue"; | ||
|
||
export function isResponseOkay<T>(error: Ref<boolean>, response: Ref<T>) { | ||
return ( | ||
error.value === false && | ||
response.value !== null && | ||
response.value !== undefined | ||
); | ||
} |
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
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,38 @@ | ||
import { isResponseOkay } from "@/api/isResponseOkay"; | ||
import { ref } from "vue"; | ||
|
||
describe('Test isResponseOkay', () => { | ||
it('should return true if the response is defined, not null and there are no errors', () => { | ||
const response = ref({ | ||
test: 'test' | ||
}); | ||
const error = ref(false); | ||
expect(isResponseOkay(error, response)).toBeTruthy(); | ||
}); | ||
|
||
it('should return false if there is an error', () => { | ||
const response = ref({ | ||
test: 'test' | ||
}); | ||
const error = ref(true); | ||
expect(isResponseOkay(error, response)).toBeFalsy(); | ||
}); | ||
|
||
it('should return false if respose is null', () => { | ||
const response = ref(null); | ||
const error = ref(false); | ||
expect(isResponseOkay(error, response)).toBeFalsy(); | ||
}); | ||
|
||
it('should be false if response is undefined', () => { | ||
const response = ref(undefined); | ||
const error = ref(false); | ||
expect(isResponseOkay(error, response)).toBeFalsy(); | ||
}); | ||
|
||
it('should be false if respose is undefined and error is true', () => { | ||
const response = ref(undefined); | ||
const error = ref(true); | ||
expect(isResponseOkay(error, response)).toBeFalsy(); | ||
}); | ||
}); |
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
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