Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9c85c6fe
Commit
9c85c6fe
authored
Dec 14, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add approvals store spec.
parent
6c154002
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
spec/javascripts/approvals/approvals_store_spec.js.es6
spec/javascripts/approvals/approvals_store_spec.js.es6
+67
-0
No files found.
spec/javascripts/approvals/approvals_store_spec.js.es6
0 → 100644
View file @
9c85c6fe
//= require jquery
//= require vue
//= require vue-resource
//= require merge_request_widget/approvals/stores/approvals_store
$.rails = {
csrfToken() {},
};
(() => {
// store constructor reference, to overwrite ApprovalStore singleton
gl.ApprovalsConstructor = gl.ApprovalsStore;
// stand in for promise returned by api calls
const mockThenable = {
then() {
return {
catch() {},
};
},
catch() {},
};
const mockRootStore = {
data: {},
dataset: {
endpoint: 'gitlab/myendpoint/',
},
assignToData(key, val) {
return { key, val };
},
};
describe('Approvals Store', function () {
beforeEach(function () {
this.rootStore = mockRootStore;
this.approvalsStore = new gl.ApprovalsConstructor(this.rootStore);
});
it('should define all needed approval api calls', function () {
expect(this.approvalsStore.fetch).toBeDefined();
expect(this.approvalsStore.approve).toBeDefined();
expect(this.approvalsStore.unapprove).toBeDefined();
});
it('should only init the store once', function () {
spyOn(this.approvalsStore, 'fetch').and.callFake(() => mockThenable);
this.approvalsStore.initStoreOnce();
this.approvalsStore.initStoreOnce();
this.approvalsStore.initStoreOnce();
expect(this.approvalsStore.fetch.calls.count()).toBe(1);
});
it('should be able to write to the rootStore', function () {
const dataToStore = { myMockData: 'string' };
spyOn(this.rootStore, 'assignToData');
this.approvalsStore.assignToRootStore(dataToStore);
expect(this.rootStore.assignToData).toHaveBeenCalled();
expect(this.rootStore.assignToData).toHaveBeenCalledWith('approvals', dataToStore);
});
});
})(window.gl || (window.gl = {}));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment