From bc45b70644c51e3b35b6332449939254dee3627f Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 23 Jun 2016 10:48:02 -0400 Subject: [PATCH] Add mixin testing to common vformat functions * test/validate/formatter/common.js (testMixin): Added. --- test/validate/formatter/common.js | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/test/validate/formatter/common.js b/test/validate/formatter/common.js index af36ebe..2d0a292 100644 --- a/test/validate/formatter/common.js +++ b/test/validate/formatter/common.js @@ -91,5 +91,50 @@ module.exports = { ); } ); } ); - } + }, + + + /** + * Test that mixin respects supertype data + * + * @param {Function} Super supertype constructor to extend + * @param {Trait} Sut SUT trait + * @param {string} base string to serve as base to data + * @param {string} given given data to pass to extended Super + * @param {string} parse expected #parse result + * @param {string} retrieve expected #retrieve result + * + * @return {undefined} + */ + testMixin: function( Super, Sut, base, given, parse, retrieve ) + { + describe( 'as a mixin', function() + { + var sut = Super.extend( + { + 'virtual override parse': function( data ) + { + return base + data; + }, + 'virtual override retrieve': function( data ) + { + return base + data; + } + } ).use( Sut )(); + + + it( 'respects supertype #parse', function() + { + expect( sut.parse( given ) ) + .to.equal( parse ); + } ); + + + it( 'respects supertype #retrieve', function() + { + expect( sut.retrieve( given ) ) + .to.equal( retrieve ); + } ); + } ); + }, };