Skip to content

Commit

Permalink
test: Added unit tests for commit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Oct 11, 2014
1 parent 121b992 commit 504a61a
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 62 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a name="">Git changelog</a>
# (2014-10-07)
# (2014-10-11)


## Documentation
Expand All @@ -21,6 +21,8 @@

## Features

- Working on new API
([121b9928](https://github.com/rafinskipg/git-changelog/commits/121b99285d2a04f9159951fa0e3f849d0d618fef))
- **bootstrap:** creating initial structure
([dea45d68](https://github.com/rafinskipg/git-changelog/commits/dea45d68ce9555e876680bf7c0778add2f367a30))
- **grunt-plugin:** Now it is ready to be a grunt plugin
Expand Down
43 changes: 43 additions & 0 deletions EXTENDEDCHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<a name="">Git changelog extended</a>
# (2014-10-11)


## Documentation

- Added docs
([e0ba50c0](https://github.com/rafinskipg/git-changelog/commits/e0ba50c0bb0b13e9b39a59b8f4dda96e86d55644))
- **readme:** Final readme Fixes #1 Closes #1
([e725d8f4](https://github.com/rafinskipg/git-changelog/commits/e725d8f4bf477b517ca6185a75fdfa0aa660b3be))


## Bug Fixes

- **git_changelog_generate:** pass tag if it exists to gitReadLog
([7c801927](https://github.com/rafinskipg/git-changelog/commits/7c801927672792fc9a818653b74c78d77c7bff9e),
[#5](https://github.com/rafinskipg/git-changelog/issues/5))
- **package.json:** move q to dependancies since it is required to run
([257119cf](https://github.com/rafinskipg/git-changelog/commits/257119cf2bb6d8f341a5d65a2f47bcf803dff205))


## Features

- Working on new API
([121b9928](https://github.com/rafinskipg/git-changelog/commits/121b99285d2a04f9159951fa0e3f849d0d618fef))
- **bootstrap:** creating initial structure
([dea45d68](https://github.com/rafinskipg/git-changelog/commits/dea45d68ce9555e876680bf7c0778add2f367a30))
- **grunt-plugin:** Now it is ready to be a grunt plugin
([6422e055](https://github.com/rafinskipg/git-changelog/commits/6422e0552b30f6e94d11b03310a23c1342aa5965))


## Refactor

- **delete:** deleted some files- **docs:**
- Angular document commits - Added docs

## Docs

- Added docs- **readme:** Final readme Fixes #1 Closes #1

## Breaking Changes


15 changes: 12 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ module.exports = function(grunt) {
nodeunit: {
tests: ['test/*_test.js'],
},

mochaTest: {
test: {
options: {
reporter: 'spec',
captureFile: 'tests/results.txt', // Optionally capture the reporter output to a file
quiet: false // Optionally suppress output to standard out (defaults to false)
},
src: ['test/**/*.spec.js']
}
}
});

// Actually load this plugin's task(s).
Expand All @@ -59,11 +68,11 @@ module.exports = function(grunt) {
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-mocha-test');

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'git_changelog', 'nodeunit']);
grunt.registerTask('test', ['clean', 'git_changelog', 'mochaTest']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
Expand Down
18 changes: 18 additions & 0 deletions fixtures/list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did one thing
==END==
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did 2 thing
==END==
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did 3 thing
==END==
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did 4 thing
==END==
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did 5 thing
==END==
1d4f604363094d4eee3b4d7b1ca01133edaad344
chore($scope): did 6 thing
==END==
17 changes: 17 additions & 0 deletions fixtures/logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
1d4f604363094d4eee3b4d7b1ca01133edaad344
Merge pull request #7 from colegleason/fix-tags
fix(git_changelog_generate): pass tag if it exists to gitReadLog
==END==
2a712b9cfd912f36b6f7f70d16b336575881881a
Merge pull request #6 from colegleason/add-q
fix(package.json): move q to dependancies since it is required to run
==END==
7c801927672792fc9a818653b74c78d77c7bff9e
fix(git_changelog_generate): pass tag if it exists to gitReadLog
Previously if a tag was found the script would try to find commits
between undefined..HEAD. By passing the tag, it now finds tags between
tag..HEAD.

Closes #5.

==END==
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"q": "~0.9.7"
},
"devDependencies": {
"chai": "^1.9.2",
"exec": "0.0.6",
"grunt": "^0.4.5",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-nodeunit": "~0.2.0"
"grunt-mocha-test": "^0.12.1",
"mocha": "^1.21.4"
},
"peerDependencies": {
"grunt": "~0.4.1"
Expand Down
31 changes: 23 additions & 8 deletions test/changelog.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';
var fs = require('fs'),
expect = require('chai').expect;

describe('changelog.js', function() {
var ch = require('./changelog');
var ch = require('../tasks/git_changelog_generate');

describe('parseRawCommit', function() {
it('should parse raw commit', function() {
Expand All @@ -11,12 +13,12 @@ describe('changelog.js', function() {
'perf testing shows that in chrome this change adds 5-15% overhead\n' +
'when destroying 10k nested scopes where each scope has a $destroy listener\n');

expect(msg.type).toBe('feat');
expect(msg.hash).toBe('9b1aff905b638aa274a5fc8f88662df446d374bd');
expect(msg.subject).toBe('broadcast $destroy event on scope destruction');
expect(msg.body).toBe('perf testing shows that in chrome this change adds 5-15% overhead\n' +
expect(msg.type).to.equal('feat');
expect(msg.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd');
expect(msg.subject).to.equal('broadcast $destroy event on scope destruction');
expect(msg.body).to.equal('perf testing shows that in chrome this change adds 5-15% overhead\n' +
'when destroying 10k nested scopes where each scope has a $destroy listener\n')
expect(msg.component).toBe('scope');
expect(msg.component).to.equal('scope');
});


Expand All @@ -27,7 +29,8 @@ describe('changelog.js', function() {
'bla bla bla\n\n' +
'Closes #123\nCloses #25\n');

expect(msg.closes).toEqual([123, 25]);
expect(msg.closes[0]).to.equal(123);
expect(msg.closes[1]).to.equal(25);
});


Expand All @@ -39,7 +42,19 @@ describe('changelog.js', function() {
'BREAKING CHANGE: first breaking change\nsomething else\n' +
'another line with more info\n');

expect(msg.breaking).toEqual(' first breaking change\nsomething else\nanother line with more info\n');
expect(msg.breaking).to.equal(' first breaking change\nsomething else\nanother line with more info\n');
});
});

describe('File creation', function(){
it('should create A CHANGELOG.md', function(){
var exists_file = fs.existsSync('CHANGELOG.md');
expect(exists_file).to.equal(true);
});

it('should create A EXTENDEDCHANGELOG.md', function(){
var exists_file = fs.existsSync('EXTENDEDCHANGELOG.md');
expect(exists_file).to.equal(true);
});
});
});
49 changes: 0 additions & 49 deletions test/git_changelog_test.js

This file was deleted.

14 changes: 14 additions & 0 deletions tests/results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


 changelog.js
 parseRawCommit
  ✓ should parse raw commit 
  ✓ should parse closed issues 
  ✓ should parse breaking changes 
 File creation
  ✓ should create A CHANGELOG.md 
  ✓ should create A EXTENDEDCHANGELOG.md 


  5 passing (8ms)

0 comments on commit 504a61a

Please sign in to comment.