mirror of
https://github.com/Snigdha-OS/Snigdha-OS.github.io.git
synced 2025-09-06 12:45:18 +02:00
🎨 style(new!): add new ui vue.js
Signed-off-by: Abhiraj Roy <157954129+iconized@users.noreply.github.com>
This commit is contained in:
39
test/github.test.js
Normal file
39
test/github.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { getGistById } from '../utils/github-api.js'
|
||||
|
||||
describe('Testing Github Gists API', () => {
|
||||
|
||||
const gistId1 = '799fe15f4b75706242b10d978e935067';
|
||||
|
||||
// do this before each test
|
||||
beforeEach(() => {
|
||||
|
||||
})
|
||||
|
||||
it('Response status is successfull: 200', async () => {
|
||||
|
||||
const getGithubGist = async (gistId) => await fetch('https://api.github.com/gists/' + gistId)
|
||||
const response = await getGithubGist(gistId1)
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
})
|
||||
|
||||
/**
|
||||
* Check if the response is a JSON
|
||||
*/
|
||||
it('The response is a JSON', async () => {
|
||||
|
||||
const gist = await getGistById(gistId1)
|
||||
|
||||
function isJson(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
expect(isJson(gist)).toBe(true)
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user