-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dashboard_integration_tests
- Loading branch information
Showing
5 changed files
with
110 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { getAllPosts, getPostBySlug, getDocBySlug } from '../../../lib/api'; | ||
import posts from '../../../config/posts.json' | ||
describe('getAllPosts', () => { | ||
it('should return all posts', () => { | ||
const allPosts = getAllPosts(); | ||
expect(allPosts).to.deep.equal(posts); | ||
}); | ||
}); | ||
|
||
describe('getPostBySlug', () => { | ||
it('should return the post with the given slug', () => { | ||
const slug = '/blog/2023-may-docs-report'; | ||
const post = getPostBySlug(slug); | ||
const expectedPost = posts.blog.find((p) => p.slug === slug && !p.isSection); | ||
expect(post).to.deep.equal(expectedPost); | ||
}); | ||
|
||
it('should return the post of a specific type with the given slug', () => { | ||
const slug = '/blog/2023-may-docs-report'; | ||
const type = 'blog'; | ||
const post = getPostBySlug(slug, type); | ||
const expectedPost = posts[type].find((p) => p.slug === slug && !p.isSection); | ||
expect(post).to.deep.equal(expectedPost); | ||
}); | ||
}); | ||
|
||
describe('getDocBySlug', () => { | ||
it('should return the document with the given slug', () => { | ||
const structuredPosts = posts['docs'] | ||
const slug = '/docs/concepts'; | ||
const doc = getDocBySlug(structuredPosts, slug); | ||
const expectedDoc = structuredPosts.find((post) => post.slug === slug && !post.isSection); | ||
expect(doc).to.deep.equal(expectedDoc); | ||
}); | ||
|
||
}); | ||
|
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,45 @@ | ||
import { getEvents } from '../../../lib/staticHelpers'; | ||
|
||
describe('getEvents', () => { | ||
it('should return sorted events in ascending order', () => { | ||
const events = [ | ||
{ | ||
"title": "Community Meeting", | ||
"calLink": "https://www.google.com/calendar/event?eid=czRmMG5maHRsYjduM2g3dmwxMDM1Z3R0NzAgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn", | ||
"url": "https://github.com/asyncapi/community/issues/645", | ||
"date": "2023-04-04T08:00:00.000Z" | ||
}, | ||
{ | ||
"title": "Spec 3.0 Meeting", | ||
"calLink": "https://www.google.com/calendar/event?eid=djhsdjZvbmRsampvb2tsYzhkZWFyc3FtYTAgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn", | ||
"url": "https://github.com/asyncapi/community/issues/649", | ||
"date": "2023-04-13T15:00:00.000Z" | ||
}, | ||
{ | ||
"title": "Community Meeting", | ||
"calLink": "https://www.google.com/calendar/event?eid=MzgwdmZiMTc4cnBmbTUzdWVlbmM4aWYyM2MgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn", | ||
"url": "https://github.com/asyncapi/community/issues/659", | ||
"banner": "https://user-images.githubusercontent.com/40604284/229763606-c0b6ed3b-e120-427c-b87d-357856d92777.png", | ||
"date": "2023-04-18T16:00:00.000Z" | ||
}, | ||
]; | ||
|
||
cy.wrap(events).as('events'); | ||
|
||
// Call the getEvents function | ||
cy.get('@events').then((events) => { | ||
const sortedEvents = getEvents(events); | ||
|
||
// Check if the result is an array | ||
expect(sortedEvents).to.be.an('array'); | ||
|
||
// Convert dates to timestamps for comparison | ||
const sortedTimestamps = sortedEvents.map((event) => event.date.valueOf()); | ||
|
||
// Check if the timestamps are sorted in ascending order | ||
for (let i = 0; i < sortedTimestamps.length - 1; i++) { | ||
expect(sortedTimestamps[i]).to.be.greaterThan(sortedTimestamps[i + 1]); | ||
} | ||
}); | ||
}); | ||
}); |