Commit 7128b45e by Michael Mifsud

Merge pull request #1307 from saper/strict-equal

Use assert.strictEqual in tests for better error output
parents 2ff29a95 093b9126
...@@ -956,26 +956,25 @@ describe('api', function() { ...@@ -956,26 +956,25 @@ describe('api', function() {
data: 'div { color: foo(bar(null)); background-color: baz("foo" == "bar"); }', data: 'div { color: foo(bar(null)); background-color: baz("foo" == "bar"); }',
functions: { functions: {
foo: function(a) { foo: function(a) {
assert.ok( assert.strictEqual(a, sass.TRUE,
'Supplied value should be the same instance as sass.TRUE', 'Supplied value should be the same instance as sass.TRUE'
a === sass.TRUE
); );
assert.ok( assert.strictEqual(
'sass.types.Boolean(true) should return a singleton', sass.types.Boolean(true), sass.types.Boolean(true),
sass.types.Boolean(true) === sass.types.Boolean(true) && 'sass.types.Boolean(true) should return a singleton');
sass.types.Boolean(true) === sass.TRUE
); assert.strictEqual(
sass.types.Boolean(true), sass.TRUE,
'sass.types.Boolean(true) should be the same instance as sass.TRUE');
counter++; counter++;
return sass.types.String('foo'); return sass.types.String('foo');
}, },
bar: function(a) { bar: function(a) {
assert.ok( assert.strictEqual(a, sass.NULL,
'Supplied value should be the same instance as sass.NULL', 'Supplied value should be the same instance as sass.NULL');
a === sass.NULL
);
assert.throws(function() { assert.throws(function() {
return new sass.types.Null(); return new sass.types.Null();
...@@ -986,20 +985,20 @@ describe('api', function() { ...@@ -986,20 +985,20 @@ describe('api', function() {
return sass.TRUE; return sass.TRUE;
}, },
baz: function(a) { baz: function(a) {
assert.ok( assert.strictEqual(a, sass.FALSE,
'Supplied value should be the same instance as sass.FALSE', 'Supplied value should be the same instance as sass.FALSE');
a === sass.FALSE
);
assert.throws(function() { assert.throws(function() {
return new sass.types.Boolean(false); return new sass.types.Boolean(false);
}, /Cannot instantiate SassBoolean/); }, /Cannot instantiate SassBoolean/);
assert.ok( assert.strictEqual(
'sass.types.Boolean(false) should return a singleton', sass.types.Boolean(false), sass.types.Boolean(false),
sass.types.Boolean(false) === sass.types.Boolean(false) && 'sass.types.Boolean(false) should return a singleton');
sass.types.Boolean(false) === sass.FALSE
); assert.strictEqual(
sass.types.Boolean(false), sass.FALSE,
'sass.types.Boolean(false) should return singleton identical to sass.FALSE');
counter++; counter++;
...@@ -1007,7 +1006,7 @@ describe('api', function() { ...@@ -1007,7 +1006,7 @@ describe('api', function() {
} }
} }
}, function() { }, function() {
assert.ok(counter === 3); assert.strictEqual(counter, 3);
done(); done();
}); });
}); });
...@@ -1021,7 +1020,7 @@ describe('api', function() { ...@@ -1021,7 +1020,7 @@ describe('api', function() {
file: fixture('include-files/index.scss') file: fixture('include-files/index.scss')
}, function(error, result) { }, function(error, result) {
assert(!error); assert(!error);
assert(typeof result.stats.start === 'number'); assert.strictEqual(typeof result.stats.start, 'number');
assert(result.stats.start >= start); assert(result.stats.start >= start);
done(); done();
}); });
...@@ -1032,7 +1031,7 @@ describe('api', function() { ...@@ -1032,7 +1031,7 @@ describe('api', function() {
file: fixture('include-files/index.scss') file: fixture('include-files/index.scss')
}, function(error, result) { }, function(error, result) {
assert(!error); assert(!error);
assert(typeof result.stats.end === 'number'); assert.strictEqual(typeof result.stats.end, 'number');
assert(result.stats.end >= result.stats.start); assert(result.stats.end >= result.stats.start);
done(); done();
}); });
...@@ -1043,7 +1042,7 @@ describe('api', function() { ...@@ -1043,7 +1042,7 @@ describe('api', function() {
file: fixture('include-files/index.scss') file: fixture('include-files/index.scss')
}, function(error, result) { }, function(error, result) {
assert(!error); assert(!error);
assert(typeof result.stats.duration === 'number'); assert.strictEqual(typeof result.stats.duration, 'number');
assert.equal(result.stats.end - result.stats.start, result.stats.duration); assert.equal(result.stats.end - result.stats.start, result.stats.duration);
done(); done();
}); });
...@@ -1504,19 +1503,19 @@ describe('api', function() { ...@@ -1504,19 +1503,19 @@ describe('api', function() {
}); });
it('should provide a start timestamp', function(done) { it('should provide a start timestamp', function(done) {
assert(typeof result.stats.start === 'number'); assert.strictEqual(typeof result.stats.start, 'number');
assert(result.stats.start >= start); assert(result.stats.start >= start);
done(); done();
}); });
it('should provide an end timestamp', function(done) { it('should provide an end timestamp', function(done) {
assert(typeof result.stats.end === 'number'); assert.strictEqual(typeof result.stats.end, 'number');
assert(result.stats.end >= result.stats.start); assert(result.stats.end >= result.stats.start);
done(); done();
}); });
it('should provide a duration', function(done) { it('should provide a duration', function(done) {
assert(typeof result.stats.duration === 'number'); assert.strictEqual(typeof result.stats.duration, 'number');
assert.equal(result.stats.end - result.stats.start, result.stats.duration); assert.equal(result.stats.end - result.stats.start, result.stats.duration);
done(); done();
}); });
......
...@@ -244,7 +244,7 @@ describe('cli', function() { ...@@ -244,7 +244,7 @@ describe('cli', function() {
bin.stderr.setEncoding('utf8'); bin.stderr.setEncoding('utf8');
bin.stderr.once('data', function(data) { bin.stderr.once('data', function(data) {
assert(data.trim() === '=> changed: ' + src); assert.strictEqual(data.trim(), '=> changed: ' + src);
fs.unlinkSync(src); fs.unlinkSync(src);
bin.kill(); bin.kill();
done(); done();
...@@ -290,7 +290,7 @@ describe('cli', function() { ...@@ -290,7 +290,7 @@ describe('cli', function() {
bin.stdout.setEncoding('utf8'); bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) { bin.stdout.once('data', function(data) {
assert(data.trim() === 'body{background:white}'); assert.strictEqual(data.trim(), 'body{background:white}');
fs.unlinkSync(src); fs.unlinkSync(src);
bin.kill(); bin.kill();
done(); done();
...@@ -314,7 +314,7 @@ describe('cli', function() { ...@@ -314,7 +314,7 @@ describe('cli', function() {
bin.stdout.setEncoding('utf8'); bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) { bin.stdout.once('data', function(data) {
assert.equal(data.trim(), 'body{background:blue}'); assert.strictEqual(data.trim(), 'body{background:blue}');
bin.kill(); bin.kill();
done(); done();
}); });
...@@ -337,7 +337,7 @@ describe('cli', function() { ...@@ -337,7 +337,7 @@ describe('cli', function() {
bin.stdout.setEncoding('utf8'); bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) { bin.stdout.once('data', function(data) {
assert.equal(data.trim(), 'body{background:red}'); assert.strictEqual(data.trim(), 'body{background:red}');
bin.kill(); bin.kill();
done(); done();
}); });
...@@ -442,7 +442,7 @@ describe('cli', function() { ...@@ -442,7 +442,7 @@ describe('cli', function() {
]); ]);
bin.once('close', function() { bin.once('close', function() {
assert(read(dest, 'utf8').indexOf('sourceMappingURL') === -1); assert.strictEqual(read(dest, 'utf8').indexOf('sourceMappingURL'), -1);
assert(fs.existsSync(map)); assert(fs.existsSync(map));
fs.unlinkSync(map); fs.unlinkSync(map);
fs.unlinkSync(dest); fs.unlinkSync(dest);
...@@ -570,8 +570,8 @@ describe('cli', function() { ...@@ -570,8 +570,8 @@ describe('cli', function() {
var bin = spawn(cli, [src]); var bin = spawn(cli, [src]);
bin.once('close', function(code) { bin.once('close', function(code) {
assert(code !== 0); assert.notStrictEqual(code, 0);
assert.equal(glob.sync(fixture('input-directory/**/*.css')).length, 0); assert.strictEqual(glob.sync(fixture('input-directory/**/*.css')).length, 0);
done(); done();
}); });
}); });
...@@ -582,7 +582,7 @@ describe('cli', function() { ...@@ -582,7 +582,7 @@ describe('cli', function() {
var bin = spawn(cli, [src, '--output', dest]); var bin = spawn(cli, [src, '--output', dest]);
bin.once('close', function(code) { bin.once('close', function(code) {
assert(code !== 0); assert.notStrictEqual(code, 0);
assert.equal(glob.sync(fixture('input-directory/**/*.css')).length, 0); assert.equal(glob.sync(fixture('input-directory/**/*.css')).length, 0);
done(); done();
}); });
...@@ -745,7 +745,7 @@ describe('cli', function() { ...@@ -745,7 +745,7 @@ describe('cli', function() {
]); ]);
bin.once('close', function(code) { bin.once('close', function(code) {
assert(code !== 0); assert.notStrictEqual(code, 0);
done(); done();
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment