Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit d18f613

Browse files
committed
Added additional tests to satisfy code coverage
1 parent 186e206 commit d18f613

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
node_modules
44
build
55
*.node
6-
components
6+
components
7+
coverage

test/PluginError.js

+30
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,36 @@ describe('PluginError()', function(){
9898
err.toString().indexOf('fileName:').should.equal(-1);
9999
});
100100

101+
it('should not show properties, but should show stack', function() {
102+
var err = new util.PluginError('test', 'it broke', {showStack: true, showProperties: false});
103+
err.fileName = 'original.js';
104+
err.lineNumber = 35;
105+
err.toString().indexOf('message:').should.equal(-1);
106+
err.toString().indexOf('fileName:').should.equal(-1);
107+
});
108+
109+
it('should not show properties, but should show stack for real error', function() {
110+
var realErr = new Error('something broke');
111+
realErr.fileName = 'original.js';
112+
realErr.lineNumber = 35;
113+
realErr.stack = 'test stack';
114+
var err = new util.PluginError('test', realErr, {showStack: true, showProperties: false});
115+
err.toString().indexOf('message:').should.equal(-1);
116+
err.toString().indexOf('fileName:').should.equal(-1);
117+
err.toString().indexOf('test stack').should.not.equal(-1);
118+
});
119+
120+
it('should not show properties, but should show stack for _stack', function() {
121+
var realErr = new Error('something broke');
122+
realErr.fileName = 'original.js';
123+
realErr.lineNumber = 35;
124+
var err = new util.PluginError('test', realErr, {showStack: true, showProperties: false});
125+
err._stack = 'test stack';
126+
err.toString().indexOf('message:').should.equal(-1);
127+
err.toString().indexOf('fileName:').should.equal(-1);
128+
err.toString().indexOf('test stack').should.not.equal(-1);
129+
});
130+
101131
it('should show properties and stack', function(){
102132
var realErr = new Error('something broke');
103133
realErr.fileName = 'original.js';

0 commit comments

Comments
 (0)