From b1e0edb22b308b395681c80023d411de9ba662ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 10 Oct 2014 11:21:15 +0200 Subject: [PATCH] test: verify exported models --- test/loopback.test.js | 24 ++++++++++++++++++++++++ test/user.test.js | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/loopback.test.js b/test/loopback.test.js index 6529d69c..d03e01e6 100644 --- a/test/loopback.test.js +++ b/test/loopback.test.js @@ -241,4 +241,28 @@ describe('loopback', function() { expect(owner._targetClass).to.equal('User'); }); }); + + describe('loopback object', function() { + it('exports all built-in models', function() { + var expectedModelNames = [ + 'Email', + 'User', + 'Application', + 'AccessToken', + 'Role', + 'RoleMapping', + 'ACL', + 'Scope', + 'Change', + 'Checkpoint' + ]; + + expect(Object.keys(loopback)).to.include.members(expectedModelNames); + + expectedModelNames.forEach(function(name) { + expect(loopback[name], name).to.be.a('function'); + expect(loopback[name].modelName, name + '.modelName').to.eql(name); + }); + }); + }); }); diff --git a/test/user.test.js b/test/user.test.js index c6680fff..c08465a0 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -600,4 +600,16 @@ describe('User', function(){ }); }); }); + + describe('ctor', function() { + it('exports default Email model', function() { + expect(User.email, 'User.email').to.be.a('function'); + expect(User.email.modelName, 'modelName').to.eql('email'); + }); + + it('exports default AccessToken model', function() { + expect(User.accessToken, 'User.accessToken').to.be.a('function'); + expect(User.accessToken.modelName, 'modelName').to.eql('AccessToken'); + }); + }); });