Skip to content

Commit

Permalink
Merge pull request #1204 from 18F/jk-md-tests
Browse files Browse the repository at this point in the history
Add tests for github and md util
  • Loading branch information
jpwentz authored Aug 11, 2017
2 parents f4f6b1f + d6f1f58 commit fd40e05
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/util/github.test.js
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()
})
})
})
17 changes: 17 additions & 0 deletions test/util/md.test.js
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>',
)
})
})

0 comments on commit fd40e05

Please sign in to comment.