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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
dd80e09a
Commit
dd80e09a
authored
Nov 14, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tests
parent
56aaa397
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
10 deletions
+108
-10
spec/javascripts/environments/environment_item_spec.js.es6
spec/javascripts/environments/environment_item_spec.js.es6
+108
-10
No files found.
spec/javascripts/environments/environment_item_spec.js.es6
View file @
dd80e09a
...
@@ -9,7 +9,6 @@ describe('Environment item', () => {
...
@@ -9,7 +9,6 @@ describe('Environment item', () => {
describe('When item is folder', () => {
describe('When item is folder', () => {
let mockItem;
let mockItem;
let component;
beforeEach(() => {
beforeEach(() => {
mockItem = {
mockItem = {
...
@@ -35,38 +34,137 @@ describe('Environment item', () => {
...
@@ -35,38 +34,137 @@ describe('Environment item', () => {
},
},
],
],
};
};
});
component = new window.gl.environmentsList.EnvironmentItem({
it('Should render clickable folder icon and name', () => {
const component = new window.gl.environmentsList.EnvironmentItem({
el: document.querySelector('tr#environment-row'),
el: document.querySelector('tr#environment-row'),
propsData: {
propsData: {
model: mockItem,
model: mockItem,
toggleRow: () => {},
'can-create-deployment': false,
'can-create-deployment': false,
'can-read-environment': true,
'can-read-environment': true,
},
},
});
});
});
it('Should render clickable folder icon and name', () => {
expect(component.$el.querySelector('.folder-name').textContent).toContain(mockItem.name);
expect(document.querySelector('.folder-name').textContent).toContain(mockItem.name);
expect(component.$el.querySelector('.folder-icon')).toBeDefined();
expect(document.querySelector('.folder-icon')).toBeDefined();
});
});
it('Should render the number of children in a badge', () => {
it('Should render the number of children in a badge', () => {
expect(document.querySelector('.folder-name .badge').textContent).toContain(mockItem.children.length);
const component = new window.gl.environmentsList.EnvironmentItem({
});
el: document.querySelector('tr#environment-row'),
propsData: {
model: mockItem,
toggleRow: () => {},
'can-create-deployment': false,
'can-read-environment': true,
},
});
it('Should not render any information other than the name', () => {
expect(component.$el.querySelector('.folder-name .badge').textContent).toContain(mockItem.children.length);
});
});
describe('when clicked', () => {
describe('when clicked', () => {
it('Should render child row', () => {
it('Should call the given prop', () => {
const component = new window.gl.environmentsList.EnvironmentItem({
el: document.querySelector('tr#environment-row'),
propsData: {
model: mockItem,
toggleRow: () => {
console.log('here!');
},
'can-create-deployment': false,
'can-read-environment': true,
},
});
spyOn(component.$options.propsData, 'toggleRow');
component.$el.querySelector('.folder-name').click();
expect(component.$options.propsData.toggleRow).toHaveBeenCalled();
});
});
});
});
});
});
describe('when item is not folder', () => {
describe('when item is not folder', () => {
let environment;
beforeEach(() => {
environment = {
id: 31,
name: 'production',
state: 'stopped',
external_url: 'http://external.com',
environment_type: null,
last_deployment: {
id: 66,
iid: 6,
sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
ref: {
name: 'master',
ref_url: 'http://localhost:3000/root/ci-folders/tree/master',
},
tag: true,
'last?': true,
user: {
name: 'Administrator',
username: 'root',
id: 1,
state: 'active',
avatar_url: 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
web_url: 'http://localhost:3000/root',
},
commit: {
id: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
short_id: '500aabcb',
title: 'Update .gitlab-ci.yml',
author_name: 'Administrator',
author_email: 'admin@example.com',
created_at: '2016-11-07T18:28:13.000+00:00',
message: 'Update .gitlab-ci.yml',
author: {
name: 'Administrator',
username: 'root',
id: 1,
state: 'active',
avatar_url: 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
web_url: 'http://localhost:3000/root',
},
commit_url: 'http://localhost:3000/root/ci-folders/tree/500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
},
deployable: {
id: 1279,
name: 'deploy',
build_url: 'http://localhost:3000/root/ci-folders/builds/1279',
retry_url: 'http://localhost:3000/root/ci-folders/builds/1279/retry',
},
manual_actions: [
{
name: 'action',
play_url: 'http://localhost:3000/play',
},
],
},
'stoppable?': true,
environment_url: 'http://localhost:3000/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-10T15:55:58.778Z',
};
});
it('should render environment name', () => {
it('should render environment name', () => {
const component = new window.gl.environmentsList.EnvironmentItem({
el: document.querySelector('tr#environment-row'),
propsData: {
model: environment,
toggleRow: () => {},
'can-create-deployment': false,
'can-read-environment': true,
},
});
debugger;
});
});
describe('With deployment', () => {
describe('With deployment', () => {
...
...
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