Skip to content

Commit 9524694

Browse files
committed
refactor(tests): Linting and Re-indenting tests
1 parent 9fc9f67 commit 9524694

22 files changed

+998
-998
lines changed

tests/downgrade.test.js

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,117 @@
1-
var chai = require( 'chai' )
1+
var chai = require('chai')
22
, expect = chai.expect
33
, exec = require('child_process').exec
4-
, path = require( 'path' )
5-
, semver = require( 'semver' )
6-
, fs = require( 'fs' )
7-
, binPath = path.join( __dirname, '..', 'bin' )
8-
, assetPath = path.join( __dirname, 'assets' );
4+
, path = require('path')
5+
, semver = require('semver')
6+
, fs = require('fs')
7+
, binPath = path.join(__dirname, '..', 'bin')
8+
, assetPath = path.join(__dirname, 'assets');
99

1010
chai.config.includeStack = true;
1111

12-
describe( 'Downgrade', function ( ) {
13-
describe( 'backend', function ( ) {
14-
before( function ( done ) {
15-
// console.log( 'Installing backend-example-module for tests...' );
16-
exec( path.join( binPath, 'clever-install' ) + ' backend-example-module', { cwd: path.join( assetPath, 'my-new-project', 'backend' ) }, function ( err ) {
17-
// console.log( 'Done with installing backend-example-module' );
18-
done( err );
19-
} );
20-
} );
21-
22-
it( 'shouldn\'t be able to downgrade if we\'re not in the correct seed (for backend module)', function ( done ) {
23-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: assetPath }, function ( err, stdout, stderr ) {
24-
expect( stderr ).to.equal( '' );
25-
expect( stdout ).to.match( /Couldn't find a seed directory within/ );
26-
done( err );
27-
} );
28-
} );
29-
30-
it( 'shouldn\'t be able to downgrade a non-existant module', function ( done ) {
31-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'backend' ) }, function ( err, stdout, stderr ) {
32-
expect( stderr ).to.equal( '' );
33-
expect( stdout ).to.match( /There are no modules to downgrade./ );
34-
done( err );
35-
} );
36-
} );
37-
38-
it( 'should be able to downgrade', function ( done ) {
39-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'backend' ) }, function ( err, stdout, stderr ) {
40-
expect( stderr ).to.equal( '' );
41-
42-
expect( fs.existsSync( path.join( assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json' ) ) ).to.be.true;
43-
expect( fs.existsSync( path.join( assetPath, 'my-new-project', 'backend', 'node_modules', 'moment' ) ) ).to.be.true;
44-
45-
if (require.cache[ path.join( assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json' ) ]) {
46-
delete require.cache[ require.resolve( path.join( assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json' ) ) ];
12+
describe('Downgrade', function () {
13+
describe('backend', function () {
14+
before(function (done) {
15+
// console.log('Installing backend-example-module for tests...');
16+
exec(path.join(binPath, 'clever-install') + ' backend-example-module', { cwd: path.join(assetPath, 'my-new-project', 'backend') }, function (err) {
17+
// console.log('Done with installing backend-example-module');
18+
done(err);
19+
});
20+
});
21+
22+
it('shouldn\'t be able to downgrade if we\'re not in the correct seed (for backend module)', function (done) {
23+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: assetPath }, function (err, stdout, stderr) {
24+
expect(stderr).to.equal('');
25+
expect(stdout).to.match(/Couldn't find a seed directory within/);
26+
done(err);
27+
});
28+
});
29+
30+
it('shouldn\'t be able to downgrade a non-existant module', function (done) {
31+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'backend') }, function (err, stdout, stderr) {
32+
expect(stderr).to.equal('');
33+
expect(stdout).to.match(/There are no modules to downgrade./);
34+
done(err);
35+
});
36+
});
37+
38+
it('should be able to downgrade', function (done) {
39+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'backend') }, function (err, stdout, stderr) {
40+
expect(stderr).to.equal('');
41+
42+
expect(fs.existsSync(path.join(assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json'))).to.be.true;
43+
expect(fs.existsSync(path.join(assetPath, 'my-new-project', 'backend', 'node_modules', 'moment'))).to.be.true;
44+
45+
if (require.cache[ path.join(assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json') ]) {
46+
delete require.cache[ require.resolve(path.join(assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json')) ];
4747
}
4848

49-
var pkg = require( path.join( assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json' ) );
50-
expect( pkg.name ).to.equal( 'backend-example-module' );
51-
expect( semver.eq( pkg.version, '1.0.5' ) ).to.true;
52-
53-
done( err );
54-
} );
55-
} );
56-
57-
it( 'should give us an error if we\'re trying to downgrade to a version that we already have', function ( done ) {
58-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'backend' ) }, function ( err, stdout, stderr ) {
59-
expect( stderr ).to.equal( '' );
60-
expect( stdout ).to.match( /backend-example-module is already at version1.0.5/ );
61-
done( err );
62-
} );
63-
} );
64-
} );
65-
66-
describe( 'frontend', function ( ) {
67-
before( function ( done ) {
68-
// console.log( 'Installing clever-datatables for tests...' );
69-
exec( path.join( binPath, 'clever-install' ) + ' clever-datatables', { cwd: path.join( assetPath, 'my-new-project', 'frontend' ) }, function ( err ) {
70-
// console.log( 'Done with installing clever-datatables' );
71-
done( err );
72-
} );
73-
} );
74-
75-
it( 'shouldn\'t be able to downgrade if we\'re not in the correct seed', function ( done ) {
76-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: assetPath }, function ( err, stdout, stderr ) {
77-
expect( stderr ).to.equal( '' );
78-
expect( stdout ).to.match( /Couldn't find a seed directory within/ );
79-
done( err );
80-
} );
81-
} );
82-
83-
it( 'shouldn\'t be able to downgrade a non-existant module', function ( done ) {
84-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'frontend' ) }, function ( err, stdout, stderr ) {
85-
expect( stderr ).to.equal( '' );
86-
expect( stdout ).to.match( /There are no modules to downgrade./ );
87-
done( err );
88-
} );
89-
} );
90-
91-
it( 'should be able to downgrade', function ( done ) {
92-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'frontend' ) }, function ( err, stdout, stderr ) {
93-
expect( stderr ).to.equal( '' );
94-
95-
expect( fs.existsSync( path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json' ) ) ).to.be.true;
96-
97-
if (require.cache[ path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json' ) ]) {
98-
delete require.cache[ require.resolve( path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json' ) ) ];
49+
var pkg = require(path.join(assetPath, 'my-new-project', 'backend', 'modules', 'backend-example-module', 'package.json'));
50+
expect(pkg.name).to.equal('backend-example-module');
51+
expect(semver.eq(pkg.version, '1.0.5')).to.true;
52+
53+
done(err);
54+
});
55+
});
56+
57+
it('should give us an error if we\'re trying to downgrade to a version that we already have', function (done) {
58+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'backend') }, function (err, stdout, stderr) {
59+
expect(stderr).to.equal('');
60+
expect(stdout).to.match(/backend-example-module is already at version1.0.5/);
61+
done(err);
62+
});
63+
});
64+
});
65+
66+
describe('frontend', function () {
67+
before(function (done) {
68+
// console.log('Installing clever-datatables for tests...');
69+
exec(path.join(binPath, 'clever-install') + ' clever-datatables', { cwd: path.join(assetPath, 'my-new-project', 'frontend') }, function (err) {
70+
// console.log('Done with installing clever-datatables');
71+
done(err);
72+
});
73+
});
74+
75+
it('shouldn\'t be able to downgrade if we\'re not in the correct seed', function (done) {
76+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: assetPath }, function (err, stdout, stderr) {
77+
expect(stderr).to.equal('');
78+
expect(stdout).to.match(/Couldn't find a seed directory within/);
79+
done(err);
80+
});
81+
});
82+
83+
it('shouldn\'t be able to downgrade a non-existant module', function (done) {
84+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'frontend') }, function (err, stdout, stderr) {
85+
expect(stderr).to.equal('');
86+
expect(stdout).to.match(/There are no modules to downgrade./);
87+
done(err);
88+
});
89+
});
90+
91+
it('should be able to downgrade', function (done) {
92+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'frontend') }, function (err, stdout, stderr) {
93+
expect(stderr).to.equal('');
94+
95+
expect(fs.existsSync(path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json'))).to.be.true;
96+
97+
if (require.cache[ path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json') ]) {
98+
delete require.cache[ require.resolve(path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json')) ];
9999
}
100100

101-
var pkg = require( path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json' ) );
102-
expect( pkg.name ).to.equal( 'clever-datatables' );
103-
expect( semver.eq( pkg.version, '0.0.1' ) ).to.true;
104-
105-
done( err );
106-
} );
107-
} );
108-
109-
it( 'should give us an error if we\'re trying to downgrade to a version that we already have', function ( done ) {
110-
exec( path.join( binPath, 'clever-downgrade' ) + ' [email protected]', { cwd: path.join( assetPath, 'my-new-project', 'frontend' ) }, function ( err, stdout, stderr ) {
111-
expect( stderr ).to.equal( '' );
112-
expect( stdout ).to.match( /clever-datatables is already at version0.0.1/ );
113-
done( err );
114-
} );
115-
} );
116-
} );
117-
} );
101+
var pkg = require(path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'cs_datatables', 'bower.json'));
102+
expect(pkg.name).to.equal('clever-datatables');
103+
expect(semver.eq(pkg.version, '0.0.1')).to.true;
104+
105+
done(err);
106+
});
107+
});
108+
109+
it('should give us an error if we\'re trying to downgrade to a version that we already have', function (done) {
110+
exec(path.join(binPath, 'clever-downgrade') + ' [email protected]', { cwd: path.join(assetPath, 'my-new-project', 'frontend') }, function (err, stdout, stderr) {
111+
expect(stderr).to.equal('');
112+
expect(stdout).to.match(/clever-datatables is already at version0.0.1/);
113+
done(err);
114+
});
115+
});
116+
});
117+
});

