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
8d42889a
Commit
8d42889a
authored
Nov 15, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inititalization and stub out specs.
parent
5804f3fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
162 additions
and
44 deletions
+162
-44
app/assets/javascripts/issuable_time_tracker.js.es6
app/assets/javascripts/issuable_time_tracker.js.es6
+5
-2
spec/javascripts/issuable_time_tracker_spec.js.es6
spec/javascripts/issuable_time_tracker_spec.js.es6
+157
-42
No files found.
app/assets/javascripts/issuable_time_tracker.js.es6
View file @
8d42889a
...
...
@@ -42,6 +42,9 @@ function getRandomInt(min, max) {
this.issuable = data;
},
},
beforeCreate() {
this.issuable = issuableData;
},
created() {
this.fetchIssuable();
},
...
...
@@ -57,9 +60,9 @@ function getRandomInt(min, max) {
});
});
Vue.component('issuable-time-tracker', {
gl.IssuableTimeTracker =
Vue.component('issuable-time-tracker', {
name: 'issuable-time-tracker',
props:
{ time_estimate: { type: Number, default: '' }, time_spent: { type: Number, default: ''} }
,
props:
[ 'time_estimate', 'time_spent' ]
,
data: function() {
return {
displayHelp: false,
...
...
spec/javascripts/issuable_time_tracker_spec.js.es6
View file @
8d42889a
...
...
@@ -2,70 +2,185 @@
//= require jquery
//= require vue
//= require vue-resource
//= require directives/tooltip_title
//= require issuable_time_tracker
((gl) => {
function initComponent({time_estimate = 100000, time_spent = 5000}) {
fixture.set(`<div id="mock-container"><issuable-time-tracker :time_estimate='${time_estimate}', :time_spent='${time_spent}'></issuable-time-tracker></div>`);
const elem = document.getElementById('mock-container');
debugger;
const comp = new Vue({
el: elem,
propsData: { time_estimate: time_estimate, time_spent: time_estimate },
});
function generateTimeObject (weeks, days, hours, minutes, totalMinutes) {
return { weeks, days, hours, minutes, totalMinutes };
return comp;
}
describe('Issuable Time Tracker', function() {
describe('Initialization', function() {
beforeEach(function() {
this.initialData = { time_estimate: 100000, time_spent: 50000 };
this.timeTracker = initComponent(this.initialData);
});
it('should return something defined', function() {
expect(this.timeTracker).toBeDefined();
});
it ('should correctly set time_estimate', function() {
expect(this.timeTracker.$data.time_estimate).toBeDefined();
expect(this.timeTracker.$data.time_estimate).toBe(this.initialData.time_estimate);
});
it ('should correctly set time_spent', function() {
expect(this.timeTracker.$data.time_spent).toBeDefined();
expect(this.timeTracker.$data.time_spent).toBe(this.initialData.time_spent);
});
});
describe('Content Display', function() {
describe('Panes', function() {
describe('Comparison pane', function() {
beforeEach(function() {
this.initialData = { time_estimate: 100000, time_spent: 50000 };
this.timeTracker = initComponent(this.initialData);
});
it('should show the "Comparison" pane when time_estimate and time_spent are truthy', function() {
const $comparisonPane = $('.time-tracking-pane-compare');
expect(this.timeTracker.showComparison).toBe(true);
expect($comparisonPane).toBeVisible();
});
it('should not show panes besides the "Comparison" pane when time_estimate and time_spent are truthy', function() {
const $comparisonPane = $('.time-tracking-pane-compare');
expect($comparisonPane.siblings()).toBeHidden();
});
});
describe("Estimate only pane", function() {
beforeEach(function() {
const time_estimate = 100000;
const time_spent = 0;
const timeTrackingComponent = Vue.extend(gl.IssuableTimeTracker);
const initialData = this.initialData = { time_estimate, time_spent };
this.timeTracker = new timeTrackingComponent({
data: initialData
}).$mount();
});
// Look for the value
it('should only show the "Estimate only" pane when time_estimate is truthy and time_spent is falsey', function() {
const $estimateOnlyPane = $('.time-tracking-estimate-only');
expect(this.timeTracker.showEstimateOnly).toBe(true);
expect($estimateOnlyPane).toBeVisible();
});
});
describe('Spent only pane', function() {
beforeEach(function() {
const time_estimate = 0;
const time_spent = 50000;
const timeTrackingComponent = Vue.extend(gl.IssuableTimeTracker);
const initialData = this.initialData = { time_estimate, time_spent };
this.timeTracker = new timeTrackingComponent({
data: initialData
}).$mount();
});
// Look for the value
it('should only show the "Spent only" pane when time_estimate is falsey and time_spent is truthy', function() {
const $spentOnlyPane = $('.time-tracking-spend-only');
expect(this.timeTracker.showSpentOnly).toBe(true);
expect($spentOnlyPane).toBeVisible();
});
});
describe('No time tracking pane', function() {
beforeEach(function() {
const time_estimated = generateTimeObject(2, 2, 2, 0, 5880);
const time_spent = generateTimeObject(1, 1, 1, 0, 2940);
const timeTrackingComponent = Vue.extend(gl.TimeTrackingDisplay);
this.timeTracker = new timeTrackingComponent({ data: { time_estimated, time_spent }}).$mount();
const time_estimate = 0;
const time_spent = 0;
const timeTrackingComponent = Vue.extend(gl.IssuableTimeTracker);
const initialData = this.initialData = { time_estimate, time_spent };
this.timeTracker = new timeTrackingComponent({
data: initialData
}).$mount();
});
// Look for The text
it('should only show the "No time tracking" pane when both time_estimate and time_spent are falsey', function() {
const $noTrackingPane = $('.time-tracking-no-tracking');
expect(this.timeTracker.showNoTimeTracking).toBe(true);
expect($noTrackingPane).toBeVisible();
});
});
describe("Help pane", function() {
beforeEach(function() {
const time_estimate = 100000;
const time_spent = 50000;
const timeTrackingComponent = Vue.extend(gl.IssuableTimeTracker);
const initialData = this.initialData = { time_estimate, time_spent };
this.timeTracker = new timeTrackingComponent({
data: initialData
}).$mount();
});
// close button
// link to help
it('should only not show the "Help" pane by default', function() {
const $helpPane = $('.time-tracking-help-state');
expect(this.timeTracker.showHelp).toBe(false);
expect($helpPane).toBeHidden();
});
it('should only show the "Help" pane when toggled', function() {
const $helpPane = $('.time-tracking-help-state');
expect(this.timeTracker.showHelp).toBe(true);
expect($helpPane).toBeVisible();
});
});
});
});
describe('Internal Component Logic', function() {
describe('Computed Intermediaries', function() {
});
describe('Methods', function() {
// parseSeconds
});
});
// show the correct pane
// parse second
// seconds to minutes
// stringify a time value
// the percent is being calculated and displayed correctly on the compare meter
// differ works, if needed
//
//
whether values that are important are actually display
it('should parse a time diff based on total minutes', function() {
const parsedDiff = this.timeTracker.parsedDiff;
expect(parsedDiff.weeks).toBe(1);
expect(parsedDiff.days).toBe(1);
expect(parsedDiff.hours).toBe(1);
expect(parsedDiff.minutes).toBe(0);
});
it('should stringify a time value', function() {
const timeTracker = this.timeTracker;
const noZeroes = generateTimeObject(1, 1, 1, 2, 2940);
const someZeroes = generateTimeObject(1, 0, 1, 0, 2940);
expect(timeTracker.stringifyTime(noZeroes)).toBe('1w 1d 1h 2m');
expect(timeTracker.stringifyTime(someZeroes)).toBe('1w 1h');
});
it('should abbreviate a stringified value', function() {
const stringifyTime = this.timeTracker.stringifyTime;
const oneWeek = stringifyTime(generateTimeObject(1, 1, 1, 1, 2940));
const oneDay = stringifyTime(generateTimeObject(0, 1, 1, 1, 2940));
const oneHour = stringifyTime(generateTimeObject(0, 0, 1, 1, 2940));
const oneMinute = stringifyTime(generateTimeObject(0, 0, 0, 1, 2940));
const abbreviateTimeFilter = Vue.filter('abbreviate-time');
expect(abbreviateTimeFilter(oneWeek)).toBe('1w');
expect(abbreviateTimeFilter(oneDay)).toBe('1d');
expect(abbreviateTimeFilter(oneHour)).toBe('1h');
expect(abbreviateTimeFilter(oneMinute)).toBe('1m');
});
it('should toggle the help state', function() {
const timeTracker = this.timeTracker;
expect(timeTracker.displayHelp).toBe(false);
timeTracker.toggleHelpState(true);
expect(timeTracker.displayHelp).toBe(true);
timeTracker.toggleHelpState(false);
expect(timeTracker.displayHelp).toBe(false);
});
});
})(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