Index: test/test_model.js |
=== modified file 'test/test_model.js' |
--- test/test_model.js 2013-04-12 22:57:49 +0000 |
+++ test/test_model.js 2013-04-17 13:28:40 +0000 |
@@ -643,3 +643,39 @@ |
instance.get('recent_commit_count').should.equal(3); |
}); |
}); |
+ |
+ |
+describe('service models', function() { |
+ var models, list, django, rails, mysql; |
+ |
+ before(function(done) { |
+ YUI(GlobalConfig).use(['juju-models'], function(Y) { |
+ models = Y.namespace('juju.models'); |
+ done(); |
+ }); |
+ }); |
+ |
+ beforeEach(function() { |
+ django = new models.Service({id: 'django'}); |
+ rails = new models.Service({id: 'rails', life: 'dying'}); |
+ mysql = new models.Service({id: 'mysql', life: 'dead'}); |
+ list = new models.ServiceList({items: [rails, django, mysql]}); |
+ }); |
+ |
+ it('instances identify if they are alive', function() { |
+ // This test also verifies that the default state is "alive". |
+ assert.isTrue(django.isAlive()); |
+ }); |
+ |
+ it('instances identify if they are not alive (dying or dead)', function() { |
+ assert.isFalse(rails.isAlive()); |
+ assert.isFalse(mysql.isAlive()); |
+ }); |
+ |
+ it('can be filtered so that it returns only alive models', function() { |
+ var filtered = list.alive(); |
+ assert.strictEqual(1, filtered.size()); |
+ assert.deepEqual([django], filtered.toArray()); |
+ }); |
+ |
+}); |