Skip to content

Commit

Permalink
V0.3.6 (#55)
Browse files Browse the repository at this point in the history
* update: make sure all WordPressElements has public init

* update: make RSSItemCategory equatable
  • Loading branch information
devahmedshendy authored Sep 6, 2023
1 parent 6ae9011 commit eade198
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Sources/SyndiKit/Formats/Feeds/RSS/RSSItemCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ public struct RSSItemCategory: Codable, EntryCategory {
nicename = try container?.decodeIfPresent(String.self, forKey: .nicename)
}
}

extension RSSItemCategory: Equatable {
public static func == (lhs: RSSItemCategory, rhs: RSSItemCategory) -> Bool {
lhs.value == rhs.value
&& lhs.domain == rhs.domain
&& lhs.nicename == rhs.nicename
}
}
7 changes: 7 additions & 0 deletions Sources/SyndiKit/Formats/Media/Wordpress/WPCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public extension WordPressElements {
case parent = "wp:categoryParent"
case name = "wp:catName"
}

public init(termID: Int, niceName: CData, parent: CData, name: String) {
self.termID = termID
self.niceName = niceName
self.parent = parent
self.name = name
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions Sources/SyndiKit/Formats/Media/Wordpress/WPTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public extension WordPressElements {
case slug = "wp:tagSlug"
case name = "wp:tagName"
}

public init(termID: Int, slug: CData, name: CData) {
self.termID = termID
self.slug = slug
self.name = name
}
}
}

Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions Tests/SyndiKitTests/RSSItemCategoryTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import XCTest
@testable import SyndiKit

final class RSSItemCategoryTests: XCTestCase {

func testTwoEqualCategories() {
let c1 = RSSItemCategory(
value: "Top Menu",
domain: "nav_menu",
nicename: "top-menu"
)

let c2 = RSSItemCategory(
value: "Top Menu",
domain: "nav_menu",
nicename: "top-menu"
)

XCTAssertEqual(c1, c2)
}

func testTwoUnequalCategories() {
let c1 = RSSItemCategory(
value: "Uncategorized",
domain: "category",
nicename: "uncategorized"
)

let c2 = RSSItemCategory(
value: "Top Menu",
domain: "nav_menu",
nicename: "top-menu"
)

XCTAssertNotEqual(c1, c2)
}
}
7 changes: 0 additions & 7 deletions Tests/SyndiKitTests/WordPressElementsTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// WordPressElementsTests.swift
//
//
// Created by Ahmed Shendy on 27/08/2023.
//

import XCTest
@testable import SyndiKit

Expand Down

0 comments on commit eade198

Please sign in to comment.