UNPKG

2.88 kBJavaScriptView Raw
1/* global require,describe,it,beforeEach */
2(function () {
3 "use strict";
4 var expect = require('chai').expect,
5 nunit;
6
7 function clearNunit() {
8 delete require.cache[require.resolve('../')];
9 nunit = require('../');
10 }
11
12 describe('Tests for gulp-nunit-runner', function () {
13 beforeEach(function () {
14 clearNunit();
15 });
16
17 describe('No executable command passed in', function () {
18 it('Should throw an error.', function () {
19 expect(function () {
20 nunit({});
21 }).to.throw(Error);
22 });
23 });
24
25 describe('Test quoted executable path and path with spaces.', function(){
26 var opts;
27 var assemblies;
28
29 it('Should quote a non-quoted string', function(){
30 opts = {
31 executable: 'C:\\nunit\\bin\\nunit-console.exe'
32 };
33
34 assemblies = ['First.Test.dll'];
35
36 expect(nunit.getExecutionCommand(opts, assemblies)).to.equal('"C:\\nunit\\bin\\nunit-console.exe" "First.Test.dll"');
37 });
38
39 it('Should correctly quote a double-quoted string', function(){
40 opts = {
41 executable: '"C:\\nunit\\bin\\nunit-console.exe"'
42 };
43
44 assemblies = ['First.Test.dll'];
45
46 expect(nunit.getExecutionCommand(opts, assemblies)).to.equal('"C:\\nunit\\bin\\nunit-console.exe" "First.Test.dll"');
47 });
48
49 it('Should correctly quote a single-quoted string', function(){
50 opts = {
51 executable: "'C:\\nunit\\bin\\nunit-console.exe'"
52 };
53
54 assemblies = ['First.Test.dll'];
55 expect(nunit.getExecutionCommand(opts, assemblies)).to.equal('"C:\\nunit\\bin\\nunit-console.exe" "First.Test.dll"');
56 });
57 });
58
59 describe('Adding assemblies and option switches should yield correct command.', function () {
60 var stream;
61 var opts;
62 var assemblies;
63
64 it('Should throw an error with no assemblies', function (cb) {
65 stream = nunit({
66 executable: 'C:\\nunit\\bin\\nunit-console.exe'
67 });
68 stream.on('error', function (err) {
69 expect(err.message).to.equal('File may not be null.');
70 cb();
71 });
72 stream.write();
73 });
74
75 it('Should have correct command with assemblies only.', function () {
76 opts = {
77 executable: 'C:\\nunit\\bin\\nunit-console.exe'
78 };
79
80 assemblies = ['First.Test.dll', 'Second.Test.dll'];
81
82 expect(nunit.getExecutionCommand(opts, assemblies)).to.equal('"C:\\nunit\\bin\\nunit-console.exe" "First.Test.dll" "Second.Test.dll"');
83 });
84
85 it('Should have correct command with options added.', function () {
86 opts = {
87 executable: 'C:\\nunit\\bin\\nunit-console.exe',
88 options : {
89 nologo : true,
90 config : 'Release',
91 transform: 'myTransform.xslt'
92 }
93 };
94
95 assemblies = ['First.Test.dll', 'Second.Test.dll'];
96
97 expect(nunit.getExecutionCommand(opts, assemblies)).to.equal('"C:\\nunit\\bin\\nunit-console.exe" /nologo /config:"Release" /transform:"myTransform.xslt" "First.Test.dll" "Second.Test.dll"');
98 });
99 });
100 });
101}());
102