|
| 1 | +var jasminePit = require('jasmine-pit'); |
| 2 | +jasminePit.install(global); |
| 3 | +var models = require('../../src/models'); |
| 4 | + |
| 5 | +describe('Flow', function() { |
| 6 | + it('should be able to require Flow', function() { |
| 7 | + expect(models.Flow).toBeDefined(models.Flow); |
| 8 | + }); |
| 9 | + |
| 10 | + it('should have static method `init` and `isInitialized` on Flow object', function() { |
| 11 | + expect(models.Flow.init).toEqual(jasmine.any(Function)); |
| 12 | + expect(models.Flow.isInitialized).toEqual(jasmine.any(Function)); |
| 13 | + }); |
| 14 | + |
| 15 | + describe('Init', function() { |
| 16 | + beforeEach(function() { |
| 17 | + var repoConfig = { |
| 18 | + setString: function() { |
| 19 | + return Promise.resolve(); |
| 20 | + } |
| 21 | + }; |
| 22 | + this.repo = { |
| 23 | + config: function() { |
| 24 | + return Promise.resolve(repoConfig); |
| 25 | + } |
| 26 | + }; |
| 27 | + }); |
| 28 | + |
| 29 | + |
| 30 | + pit('should throw error if no repository is passed', function() { |
| 31 | + return models.Flow.init() |
| 32 | + .then(function() { |
| 33 | + fail(); |
| 34 | + }) |
| 35 | + .catch(function(reason) { |
| 36 | + expect(reason).toEqual(jasmine.any(Error)); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + pit('should return new flow object if repository is passed', function() { |
| 41 | + return models.Flow.init(this.repo) |
| 42 | + .then(function(flow) { |
| 43 | + expect(flow.startFeature).toEqual(jasmine.any(Function)); |
| 44 | + expect(flow.startFeature).toEqual(jasmine.any(Function)); |
| 45 | + expect(flow.startHotfix).toEqual(jasmine.any(Function)); |
| 46 | + expect(flow.startHotfix).toEqual(jasmine.any(Function)); |
| 47 | + expect(flow.startRelease).toEqual(jasmine.any(Function)); |
| 48 | + expect(flow.startRelease).toEqual(jasmine.any(Function)); |
| 49 | + }); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + describe('Static methods', function() { |
| 54 | + it('should contain all of the static methods', function() { |
| 55 | + expect(models.Flow.startFeature).toEqual(jasmine.any(Function)); |
| 56 | + expect(models.Flow.startFeature).toEqual(jasmine.any(Function)); |
| 57 | + expect(models.Flow.startHotfix).toEqual(jasmine.any(Function)); |
| 58 | + expect(models.Flow.startHotfix).toEqual(jasmine.any(Function)); |
| 59 | + expect(models.Flow.startRelease).toEqual(jasmine.any(Function)); |
| 60 | + expect(models.Flow.startRelease).toEqual(jasmine.any(Function)); |
| 61 | + }); |
| 62 | + }); |
| 63 | +}); |
0 commit comments