From 243423ad588eb3dd9dcd2fbd5cb5a2c885faecfa Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 14 Aug 2015 18:20:35 -0700 Subject: [PATCH] Test that `originalError` is set for unique keys It's set for WLError, but at least one library clobbers the original error message when creating a WLValidationError. Test that this property exists. --- features/unique/core/unique.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/features/unique/core/unique.test.js b/features/unique/core/unique.test.js index a13828a..00e82a1 100644 --- a/features/unique/core/unique.test.js +++ b/features/unique/core/unique.test.js @@ -72,6 +72,13 @@ describe('unique attribute feature', function() { }); }); + it('should attach the original error when creating with a duplicate value', function(done) { + UniqueModel.create({ email: email0, type: 'unique' }, function(err, records) { + assert.strictEqual(err.code, 'E_VALIDATION'); + assert.ok(err.originalError); + }); + }); + it('should error when updating with a duplicate value', function(done) { UniqueModel.update(id1, { email: email0 }).exec(function(err, records) { assert(err);