|
1 | | -var chai = require( 'chai' ) |
| 1 | +var chai = require('chai') |
2 | 2 | , expect = chai.expect |
3 | 3 | , 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'); |
9 | 9 |
|
10 | 10 | chai.config.includeStack = true; |
11 | 11 |
|
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')) ]; |
47 | 47 | } |
48 | 48 |
|
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')) ]; |
99 | 99 | } |
100 | 100 |
|
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 | +}); |
0 commit comments