-
Notifications
You must be signed in to change notification settings - Fork 33
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 #1204 from 18F/jk-md-tests
Add tests for github and md util
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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,34 @@ | ||
/* eslint no-undef: 0 */ | ||
|
||
import axios from 'axios' | ||
import sinon from 'sinon' | ||
|
||
import { createIssue } from '../../src/util/github' | ||
|
||
describe('github utility', () => { | ||
let sandbox | ||
const fakeIssue = { | ||
body: 'fake text', | ||
owner: '18f', | ||
repo: 'fake-repo', | ||
title: 'fake title', | ||
token: 'fake-token', | ||
} | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.sandbox.create() | ||
}) | ||
|
||
afterEach(() => { | ||
sandbox.restore() | ||
}) | ||
|
||
it('should post data to the github api', done => { | ||
const spy = sandbox.stub(axios, 'post', () => Promise.resolve([])) | ||
createIssue(fakeIssue).then(() => { | ||
const url = spy.getCall(0).args[0] | ||
expect(url).toEqual('https://api.github.com/repos/18f/fake-repo/issues') | ||
done() | ||
}) | ||
}) | ||
}) |
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,17 @@ | ||
/* eslint no-undef: 0 */ | ||
|
||
import markdown from '../../src/util/md' | ||
|
||
describe('markdown util', () => { | ||
it('should render markdown to html', () => { | ||
const actual = markdown.render('# test\nfake text') | ||
expect(actual.trim()).toEqual('<h1>test</h1>\n<p>fake text</p>') | ||
}) | ||
|
||
it('should properly render glossary links', () => { | ||
const actual = markdown.render('[yo](#glossary?term=yo)') | ||
expect(actual.trim()).toEqual( | ||
'<p><a href="#glossary?term=yo" class="underline glossary-icon glossary-icon-md">yo</a></p>', | ||
) | ||
}) | ||
}) |