mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-21 06:54:08 -07:00
Test that README apps are in Alphabetical order
This commit is contained in:
parent
4226685bde
commit
4ad0cc5171
1 changed files with 58 additions and 5 deletions
|
|
@ -23,16 +23,19 @@ test.before(async t => {
|
||||||
|
|
||||||
// Store sitemap urls to context
|
// Store sitemap urls to context
|
||||||
t.context.readmeFileContent = readmeFileContent
|
t.context.readmeFileContent = readmeFileContent
|
||||||
|
t.context.readmeAppList = buildReadmeAppList({
|
||||||
|
readmeContent: t.context.readmeFileContent,
|
||||||
|
scanListMap: new Map(),
|
||||||
|
commits: []
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('README App Titles are alphanumeric only', (t) => {
|
test('README App Titles are alphanumeric only', (t) => {
|
||||||
// console.log('t.context.sitemapUrls', t.context.sitemapUrls)
|
// console.log('t.context.sitemapUrls', t.context.sitemapUrls)
|
||||||
|
|
||||||
const readmeAppList = buildReadmeAppList({
|
const {
|
||||||
readmeContent: t.context.readmeFileContent,
|
readmeAppList
|
||||||
scanListMap: new Map(),
|
} = t.context
|
||||||
commits: []
|
|
||||||
})
|
|
||||||
|
|
||||||
// console.log('readmeAppList', readmeAppList)
|
// console.log('readmeAppList', readmeAppList)
|
||||||
t.log('readmeAppList', readmeAppList.length)
|
t.log('readmeAppList', readmeAppList.length)
|
||||||
|
|
@ -64,3 +67,53 @@ test('README App Titles are alphanumeric only', (t) => {
|
||||||
t.log( `${readmeAppList.length} valid alpanumeric app titles in readme` )
|
t.log( `${readmeAppList.length} valid alpanumeric app titles in readme` )
|
||||||
t.pass()
|
t.pass()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function sortAppsAlphabetically ( a, b ) {
|
||||||
|
return a.name.localeCompare(b.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test('README Apps are in alphbetical order', (t) => {
|
||||||
|
|
||||||
|
const {
|
||||||
|
readmeAppList
|
||||||
|
} = t.context
|
||||||
|
|
||||||
|
const appsByCategory = new Map()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Group apps by category
|
||||||
|
for ( const readmeApp of readmeAppList ) {
|
||||||
|
const category = readmeApp.category.slug
|
||||||
|
|
||||||
|
if ( !appsByCategory.has(category) ) {
|
||||||
|
appsByCategory.set(category, [])
|
||||||
|
}
|
||||||
|
|
||||||
|
appsByCategory.get( category ).push(readmeApp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort apps in groups alphabetically
|
||||||
|
for ( const [ category, apps ] of appsByCategory ) {
|
||||||
|
|
||||||
|
const unsortedApps = apps.slice()
|
||||||
|
|
||||||
|
// Sort apps in category in place
|
||||||
|
apps.sort(sortAppsAlphabetically)
|
||||||
|
|
||||||
|
// Check sorted sorted apps against unsorted apps
|
||||||
|
for ( const [ index, unsortedApp ] of unsortedApps.entries() ) {
|
||||||
|
const sortedApp = apps[index]
|
||||||
|
|
||||||
|
if ( sortedApp.slug !== unsortedApp.slug ) {
|
||||||
|
t.fail(`README App at index ${index} of ${category} is ${unsortedApp.name} but should be ${sortedApp.name}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.pass()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue