-
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.
Merge pull request #8 from katapod/tests_and_migrations
- Loading branch information
Showing
14 changed files
with
3,924 additions
and
3,601 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 22.2.0 |
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 |
---|---|---|
|
@@ -53,14 +53,15 @@ | |
"eslint-plugin-tsdoc": "^0.2.17", | ||
"jest": "^29.5.0", | ||
"jest-junit": "^16.0.0", | ||
"libxmljs": "^1.0.9", | ||
"prettier": "^2.8.8", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.24.7", | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.0.4", | ||
"xml-js": "^1.6.11" | ||
}, | ||
"dependencies": { | ||
"dom-parser": "^0.1.6" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha512.c2e60e7ed04e459591c982f2760cd8f7d1f48fe1ca4d46ccbbf8377df1eb2d077ace1e9d334b06250dddf23c03b4562858f77992b9a3bb4a93355aefd173df32" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 +1,4 @@ | ||
import { generateObjectFromXML } from './parser'; | ||
import { generateXMLFromObject } from './builder'; | ||
|
||
const cleanXML = `<?xml version="1.0" encoding="UTF-8"?> | ||
export const cleanXML = `<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet href="https://feeds.katapod.com/stylesheet.xsl" type="text/xsl"?> | ||
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0"> | ||
<channel> | ||
|
@@ -98,8 +95,74 @@ Website: https://auditorspodcast.katapod.com/1 | |
</channel> | ||
</rss> | ||
`; | ||
|
||
const targetJson = { | ||
export const dirtyXML = `<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet href="https://feeds.katapod.com/stylesheet.xsl" type="text/xsl"?> | ||
rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0"> | ||
<channel> | ||
<atom:link rel="self" type="application/atom+xml" href="https://feeds.katapod.com/auditors-of-the-outer-rim" title="MP3 Audio"/> | ||
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com/"/> | ||
<title>Auditors of the Outer Rim</title> | ||
<generator>Katapod (https://katapod.com)</generator> | ||
<itunes:new-feed-url>https://feeds.katapod.com/auditors-of-the-outer-rim</itunes:new-feed-url> | ||
<copyright>© 2020-2021 Auditors of the Outer Rim</copyright> | ||
<podcast:guid>00535402-5e2c-5454-a20a-7e0bf9ead225</podcast:guid> | ||
<podcast:locked owner="[email protected]">no</podcast:locked> | ||
<language>en</language> | ||
<pubDate>Fri, 15 Apr 2022 04:01:45 +1000</pubDate> | ||
<lastBuildDate>Thu, 01 Jun 2023 03:37:05 +1000</lastBuildDate> | ||
<link>https://twitter.com/AuditorsPodcast</link> | ||
<image> | ||
<url>https://images.katapod.com/file/Katapod/images/show/16601/full_1606823271-artwork.jpg</url> | ||
<title>Auditors of the Outer Rim</title> | ||
<link>https://twitter.com/AuditorsPodcast</link> | ||
</image> | ||
<itunes:category text="Leisure"> | ||
<itunes:category text="Games"/> | ||
</itunes:category> | ||
<itunes:category text="Fiction"> | ||
<itunes:category text="Science Fiction"/> | ||
</itunes:category> | ||
<itunes:type>serial</itunes:type> | ||
<itunes:author>Auditors of the Outer Rim</itunes:author> | ||
<itunes:image href="https://images.katapod.com/file/Katapod/images/show/16601/full_1606823271-artwork.jpg"/> | ||
<itunes:subtitle>A Star Wars roleplaying game featuring storytelling, adventure, chaos, and fun.</itunes:subtitle> | ||
<itunes:keywords>star wars, rpg, tabletop, roleplay, story, dice, edge of the empire, empire, dnd, d&d, adventure, improv, jedi, plot, homebrew, custom, investigation, mystery, discovery, intrigue </itunes:keywords> | ||
<itunes:owner> | ||
<itunes:name>Ryan Miller</itunes:name> | ||
</itunes:owner> | ||
<itunes:complete>No</itunes:complete> | ||
<itunes:explicit>No</itunes:explicit> | ||
<item> | ||
<title>Episode 1: The Auditors Are Born</title> | ||
<itunes:title>Episode 1: The Auditors Are Born</itunes:title> | ||
<itunes:episodeType>full</itunes:episodeType> | ||
<guid isPermaLink="false">727d6797-eab2-4aab-a0e6-cfe31a8d0c8a</guid> | ||
<link>https://share.katapod.com/s/3712446a</link> | ||
<description> | ||
<![CDATA[<p>This is the first episode of Auditors of the Outer Rim. We're using the Star Wars RPG Edge of the Empire by Fantasy Flight with a focus on fun and story before rules. Find us on Twitter <a href="https://twitter.com/AuditorsPodcast">@AuditorsPodcast</a> and on all major podcasting platforms.</p><p><strong>Cast:</strong> Ryan (GM), Tom (Mi-Shaan Li), Dan (Xeth), Damo (E-1), Will (Dahc). </p><p><strong>Story so far: </strong>Coming together out of necessity, this group of renegades escaped the grasp of their Hutt crime lord, stole his ship, liberated his slaves, and returned to end his reign. Their final escape from Tatooine caught the eye of the empire; narrowly avoiding destruction, they returned to Ryloth to seek help from those they saved. In exchange for future employment, their ship, renamed to The Auditor, was repaired and remade. The Auditors were born.</p><p><strong>Intro Crawl:<br></strong>Violence in the outer rim!</p><p>On the twin-sunned planet of TATOOINE, 4 escapees flee the quiet town of MOS SHUUTA and its ruler, TEEMO THE HUTT. Stealing an old freighter named the KRAYT FANG, the group of rebellious upstarts made for the planet of RYLOTH in the company of a Twi’lek prisoner.</p><p>Once there, the group uncovered a sinister plot of the HUTT, utilising slaves to mine an illegal substance known as SPICE. In eliminating TEEMO’s illegal activities, the party found themselves once more the focus of the HUTT’s wrath, leaving them but one option; eliminate the HUTT entirely.</p><p>A daring breach into the heart of TEEMO’s empire saw the party, disguised as AUDITORS, download and flee with all TEEMO’s business records that, once leaked, revealed TEEMO as shorthanding other members of the HUTT CLAN, permanently severing TEEMO from the power of their CLAN.</p><p>And such, a legend was born, adopting the name of the role that bought them their freedom as they roam the galaxy in search of fame, adoration, and of course, credits. This is the start of the group that would come to be known simply as the Auditors.</p><p><br><strong>Check out our links: </strong></p><p>🔗 <a href="https://linktr.ee/AuditorsPodcast">https://linktr.ee/AuditorsPodcast</a></p><p>🐦 <a href="https://twitter.com/AuditorsPodcast">https://twitter.com/AuditorsPodcast</a></p><p>🎙️ <a href="https://open.spotify.com/show/0xEF4DiEIibOVgYC6PK7eP">https://open.spotify.com/show/0xEF4DiEIibOVgYC6PK7eP</a></p><p>🍎 <a href="https://podcasts.apple.com/au/podcast/auditors-of-the-outer-rim/id1543140409">https://podcasts.apple.com/au/podcast/auditors-of-the-outer-rim/id1543140409</a></p><p>📺 <a href="https://www.youtube.com/channel/UCQJaT5gVoalzBqlNhwq5T8Q">https://www.youtube.com/channel/UCQJaT5gVoalzBqlNhwq5T8Q</a></p><p>✉️ <a href="https://[email protected]"><span class="__cf_email__" data-cfemail="046561766d687d69666d7e446369656d682a676b69">[email protected]</span></a></p><p>Original music provided with licenced or permission by: </p><p>"Seatbelt On" - Brightarm Orchestra on Epidemic Sound - <a href="https://www.epidemicsound.com/track/LCZ68X6PLC/">https://www.epidemicsound.com/track/LCZ68X6PLC/</a></p><p>Unlisted music, sounds, artwork, and assets are created by the people in this podcast and are provided with permission for use in this podcast and any related official or approved content.</p><p>If anyone wishes to use any audio or visual elements from this podcast, they may do so with appropriate attribution. We encourage you to use our works, but please contact <a href="https://[email protected]"><span class="__cf_email__" data-cfemail="7e1f1b0c171207131c17043e19131f1712501d1113">[email protected]</span></a> if you wish to do so out of courtesy and to ensure it's ok.</p><p>© 2020-2021 Auditors of the Outer Rim</p>]]> | ||
</description> | ||
<content:encoded> | ||
<![CDATA[<p>This is the first episode of Auditors of the Outer Rim. We're using the Star Wars RPG Edge of the Empire by Fantasy Flight with a focus on fun and story before rules. Find us on Twitter <a href="https://twitter.com/AuditorsPodcast">@AuditorsPodcast</a> and on all major podcasting platforms.</p><p><strong>Cast:</strong> Ryan (GM), Tom (Mi-Shaan Li), Dan (Xeth), Damo (E-1), Will (Dahc). </p><p><strong>Story so far: </strong>Coming together out of necessity, this group of renegades escaped the grasp of their Hutt crime lord, stole his ship, liberated his slaves, and returned to end his reign. Their final escape from Tatooine caught the eye of the empire; narrowly avoiding destruction, they returned to Ryloth to seek help from those they saved. In exchange for future employment, their ship, renamed to The Auditor, was repaired and remade. The Auditors were born.</p><p><strong>Intro Crawl:<br></strong>Violence in the outer rim!</p><p>On the twin-sunned planet of TATOOINE, 4 escapees flee the quiet town of MOS SHUUTA and its ruler, TEEMO THE HUTT. Stealing an old freighter named the KRAYT FANG, the group of rebellious upstarts made for the planet of RYLOTH in the company of a Twi’lek prisoner.</p><p>Once there, the group uncovered a sinister plot of the HUTT, utilising slaves to mine an illegal substance known as SPICE. In eliminating TEEMO’s illegal activities, the party found themselves once more the focus of the HUTT’s wrath, leaving them but one option; eliminate the HUTT entirely.</p><p>A daring breach into the heart of TEEMO’s empire saw the party, disguised as AUDITORS, download and flee with all TEEMO’s business records that, once leaked, revealed TEEMO as shorthanding other members of the HUTT CLAN, permanently severing TEEMO from the power of their CLAN.</p><p>And such, a legend was born, adopting the name of the role that bought them their freedom as they roam the galaxy in search of fame, adoration, and of course, credits. This is the start of the group that would come to be known simply as the Auditors.</p><p><br><strong>Check out our links: </strong></p><p>🔗 <a href="https://linktr.ee/AuditorsPodcast">https://linktr.ee/AuditorsPodcast</a></p><p>🐦 <a href="https://twitter.com/AuditorsPodcast">https://twitter.com/AuditorsPodcast</a></p><p>🎙️ <a href="https://open.spotify.com/show/0xEF4DiEIibOVgYC6PK7eP">https://open.spotify.com/show/0xEF4DiEIibOVgYC6PK7eP</a></p><p>🍎 <a href="https://podcasts.apple.com/au/podcast/auditors-of-the-outer-rim/id1543140409">https://podcasts.apple.com/au/podcast/auditors-of-the-outer-rim/id1543140409</a></p><p>📺 <a href="https://www.youtube.com/channel/UCQJaT5gVoalzBqlNhwq5T8Q">https://www.youtube.com/channel/UCQJaT5gVoalzBqlNhwq5T8Q</a></p><p>✉️ <a href="https://[email protected]"><span class="__cf_email__" data-cfemail="b1d0d4c3d8ddc8dcd3d8cbf1d6dcd0d8dd9fd2dedc">[email protected]</span></a></p><p>Original music provided with licenced or permission by: </p><p>"Seatbelt On" - Brightarm Orchestra on Epidemic Sound - <a href="https://www.epidemicsound.com/track/LCZ68X6PLC/">https://www.epidemicsound.com/track/LCZ68X6PLC/</a></p><p>Unlisted music, sounds, artwork, and assets are created by the people in this podcast and are provided with permission for use in this podcast and any related official or approved content.</p><p>If anyone wishes to use any audio or visual elements from this podcast, they may do so with appropriate attribution. We encourage you to use our works, but please contact <a href="https://[email protected]"><span class="__cf_email__" data-cfemail="036266716a6f7a6e616a7943646e626a6f2d606c6e">[email protected]</span></a> if you wish to do so out of courtesy and to ensure it's ok.</p><p>© 2020-2021 Auditors of the Outer Rim</p>]]> | ||
</content:encoded> | ||
<pubDate>Wed, 02 Dec 2020 01:59:54 +1100</pubDate> | ||
<author>Auditors of the Outer Rim</author> | ||
<enclosure url="https://media.katapod.com/3712446a/ece1bd1a.mp3" length="125885781" type="audio/mpeg"/> | ||
<itunes:author>Auditors of the Outer Rim</itunes:author> | ||
<itunes:image href="https://images.katapod.com/file/Katapod/images/show/16601/full_1606823271-artwork.jpg"/> | ||
<itunes:duration>7863</itunes:duration> | ||
<itunes:summary>Coming together out of necessity, this group of renegades escaped the grasp of their Hutt crime lord, stole his ship, liberated his slaves, and returned to end his reign. Their final escape from Tatooine caught the eye of the empire; narrowly avoiding destruction, they returned to Ryloth to seek help from those they saved. In exchange for future employment, their ship, renamed to The Auditor, was repaired and remade. The Auditors were born. | ||
Show Notes: https://share.katapod.com/s/3712446a | ||
Website: https://auditorspodcast.katapod.com/1 | ||
</itunes:summary> | ||
<itunes:subtitle>Coming together out of necessity, this group of renegades escaped the grasp of their Hutt crime lord, stole his ship, liberated his slaves, and returned to end his reign. Their final escape from Tatooine caught the eye of the empire; narrowly avoiding des</itunes:subtitle> | ||
<itunes:keywords>star wars, rpg, tabletop, roleplay, story, dice, edge of the empire, empire, dnd, d&d, adventure, improv, jedi, plot, homebrew, custom, investigation, mystery, discovery, intrigue | ||
</itunes:keywords> | ||
<itunes:explicit>No</itunes:explicit> | ||
</item> | ||
</channel> | ||
</rss> | ||
`; | ||
export const targetJson = { | ||
'?xml-stylesheet': { | ||
'@href': 'https://feeds.katapod.com/stylesheet.xsl', | ||
'@type': 'text/xsl', | ||
|
@@ -240,30 +303,3 @@ Website: https://auditorspodcast.katapod.com/1`, | |
}, | ||
}, | ||
}; | ||
|
||
describe('Parser Functionality', () => { | ||
it('Creates JSON from real XML', async () => { | ||
const json = generateObjectFromXML(cleanXML); | ||
|
||
expect(json).toBeDefined(); | ||
|
||
const generatedJson = { | ||
'?xml-stylesheet': { | ||
'@href': 'https://feeds.katapod.com/stylesheet.xsl', | ||
'@type': 'text/xsl', | ||
}, | ||
rss: { | ||
'@version': '2.0', | ||
'@xmlns:dc': 'http://purl.org/dc/elements/1.1/', | ||
'@xmlns:atom': 'http://www.w3.org/2005/Atom', | ||
'@xmlns:sy': 'http://purl.org/rss/1.0/modules/syndication/', | ||
'@xmlns:content': 'http://purl.org/rss/1.0/modules/content/', | ||
'@xmlns:itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd', | ||
'@xmlns:podcast': 'https://podcastindex.org/namespace/1.0', | ||
channel: json, | ||
}, | ||
}; | ||
|
||
expect(generatedJson).toStrictEqual(targetJson); | ||
}); | ||
}); |
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,11 @@ | ||
import { xml2json } from 'xml-js'; | ||
|
||
export const isValidXml = (xml: string) => { | ||
try { | ||
const res = xml2json(xml); | ||
|
||
return !!(res && res.length > 0); | ||
} catch (error) { | ||
return false; | ||
} | ||
}; |
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,10 +1,10 @@ | ||
describe('index', () => { | ||
it('should export generateXMLFromObject', () => { | ||
const { generateXMLFromObject } = require('./index'); | ||
const { generateXMLFromObject } = require('../src/index'); | ||
expect(generateXMLFromObject).toBeDefined(); | ||
}); | ||
it('should export generateObjectFromXML', () => { | ||
const { generateObjectFromXML } = require('./index'); | ||
const { generateObjectFromXML } = require('../src/index'); | ||
expect(generateObjectFromXML).toBeDefined(); | ||
}); | ||
}); |
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,29 @@ | ||
import { generateObjectFromXML } from '../src/parser'; | ||
import { cleanXML, targetJson } from '../src/constants'; | ||
|
||
describe('Parser Functionality', () => { | ||
it('Creates JSON from real XML', async () => { | ||
const json = generateObjectFromXML(cleanXML); | ||
|
||
expect(json).toBeDefined(); | ||
|
||
const generatedJson = { | ||
'?xml-stylesheet': { | ||
'@href': 'https://feeds.katapod.com/stylesheet.xsl', | ||
'@type': 'text/xsl', | ||
}, | ||
rss: { | ||
'@version': '2.0', | ||
'@xmlns:dc': 'http://purl.org/dc/elements/1.1/', | ||
'@xmlns:atom': 'http://www.w3.org/2005/Atom', | ||
'@xmlns:sy': 'http://purl.org/rss/1.0/modules/syndication/', | ||
'@xmlns:content': 'http://purl.org/rss/1.0/modules/content/', | ||
'@xmlns:itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd', | ||
'@xmlns:podcast': 'https://podcastindex.org/namespace/1.0', | ||
channel: json, | ||
}, | ||
}; | ||
|
||
expect(generatedJson).toStrictEqual(targetJson); | ||
}); | ||
}); |
Oops, something went wrong.