@@ -7,77 +7,40 @@ var nodegit = require("../../");
77var Repository = nodegit . Repository ;
88
99describe ( "Commit" , function ( ) {
10- var historyCountKnownSHA = "fce88902e66c72b5b93e75bdb5ae717038b221f6" ;
1110 var reposPath = path . resolve ( "test/repos/workdir/.git" ) ;
11+ var historyCountKnownSHA = "fce88902e66c72b5b93e75bdb5ae717038b221f6" ;
1212
1313 var Commit = require ( "./commit" ) ;
1414
15- describe ( "when fetched" , function ( ) {
16-
17- it ( "makes its message available" , function ( done ) {
18- Repository . open ( reposPath , function ( error , repository ) {
19- repository . getCommit ( historyCountKnownSHA , function ( error , commit ) {
20- var message = commit . message ( ) ;
21-
22- assert . equal ( error , null ) ;
23- assert . equal ( message , "Update README.md" ) ;
24-
25- done ( ) ;
26- } ) ;
27- } ) ;
28- } ) ;
29-
30- it ( "makes its sha available" , function ( done ) {
31- Repository . open ( reposPath , function ( error , repository ) {
32- repository . getCommit ( historyCountKnownSHA , function ( error , commit ) {
33- var sha = commit . sha ( ) ;
34-
35- assert . equal ( error , null ) ;
36- assert . equal ( sha , historyCountKnownSHA ) ;
37-
38- done ( ) ;
39- } ) ;
40- } ) ;
41- } ) ;
42-
43- it ( "makes its time available" , function ( done ) {
44- Repository . open ( reposPath , function ( error , repository ) {
45- repository . getCommit ( historyCountKnownSHA , function ( error , commit ) {
46- var time = commit . timeMs ( ) ;
15+ beforeEach ( function ( ) {
16+ var test = this ;
4717
48- assert . equal ( error , null ) ;
49- assert . equal ( time , 1362012884000 ) ;
18+ return Repository . open ( reposPath ) . then ( function ( repository ) {
19+ test . repository = repository ;
5020
51- done ( ) ;
52- } ) ;
21+ return repository . getCommit ( historyCountKnownSHA ) . then ( function ( commit ) {
22+ test . commit = commit ;
5323 } ) ;
5424 } ) ;
25+ } ) ;
5526
56- it ( "makes its date available" , function ( done ) {
57- Repository . open ( reposPath , function ( error , repository ) {
58- repository . getCommit ( historyCountKnownSHA , function ( error , commit ) {
59- var date = commit . date ( ) ;
60-
61- assert . equal ( error , null ) ;
62- assert . equal ( date . getTime ( ) , 1362012884000 ) ;
63-
64- done ( ) ;
65- } ) ;
66- } ) ;
67- } ) ;
27+ it ( "makes its message available" , function ( ) {
28+ assert . equal ( this . commit . message ( ) , "Update README.md" ) ;
29+ } ) ;
6830
69- it ( "makes its offset available" , function ( done ) {
70- Repository . open ( reposPath , function ( error , repository ) {
71- repository . getCommit ( historyCountKnownSHA , function ( error , commit ) {
72- var offset = commit . offset ( ) ;
31+ it ( "makes its sha available" , function ( ) {
32+ assert . equal ( this . commit . sha ( ) , historyCountKnownSHA ) ;
33+ } ) ;
7334
74- assert . equal ( error , null ) ;
75- assert . equal ( offset , 780 ) ;
35+ it ( "makes its time available" , function ( ) {
36+ assert . equal ( this . commit . timeMs ( ) , 1362012884000 ) ;
37+ } ) ;
7638
77- done ( ) ;
78- } ) ;
79- } ) ;
80- } ) ;
39+ it ( "makes its date available" , function ( ) {
40+ assert . equal ( this . commit . date ( ) . getTime ( ) , 1362012884000 ) ;
41+ } ) ;
8142
43+ it ( "makes its offset available" , function ( ) {
44+ assert . equal ( this . commit . offset ( ) , 780 ) ;
8245 } ) ;
8346} ) ;
0 commit comments