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
662b203b
Commit
662b203b
authored
Dec 14, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for approvals body, with computed string specs failing.
parent
028d1907
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
0 deletions
+131
-0
spec/javascripts/approvals/approvals_body_spec.js.es6
spec/javascripts/approvals/approvals_body_spec.js.es6
+131
-0
No files found.
spec/javascripts/approvals/approvals_body_spec.js.es6
0 → 100644
View file @
662b203b
//= require vue
//= require underscore
//= require jquery
//= require merge_request_widget/approvals/components/approvals_body
// - showapprovebutton
//
(() => {
gl.ApprovalsStore = {
data: {},
initStoreOnce() {
return {
then() {},
};
},
};
function initApprovalsBodyComponent() {
fixture.set(`
<div>
<div id="mock-container"></div>
</div>
`);
this.initialData = {
suggestedApprovers: ['Approver 1'],
userCanApprove: false,
userHasApproved: true,
approvedBy: [],
approvalsLeft: 1,
pendingAvatarSvg: '<svg></svg>',
checkmarkSvg: '<svg></svg>',
};
const ApprovalsBodyComponent = Vue.component('approvals-body');
this.approvalsBody = new ApprovalsBodyComponent({
el: '#mock-container',
propsData: this.initialData,
beforeCreate() {},
});
}
describe('Approvals Body Component', function () {
beforeEach(function () {
initApprovalsBodyComponent.call(this);
});
it('should correctly set component props', function () {
const approvalsBody = this.approvalsBody;
_.each(approvalsBody, (propValue, propKey) => {
if (this.initialData[propKey]) {
expect(approvalsBody[propKey]).toBe(this.initialData[propKey]);
}
});
});
describe('Computed properties', function () {
describe('approvalsRequiredStringified', function () {
it('should display the correct string for 1 possible approver', function () {
const correctText = 'one more approval';
expect(this.approvalsBody.approvalsRequiredStringified).toBe(correctText);
});
it('should display the correct string for 2 possible approver', function (done) {
this.approvalsBody.approvalsLeft = 2;
this.approvalsBody.suggestedApprovers.push('Approver 2');
Vue.nextTick(() => {
const correctText = '2 more approvals';
expect(this.approvalsBody.approvalsRequiredStringified).toBe(correctText);
done();
});
});
});
describe('approverNamesStringified', function () {
// Preceded by: Requires {one more approval} required from _____
it('should display the correct string for 1 possible approver name', function () {
const correctText = 'Approver 1';
expect(this.approvalsBody.approverNamesStringified).toBe(correctText);
});
it('should display the correct string for 2 possible approver names', function (done) {
this.approvalsBody.approvalsLeft = 2;
this.approvalsBody.suggestedApprovers.push('Approver 2');
Vue.nextTick(() => {
const correctText = 'Approver 1 or Approver 2';
expect(this.approvalsBody.approverNamesStringified).toBe(correctText);
done();
});
});
it('should display the correct string for 3 possible approver names', function (done) {
this.approvalsBody.approvalsLeft = 3;
this.approvalsBody.suggestedApprovers.push('Approver 2');
this.approvalsBody.suggestedApprovers.push('Approver 3');
Vue.nextTick(() => {
const correctText = 'Approver 1, Approver 2 or Approver 3';
expect(this.approvalsBody.approverNamesStringified).toBe(correctText);
done();
});
});
});
describe('showApproveButton', function () {
it('should not be true when the user cannot approve', function (done) {
this.approvalsBody.userCanApprove = false;
this.approvalsBody.userHasApproved = true;
Vue.nextTick(() => {
expect(this.approvalsBody.showApproveButton).toBe(false);
done();
});
});
it('should be true when the user can approve', function (done) {
this.approvalsBody.userCanApprove = true;
this.approvalsBody.userHasApproved = false;
Vue.nextTick(() => {
expect(this.approvalsBody.showApproveButton).toBe(true);
done();
});
});
});
});
});
})(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