From d49c5c1398fd64d30213a80969add3e67bf0e7b5 Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Sun, 22 Mar 2026 19:12:03 +0000 Subject: [PATCH] extract test structures to their own file --- StickerSlack.xcodeproj/project.pbxproj | 8 + .../Emoji/Categorisation/EmojiPack.swift | 18 --- StickerSlack/Emoji/Emoji.swift | 10 -- StickerSlack/Extensions/TestStructures.swift | 141 ++++++++++++++++++ StickerSlack/Gifs/Gif.swift | 101 +------------ 5 files changed, 150 insertions(+), 128 deletions(-) create mode 100644 StickerSlack/Extensions/TestStructures.swift diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index cc9649b..adec365 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -58,6 +58,8 @@ A99589AF2F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; A99589B02F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; A99589B12F5E0D83003A4A8C /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = A99589AE2F5E0D83003A4A8C /* image.png */; }; + A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; }; + A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; }; A9A7A43F2F6835F800BB84C6 /* Trending.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A43E2F6835F800BB84C6 /* Trending.swift */; }; A9A7A4402F6835F800BB84C6 /* Trending.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A43E2F6835F800BB84C6 /* Trending.swift */; }; A9A7A4422F68360200BB84C6 /* GifObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A7A4412F68360200BB84C6 /* GifObject.swift */; }; @@ -111,6 +113,7 @@ A9CD6C3A2EDDE6B500B7F421 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; A9CD6C3B2EDDE6B500B7F421 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; A9D15B8B2EB1142C00404792 /* EmojiPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D15B892EB1142C00404792 /* EmojiPack.swift */; }; + A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */ = {isa = PBXBuildFile; fileRef = A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */; }; A9EB72392EB93FDB00658CEB /* EmojiCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72382EB93FDB00658CEB /* EmojiCollectionView.swift */; }; A9EB72472EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; A9EB72492EB948C400658CEB /* StickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EB72462EB948C400658CEB /* StickerRow.swift */; }; @@ -187,6 +190,7 @@ A986A6CA2EB659E000B6E0FA /* MessagesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesViewController.swift; sourceTree = ""; }; A986A6CB2EB659E000B6E0FA /* StickerBrowserDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerBrowserDataSource.swift; sourceTree = ""; }; A99589AE2F5E0D83003A4A8C /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = ""; }; + A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestStructures.swift; sourceTree = ""; }; A9A7A43E2F6835F800BB84C6 /* Trending.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Trending.swift; sourceTree = ""; }; A9A7A4412F68360200BB84C6 /* GifObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifObject.swift; sourceTree = ""; }; A9A7A4442F68360900BB84C6 /* Pagination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pagination.swift; sourceTree = ""; }; @@ -259,6 +263,7 @@ A9104C7D2EB4022500D160EA /* MSSticker.swift */, A957C1762ECD008E00EA3EE9 /* Bundle.swift */, A9A7A4672F6AA17C00BB84C6 /* Int.swift */, + A995D95A2F6EBBDD0043E5F5 /* TestStructures.swift */, ); path = Extensions; sourceTree = ""; @@ -645,6 +650,7 @@ A9BE30F22F5B004E00A57668 /* Gif.swift in Sources */, A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */, A9A7A4482F68361200BB84C6 /* Meta.swift in Sources */, + A995D95C2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */, A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -672,6 +678,7 @@ A957C17E2ECFAA1100EA3EE9 /* GifView.swift in Sources */, A9A7A45F2F69570200BB84C6 /* Gif.swift in Sources */, A9A7A45E2F6956B700BB84C6 /* StickerType.swift in Sources */, + A9D6A8212F7014AE00F198FB /* TestStructures.swift in Sources */, A9BBC5192EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, A986A6C42EB6598500B6E0FA /* SlackResponse.swift in Sources */, A986A6C22EB6597600B6E0FA /* Emoji.swift in Sources */, @@ -700,6 +707,7 @@ A9EB724A2EB948E000658CEB /* EmojiCollectionView.swift in Sources */, A9EB724D2EB94A6B00658CEB /* TrieTestingView.swift in Sources */, A9BBC51A2EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, + A995D95B2F6EBBDD0043E5F5 /* TestStructures.swift in Sources */, A955B3ED2EC22C4A00E1732D /* DownloadedView.swift in Sources */, A9EC46AD2F6D9E4600E066E6 /* Hoarder.swift in Sources */, A9A7A4682F6AA17C00BB84C6 /* Int.swift in Sources */, diff --git a/StickerSlack/Emoji/Categorisation/EmojiPack.swift b/StickerSlack/Emoji/Categorisation/EmojiPack.swift index 98138dc..f8b757a 100644 --- a/StickerSlack/Emoji/Categorisation/EmojiPack.swift +++ b/StickerSlack/Emoji/Categorisation/EmojiPack.swift @@ -12,22 +12,4 @@ struct EmojiPack: Identifiable, Codable { var name: String var description: String var emojiNames: [String] - - static var test: EmojiPack { - EmojiPack( - id: UUID(), - name: "test pack", - description: "neon443's debug emoji pack", - emojiNames: [ - "pf", - "heavysob", - "yay", - "skulk", - "loll", - "bleh", - "uhh", - "communist" - ] - ) - } } diff --git a/StickerSlack/Emoji/Emoji.swift b/StickerSlack/Emoji/Emoji.swift index 92ad022..d259ad8 100644 --- a/StickerSlack/Emoji/Emoji.swift +++ b/StickerSlack/Emoji/Emoji.swift @@ -44,14 +44,4 @@ struct Emoji: StickerProtocol { self.name = name self.remoteImageURL = url } - - static var test: Emoji = Emoji( - name: "a test slack emoji", - url: Bundle.main.url(forResource: "image", withExtension: "png")! - ) - - static var testLongName: Emoji = Emoji( - name: "ForEach, String, EmojiRow>: the ID jarjarbinks occurs multiple times within the collection, this will give undefined results!", - url: Bundle.main.url(forResource: "image", withExtension: "png")! - ) } diff --git a/StickerSlack/Extensions/TestStructures.swift b/StickerSlack/Extensions/TestStructures.swift new file mode 100644 index 0000000..173c87e --- /dev/null +++ b/StickerSlack/Extensions/TestStructures.swift @@ -0,0 +1,141 @@ +// +// TestStructures.swift +// StickerSlack +// +// Created by neon443 on 21/03/2026. +// + +import Foundation + +extension Emoji { + static var test: Emoji = Emoji( + name: "a test slack emoji", + url: Bundle.main.url(forResource: "image", withExtension: "png")! + ) + + static var testLongName: Emoji = Emoji( + name: "ForEach, String, EmojiRow>: the ID jarjarbinks occurs multiple times within the collection, this will give undefined results!", + url: Bundle.main.url(forResource: "image", withExtension: "png")! + ) +} + +extension Gif { + static var test: Gif = GifObject( + type: "gif", + id: "XAeEGyCbp8UehBPkSA", + slug: "know-does-he-XAeEGyCbp8UehBPkSA", + url: "https://giphy.com/gifs/know-does-he-XAeEGyCbp8UehBPkSA", + bitly_url: "https://gph.is/g/4AKMQlV", + embed_url: "https://giphy.com/embed/XAeEGyCbp8UehBPkSA", + username: "Ommarbisafool", + source: "", + rating: "g", + source_tld: "", + source_post_url: "", + import_datetime: "2025-11-06 15:48:02", + images: GiphyImages( + fixed_height: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.gif&ct=g", + width: "270", + height: "200", + size: "74672", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.mp4&ct=g", + mp4_size: "11433", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.webp&ct=g", + webp_size: "10962" + ), + fixed_height_still: nil, + fixed_height_downsampled: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.gif&ct=g", + width: "270", + height: "200", + size: "51332", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.webp&ct=g", + webp_size: "44850" + ), + fixed_height_small: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.gif&ct=g", + width: "134", + height: "100", + size: "16461", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.mp4&ct=g", + mp4_size: "5340", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.webp&ct=g", + webp_size: "3142" + ), + fixed_height_small_still: nil, + fixed_width: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.gif&ct=g", + width: "200", + height: "148", + size: "42579", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.mp4&ct=g", + mp4_size: "8158", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.webp&ct=g", + webp_size: "4458" + ), + fixed_width_still: nil, + fixed_width_downsampled: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.gif&ct=g", + width: "200", + height: "148", + size: "23483", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.webp&ct=g", + webp_size: "22586" + ), + fixed_width_small: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.gif&ct=g", + width: "100", + height: "74", + size: "8150", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.mp4&ct=g", + mp4_size: "4103", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.webp&ct=g", + webp_size: "1814" + ), + fixed_width_small_still: nil, + downsized: nil, + downsized_still: nil, + downsized_large: nil, + downsized_medium: nil, + downsized_small: nil, + original: .init( + url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.gif&ct=g", + width: "480", + height: "356", + size: "245829", + mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.mp4&ct=g", + mp4_size: "23259", + webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.webp&ct=g", + webp_size: "26984" + ), + original_still: nil, + // looping: nil, + preview: nil, + preview_gif: nil + ), + title: "Know GIF", + alt_text: "", + is_low_contrast: false + ).toGif +} + +extension EmojiPack { + static var test: EmojiPack { + EmojiPack( + id: UUID(), + name: "test pack", + description: "neon443's debug emoji pack", + emojiNames: [ + "pf", + "heavysob", + "yay", + "skulk", + "loll", + "bleh", + "uhh", + "communist" + ] + ) + } +} diff --git a/StickerSlack/Gifs/Gif.swift b/StickerSlack/Gifs/Gif.swift index 3256db2..d4ff1f3 100644 --- a/StickerSlack/Gifs/Gif.swift +++ b/StickerSlack/Gifs/Gif.swift @@ -52,104 +52,5 @@ struct Gif: StickerProtocol { try! data.write(to: localImageURL) return - } - - static var test: Gif = GifObject( - type: "gif", - id: "XAeEGyCbp8UehBPkSA", - slug: "know-does-he-XAeEGyCbp8UehBPkSA", - url: "https://giphy.com/gifs/know-does-he-XAeEGyCbp8UehBPkSA", - bitly_url: "https://gph.is/g/4AKMQlV", - embed_url: "https://giphy.com/embed/XAeEGyCbp8UehBPkSA", - username: "Ommarbisafool", - source: "", - rating: "g", - source_tld: "", - source_post_url: "", - import_datetime: "2025-11-06 15:48:02", - images: GiphyImages( - fixed_height: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.gif&ct=g", - width: "270", - height: "200", - size: "74672", - mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.mp4&ct=g", - mp4_size: "11433", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200.webp&ct=g", - webp_size: "10962" - ), - fixed_height_still: nil, - fixed_height_downsampled: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.gif&ct=g", - width: "270", - height: "200", - size: "51332", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200_d.webp&ct=g", - webp_size: "44850" - ), - fixed_height_small: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.gif&ct=g", - width: "134", - height: "100", - size: "16461", - mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.mp4&ct=g", - mp4_size: "5340", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100.webp&ct=g", - webp_size: "3142" - ), - fixed_height_small_still: nil, - fixed_width: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.gif&ct=g", - width: "200", - height: "148", - size: "42579", - mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.mp4&ct=g", - mp4_size: "8158", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w.webp&ct=g", - webp_size: "4458" - ), - fixed_width_still: nil, - fixed_width_downsampled: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.gif&ct=g", - width: "200", - height: "148", - size: "23483", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/200w_d.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=200w_d.webp&ct=g", - webp_size: "22586" - ), - fixed_width_small: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.gif&ct=g", - width: "100", - height: "74", - size: "8150", - mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.mp4&ct=g", - mp4_size: "4103", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/100w.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=100w.webp&ct=g", - webp_size: "1814" - ), - fixed_width_small_still: nil, - downsized: nil, - downsized_still: nil, - downsized_large: nil, - downsized_medium: nil, - downsized_small: nil, - original: .init( - url: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.gif?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.gif&ct=g", - width: "480", - height: "356", - size: "245829", - mp4: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.mp4?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.mp4&ct=g", - mp4_size: "23259", - webp: "https://media2.giphy.com/media/XAeEGyCbp8UehBPkSA/giphy.webp?cid=acd65332fv0sn3gzwa5vi4jw834l2hhwmfm6d90329p1590n&ep=v1_gifs_search&rid=giphy.webp&ct=g", - webp_size: "26984" - ), - original_still: nil, -// looping: nil, - preview: nil, - preview_gif: nil - ), - title: "Know GIF", - alt_text: "", - is_low_contrast: false - ).toGif + } }