11'use strict' ;
22
3- // module dependencies
4- var chai = require ( 'chai' ) , sinonChai = require ( 'sinon-chai' ) ;
3+ var github , repo , user , test_user ;
54
6- var Github = require ( '../' ) ;
7- var test_user = require ( './user.json' ) ;
5+ if ( typeof window === 'undefined' ) {
6+ // module dependencies
7+ var chai = require ( 'chai' ) ,
8+ sinonChai = require ( 'sinon-chai' ) ;
89
9- // Use should flavour for Mocha
10- var should = chai . should ( ) ;
11- chai . use ( sinonChai ) ;
10+ var Github = require ( '../' ) ;
11+ test_user = require ( './user.json' ) ;
12+
13+ // Use should flavour for Mocha
14+ var should = chai . should ( ) ;
15+ chai . use ( sinonChai ) ;
16+ }
1217
1318describe ( 'Github.Repository' , function ( ) {
14- var github = new Github ( {
15- username : test_user . USERNAME ,
16- password : test_user . PASSWORD ,
17- auth : 'basic'
19+ before ( function ( ) {
20+ if ( typeof window !== 'undefined' ) test_user = window . __fixtures__ [ 'test/user' ] ;
21+
22+ github = new Github ( {
23+ username : test_user . USERNAME ,
24+ password : test_user . PASSWORD ,
25+ auth : 'basic'
26+ } ) ;
27+
28+ repo = github . getRepo ( 'michael' , 'github' ) ;
1829 } ) ;
19- var repo = github . getRepo ( 'michael' , 'github' ) ;
2030
2131 it ( 'should show repo' , function ( done ) {
2232 repo . show ( function ( err , res ) {
@@ -82,7 +92,7 @@ describe('Github.Repository', function() {
8292 it ( 'should get a SHA from a repo' , function ( done ) {
8393 repo . getSha ( 'master' , '.gitignore' , function ( err , sha ) {
8494 should . not . exist ( err ) ;
85- sha . should . equal ( '8293a5658aed839ed52fb0e5bd9e6c467c992d3d ' ) ;
95+ sha . should . equal ( '743f72052be92b3e7f42b8318f2663a9011ef5be ' ) ;
8696 done ( ) ;
8797 } ) ;
8898 } ) ;
@@ -100,12 +110,18 @@ describe('Github.Repository', function() {
100110var repoTest = Math . floor ( Math . random ( ) * ( 100000 - 0 ) ) + 0 ;
101111
102112describe ( 'Creating new Github.Repository' , function ( ) {
103- var github = new Github ( {
104- username : test_user . USERNAME ,
105- password : test_user . PASSWORD ,
106- auth : 'basic'
113+ before ( function ( ) {
114+ if ( typeof window !== 'undefined' ) test_user = window . __fixtures__ [ 'test/user' ] ;
115+
116+ github = new Github ( {
117+ username : test_user . USERNAME ,
118+ password : test_user . PASSWORD ,
119+ auth : 'basic'
120+ } ) ;
121+
122+ user = github . getUser ( ) ;
123+ repo = github . getRepo ( test_user . USERNAME , repoTest ) ;
107124 } ) ;
108- var user = github . getUser ( ) ;
109125
110126 it ( 'should create repo' , function ( done ) {
111127 user . createRepo ( { 'name' : repoTest } , function ( err , res ) {
@@ -115,8 +131,6 @@ describe('Creating new Github.Repository', function() {
115131 } ) ;
116132 } ) ;
117133
118- var repo = github . getRepo ( test_user . USERNAME , repoTest ) ;
119-
120134 it ( 'should write to repo' , function ( done ) {
121135 repo . write ( 'master' , 'TEST.md' , 'THIS IS A TEST' , 'Creating test' , function ( err ) {
122136 should . not . exist ( err ) ;
@@ -267,12 +281,15 @@ describe('Creating new Github.Repository', function() {
267281} ) ;
268282
269283describe ( 'deleting a Github.Repository' , function ( ) {
270- var github = new Github ( {
271- username : test_user . USERNAME ,
272- password : test_user . PASSWORD ,
273- auth : 'basic'
284+ before ( function ( ) {
285+ if ( typeof window !== 'undefined' ) test_user = window . __fixtures__ [ 'test/user' ] ;
286+ github = new Github ( {
287+ username : test_user . USERNAME ,
288+ password : test_user . PASSWORD ,
289+ auth : 'basic'
290+ } ) ;
291+ repo = github . getRepo ( test_user . USERNAME , repoTest ) ;
274292 } ) ;
275- var repo = github . getRepo ( test_user . USERNAME , repoTest ) ;
276293
277294 it ( 'should delete the repo' , function ( done ) {
278295 repo . deleteRepo ( function ( err , res ) {
@@ -284,12 +301,15 @@ describe('deleting a Github.Repository', function() {
284301} ) ;
285302
286303describe ( 'Repo returns commit errors correctly' , function ( ) {
287- var github = new Github ( {
288- username : test_user . USERNAME ,
289- password : test_user . PASSWORD ,
290- auth : 'basic'
304+ before ( function ( ) {
305+ if ( typeof window !== 'undefined' ) test_user = window . __fixtures__ [ 'test/user' ] ;
306+ github = new Github ( {
307+ username : test_user . USERNAME ,
308+ password : test_user . PASSWORD ,
309+ auth : 'basic'
310+ } ) ;
311+ repo = github . getRepo ( test_user . USERNAME , test_user . REPO ) ;
291312 } ) ;
292- var repo = github . getRepo ( test_user . USERNAME , test_user . REPO ) ;
293313
294314 it ( 'should fail on broken commit' , function ( done ) {
295315 repo . commit ( 'broken-parent-hash' , 'broken-tree-hash' , 'commit message' , function ( err ) {
0 commit comments