-
Notifications
You must be signed in to change notification settings - Fork 1
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 #2 from holidaycheck/switch-to-ava
Switch from jest to ava and sinon
- Loading branch information
Showing
8 changed files
with
2,009 additions
and
2,185 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
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
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
const index = require('../../index'); | ||
import test from 'ava'; | ||
import sinon from 'sinon'; | ||
import index from '../../index'; | ||
|
||
describe('index', () => { | ||
it('handles issue labels events', () => { | ||
const expectedEvents = ['issues.labeled', 'issues.unlabeled', 'issues.opened']; | ||
const robot = { on: jest.fn() }; | ||
index(robot); | ||
test('handles issue labels events', t => { | ||
const expectedEvents = ['issues.labeled', 'issues.unlabeled', 'issues.opened']; | ||
const robot = { on: sinon.spy() }; | ||
index(robot); | ||
|
||
expect(robot.on).toHaveBeenCalledTimes(1); | ||
const firstArgument = robot.on.mock.calls[0][0]; | ||
expect(firstArgument).toEqual(expectedEvents); | ||
}); | ||
t.is(robot.on.callCount, 1); | ||
t.deepEqual(robot.on.firstCall.args[0], expectedEvents); | ||
}); |
This file was deleted.
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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
const addLabel = require('../../../src/addLabel'); | ||
import test from 'ava'; | ||
import sinon from 'sinon'; | ||
import addLabel from '../../../src/addLabel'; | ||
|
||
describe('addLabel', () => { | ||
const issueNumber = 123; | ||
const owner = 'foo bar owner'; | ||
const repo = 'foobaria repo'; | ||
const labelName = 'some labelzzz'; | ||
const issueNumber = 123; | ||
const owner = 'foo bar owner'; | ||
const repo = 'foobaria repo'; | ||
const labelName = 'some labelzzz'; | ||
|
||
const createContext = (addLabels) => { | ||
const issue = { number: issueNumber }; | ||
const repository = { | ||
name: repo, | ||
owner: { login: owner } | ||
}; | ||
const createContext = (addLabels) => { | ||
const issue = { number: issueNumber }; | ||
const repository = { | ||
name: repo, | ||
owner: { login: owner } | ||
}; | ||
|
||
return { | ||
payload: { issue, repository }, | ||
github: { issues: { addLabels } } | ||
}; | ||
return { | ||
payload: { issue, repository }, | ||
github: { issues: { addLabels } } | ||
}; | ||
}; | ||
|
||
it('calls addLabel with correct issue object', () => { | ||
const addLabelsStub = jest.fn(); | ||
const context = createContext(addLabelsStub); | ||
addLabel(context, labelName); | ||
test('calls addLabel with correct issue object', t => { | ||
const addLabelsStub = sinon.stub(); | ||
const context = createContext(addLabelsStub); | ||
addLabel(context, labelName); | ||
|
||
expect(addLabelsStub).toHaveBeenCalledTimes(1); | ||
expect(addLabelsStub).toHaveBeenCalledWith({ | ||
number: issueNumber, | ||
labels: [labelName], | ||
owner, | ||
repo | ||
}); | ||
}); | ||
t.is(addLabelsStub.callCount, 1); | ||
t.true(addLabelsStub.calledWith({ | ||
number: issueNumber, | ||
labels: [labelName], | ||
owner, | ||
repo | ||
})); | ||
}); |
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 |
---|---|---|
@@ -1,43 +1,42 @@ | ||
const calculatePriority = require('../../../src/calculatePriority'); | ||
|
||
describe('calculatePriority', () => { | ||
it('calculate priority based on effort, potential and weight', () => { | ||
const metrics = { | ||
effort: 0.3, | ||
potential: 0.9, | ||
weight: 0.2 | ||
}; | ||
|
||
expect(calculatePriority(metrics)).toEqual('2.7'); | ||
}); | ||
|
||
it('rounds calculated priority', () => { | ||
const metrics = { | ||
effort: 0.1, | ||
potential: 0.2, | ||
weight: 0.3 | ||
}; | ||
|
||
expect(calculatePriority(metrics)).toEqual('1.6'); | ||
}); | ||
|
||
it('calculates max priority', () => { | ||
const metrics = { | ||
effort: 0.1, | ||
potential: 1, | ||
weight: 1 | ||
}; | ||
|
||
expect(calculatePriority(metrics)).toEqual('3.9'); | ||
}); | ||
|
||
it('calculates min priority', () => { | ||
const metrics = { | ||
effort: 1.0, | ||
potential: 0.1, | ||
weight: 0.1 | ||
}; | ||
|
||
expect(calculatePriority(metrics)).toEqual('0.3'); | ||
}); | ||
import test from 'ava'; | ||
import calculatePriority from '../../../src/calculatePriority'; | ||
|
||
test('calculates priority based on effort, potential and weight', t => { | ||
const metrics = { | ||
effort: 0.3, | ||
potential: 0.9, | ||
weight: 0.2 | ||
}; | ||
|
||
t.is(calculatePriority(metrics), '2.7'); | ||
}); | ||
|
||
test('rounds calculated priority', t => { | ||
const metrics = { | ||
effort: 0.1, | ||
potential: 0.2, | ||
weight: 0.3 | ||
}; | ||
|
||
t.is(calculatePriority(metrics), '1.6'); | ||
}); | ||
|
||
test('calculates max priority', t => { | ||
const metrics = { | ||
effort: 0.1, | ||
potential: 1, | ||
weight: 1 | ||
}; | ||
|
||
t.is(calculatePriority(metrics), '3.9'); | ||
}); | ||
|
||
test('calculates min priority', t => { | ||
const metrics = { | ||
effort: 1.0, | ||
potential: 0.1, | ||
weight: 0.1 | ||
}; | ||
|
||
t.is(calculatePriority(metrics), '0.3'); | ||
}); |
Oops, something went wrong.