Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6a5499

Browse files
committed
fix: update isNotificationTextPrefixed
This removes an eslint-disable rule and adds two new tests to ensureisNotificationTextPrefixed is working as expected.
1 parentb23f35f commite6a5499

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎site/src/components/GlobalSnackbar/utils.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
isNotificationTextPrefixed,
55
MsgType,
66
NotificationMsg,
7+
NotificationTextPrefixed,
78
SnackbarEventType,
89
}from"./utils"
910

@@ -17,6 +18,29 @@ describe("Snackbar", () => {
1718
// When
1819
constisTextPrefixed=isNotificationTextPrefixed(msg)
1920

21+
// Then
22+
expect(isTextPrefixed).toBe(false)
23+
})
24+
it("returns true if prefixed",()=>{
25+
// Given
26+
constmsg:NotificationTextPrefixed={
27+
prefix:"warning",
28+
text:"careful with this workspace",
29+
}
30+
31+
// When
32+
constisTextPrefixed=isNotificationTextPrefixed(msg)
33+
34+
// Then
35+
expect(isTextPrefixed).toBe(true)
36+
})
37+
it("returns false if not prefixed",()=>{
38+
// Given
39+
constmsg="plain ol' message"
40+
41+
// When
42+
constisTextPrefixed=isNotificationTextPrefixed(msg)
43+
2044
// Then
2145
expect(isTextPrefixed).toBe(false)
2246
})

‎site/src/components/GlobalSnackbar/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ export const isNotificationText = (msg: AdditionalMessage): msg is string => {
2727
exportconstisNotificationTextPrefixed=(
2828
msg:AdditionalMessage|null,
2929
):msg isNotificationTextPrefixed=>{
30-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
31-
returntypeof(msgasNotificationTextPrefixed)?.prefix!=="undefined"
30+
if(msg){
31+
returntypeofmsg!=="string"&&Object.prototype.hasOwnProperty.call(msg,"prefix")
32+
}
33+
returnfalse
3234
}
3335

3436
exportconstisNotificationList=(msg:AdditionalMessage):msg isstring[]=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp