diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-22 13:59:07 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-22 13:59:07 +0800 |
commit | 60fe975452f6781198188ae985bad7329d1aff05 (patch) | |
tree | d75209d003ff3a3aadfef80a333ac80c28648a5f /spec/javascripts/subbable_resource_spec.js.es6 | |
parent | 428061678eda85a65ce6a9ee15ac520af45f021a (diff) | |
parent | 56b420ae10aa91807b5be2b8e4c18d67313d27dc (diff) | |
download | gitlab-ce-60fe975452f6781198188ae985bad7329d1aff05.tar.gz |
Merge remote-tracking branch 'upstream/master' into feature/1376-allow-write-access-deploy-keys
* upstream/master: (497 commits)
Use single quote for strings
Ue svg from SVGs object
Dont trigger CI builds [ci skip]
Revert "Test only migrations"
Add custom copy for each empty stage
Fetch only one revision
Highlight nav item on hover
Test only migrations
Fix migration paths tests
Scroll CA stage panel on mobile
Fix CSS declaration
administer to administrator
Move SVGs to JS objects for easy reuse
Improve deploy command message
No enough data to Not enough data
Keep the cookie name as before
Fix variable usage
Evalute time_ago method instead of printing it
Removed button styling from restricted visibility levels and added checkboxes with icons
Do not show overview message if there’s already CA data
...
Diffstat (limited to 'spec/javascripts/subbable_resource_spec.js.es6')
-rw-r--r-- | spec/javascripts/subbable_resource_spec.js.es6 | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/javascripts/subbable_resource_spec.js.es6 b/spec/javascripts/subbable_resource_spec.js.es6 new file mode 100644 index 00000000000..df395296791 --- /dev/null +++ b/spec/javascripts/subbable_resource_spec.js.es6 @@ -0,0 +1,65 @@ +/* eslint-disable */ +//= vue +//= vue-resource +//= require jquery +//= require subbable_resource + +/* +* Test that each rest verb calls the publish and subscribe function and passes the correct value back +* +* +* */ +((global) => { + describe('Subbable Resource', function () { + describe('PubSub', function () { + beforeEach(function () { + this.MockResource = new global.SubbableResource('https://example.com'); + }); + it('should successfully add a single subscriber', function () { + const callback = () => {}; + this.MockResource.subscribe(callback); + + expect(this.MockResource.subscribers.length).toBe(1); + expect(this.MockResource.subscribers[0]).toBe(callback); + }); + + it('should successfully add multiple subscribers', function () { + const callbackOne = () => {}; + const callbackTwo = () => {}; + const callbackThree = () => {}; + + this.MockResource.subscribe(callbackOne); + this.MockResource.subscribe(callbackTwo); + this.MockResource.subscribe(callbackThree); + + expect(this.MockResource.subscribers.length).toBe(3); + }); + + it('should successfully publish an update to a single subscriber', function () { + const state = { myprop: 1 }; + + const callbacks = { + one: (data) => expect(data.myprop).toBe(2), + two: (data) => expect(data.myprop).toBe(2), + three: (data) => expect(data.myprop).toBe(2) + }; + + const spyOne = spyOn(callbacks, 'one'); + const spyTwo = spyOn(callbacks, 'two'); + const spyThree = spyOn(callbacks, 'three'); + + this.MockResource.subscribe(callbacks.one); + this.MockResource.subscribe(callbacks.two); + this.MockResource.subscribe(callbacks.three); + + state.myprop++; + + this.MockResource.publish(state); + + expect(spyOne).toHaveBeenCalled(); + expect(spyTwo).toHaveBeenCalled(); + expect(spyThree).toHaveBeenCalled(); + }); + }); + }); +})(window.gl || (window.gl = {})); |