Skip to content

Commit

Permalink
test: add test to validate log output structure
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 committed Dec 4, 2018
1 parent 739bbfd commit 58fd6df
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
39 changes: 39 additions & 0 deletions lib/log.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const log = require('./log')
const chalk = require('chalk')
const stripAnsi = require('strip-ansi');

test('should return formatted log', async () => {
const org = 'foojs'
const repo = 'barjs'
const issue = {
title: 'Add BAZ support',
pr: 123,
labels: [[Object], [Object], [Object]],
state: 'open',
repo: `https://api.github.com/${org}/${repo}`,
url: `https://github.com/${org}/${repo}/issues/123`,
assignee: null,
assignees: [],
locked: false
}

const expectedOutput = `
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ Good First Issue in foojs: โ”‚
โ”‚ โ”‚
โ”‚ - Title: Add BAZ support โ”‚
โ”‚ - Repository: foojs/barjs โ”‚
โ”‚ - Issue: #123 โ”‚
โ”‚ - Status: open โ”‚
โ”‚ - Assigned to: unassigned! โ”‚
โ”‚ โ”‚
โ”‚ Start now: https://github.com/foojs/barjs/issues/123 โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
`

const actualOutput = await log(issue, org)

expect(expectedOutput).toBe(stripAnsi(actualOutput))
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"devDependencies": {
"jest": "^23.6.0",
"markdown-magic": "^0.1.25",
"standard": "^12.0.1"
"standard": "^12.0.1",
"strip-ansi": "^5.0.0"
}
}

0 comments on commit 58fd6df

Please sign in to comment.