-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(notifications): Update code to handle presentational data and ico…
…n mapping Discourse notification types starts from 1 in that sense we need to update to make sure we map icons correctly, besides, the notification presentational data changes depending on the type of notification, thus, we need a way to provide a common structure to be rendered
- Loading branch information
Showing
7 changed files
with
102 additions
and
40 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
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 |
---|---|---|
@@ -1,11 +1,33 @@ | ||
// @flow | ||
|
||
import { getNotificationTypeName } from "../helpers"; | ||
import { notifications } from "../../__fixtures__/notifications"; | ||
import { | ||
getNotificationPresentationalData, | ||
getNotificationTypeName, | ||
} from "../helpers"; | ||
|
||
describe("helpers", () => { | ||
describe("getNotificationTypeName", () => { | ||
it("returns mapped notification name after number", () => { | ||
expect(getNotificationTypeName(1)).toEqual("replied"); | ||
expect(getNotificationTypeName(1)).toEqual("mentioned"); | ||
}); | ||
}); | ||
|
||
describe("getNotificationPresentationalData", () => { | ||
it("returns a consistent object with title and date", () => { | ||
expect(getNotificationPresentationalData(notifications[0])).toEqual({ | ||
date: notifications[0].created_at, | ||
title: notifications[0].data.topic_title, | ||
}); | ||
}); | ||
|
||
describe("when notification type is related to granted badge", () => { | ||
it("returns a consistent object with title and date", () => { | ||
expect(getNotificationPresentationalData(notifications[3])).toEqual({ | ||
date: notifications[3].created_at, | ||
title: notifications[3].data.badge_name, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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