UNPKG

nhz.lib

Version:
51 lines (49 loc) 2.71 kB
/* coffee.genClassTests(args) */ module.exports = function(args) { var ancestor, ancestors, i, j, k, l, len, len1, len2, len3, len4, len5, len6, m, method, methods, n, name, o, properties, property, ref, ref1, ref2, ref3, ref4, ref5, ref6, result, staticMethods, staticProperties; if (args == null) { args = {}; } name = args.name, ancestors = args.ancestors, staticProperties = args.staticProperties, properties = args.properties, staticMethods = args.staticMethods, methods = args.methods; result = ''; if (name) { result += "### test: " + name + " ###\n\nshould = require 'should'\n\ndescribe '" + name + "', ->\n it 'should be a class', ->\n " + name + ".should.be.a.Function\n " + name + "::constructor.should.be.equal " + name + "\n"; ref = ancestors || []; for (i = 0, len = ref.length; i < len; i++) { ancestor = ref[i]; result += "---\n it 'should be a subclass of " + ancestor + "', -> (Object.create " + name + "::).should.be.an.instanceof " + ancestor + "\n"; } ref1 = staticProperties || []; for (j = 0, len1 = ref1.length; j < len1; j++) { property = ref1[j]; result += "---\n it 'should have \"" + property + "\" property', -> " + name + ".should.have.property '" + property + "'\n"; } ref2 = staticMethods || []; for (k = 0, len2 = ref2.length; k < len2; k++) { method = ref2[k]; result += "---\n it 'should have \"" + method + "()\" method', -> " + name + "." + method + ".should.be.a.Function"; } result += "---\n describe '#constructor()', ->\n it 'should return an instance of " + name + "', -> (new " + name + ").should.be.an.instanceof " + name + "\n\n describe 'instance', ->\n"; ref3 = properties || []; for (l = 0, len3 = ref3.length; l < len3; l++) { property = ref3[l]; result += "---\n it 'should have \"" + property + "\" property', -> (new " + name + ").should.have.property '" + property + "'\n"; } ref4 = methods || []; for (m = 0, len4 = ref4.length; m < len4; m++) { method = ref4[m]; result += "---\n it 'should have \"" + method + "()\" method', -> (new " + name + ")." + method + ".should.be.a.Function\n"; } ref5 = properties || []; for (n = 0, len5 = ref5.length; n < len5; n++) { property = ref5[n]; result += "---\n describe '#" + property + "', ->\n"; } ref6 = methods || []; for (o = 0, len6 = ref6.length; o < len6; o++) { method = ref6[o]; result += "---\n describe '#" + method + "()', ->\n it 'should be a stub', -> (-> (new " + name + ")." + method + "()).should.throw 'UNIMPLEMENTED'\n"; } } return result.replace(/^---\s*$/gmi, ''); };