tests/generate/frontend/controllers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var path = require( 'path' )
2-
, assetPath = path.join( __dirname, '..', '..', 'assets' );
1+
var path = require('path')
2+
, assetPath = path.join(__dirname, '..', '..', 'assets');
33

4-
exports.tap = function ( done ) {
5-
done( null, {
6-
file: path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'controllers', 'Testing2Controller.js' ),
4+
exports.tap = function (done) {
5+
done(null, {
6+
file: path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'controllers', 'Testing2Controller.js'),
77
matches: [
88
/\.module\(\'Testing2.controllers'\)/,
99
/\.controller\(\'Testing2Controller',\ function\(\$scope\)\ {/

tests/generate/frontend/directives.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var path = require( 'path' )
2-
, assetPath = path.join( __dirname, '..', '..', 'assets' );
1+
var path = require('path')
2+
, assetPath = path.join(__dirname, '..', '..', 'assets');
33

4-
exports.tap = function ( done ) {
5-
done( null, {
6-
file: path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'directives', 'Testing2Directive.js' ),
4+
exports.tap = function (done) {
5+
done(null, {
6+
file: path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'directives', 'Testing2Directive.js'),
77
matches: [
88
/\.module\('Testing2.directives'\)/,
99
/\.directive\('Testing2Directive',\ function\(\)\ {/

tests/generate/frontend/factories.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var path = require( 'path' )
2-
, assetPath = path.join( __dirname, '..', '..', 'assets' );
1+
var path = require('path')
2+
, assetPath = path.join(__dirname, '..', '..', 'assets');
33

4-
exports.tap = function ( done ) {
5-
done( null, {
6-
file: path.join( assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'factories', 'Testing2Factory.js' ),
4+
exports.tap = function (done) {
5+
done(null, {
6+
file: path.join(assetPath, 'my-new-project', 'frontend', 'app', 'modules', 'Testing2', 'factories', 'Testing2Factory.js'),
77
matches: [
88
/\.module\('Testing2.factories'\)/,
99
/\.factory\('Testing2Factory',\ function\(\)\ {/

0 commit comments

Comments
 (0)