-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing jasmine tests to teaspoon-mocha #2997
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
acc6670
Changed jasmine tests to teaspoon-mocha
Souravirus ecd50a2
Few corrections
Souravirus c4dd5af
Corrected inline_grids_spec.js
Souravirus fdd9939
Some changes in first test of plots2_spec.js
Souravirus d785ab3
Made the first expect work
Souravirus a9cce9c
made the click function above the jquery function in plots_spec
Souravirus f6731ed
Corrected the wikis_spec.js
Souravirus b763330
Corrected all tests in plots2_spec.js
Souravirus 8ea25c6
Corrected the Gemfile
Souravirus e39a726
Running the rake test:all in Rakefile
Souravirus 45b31a6
Corrected the rubocop offenses
Souravirus a394862
Corrected some identation problem in .travis.yml
Souravirus 9b913b6
Passing the reports to dangerbot
Souravirus dc323c9
removed jasmine tasks from Rakefile and other modifications
Souravirus 129eaaa
Modified the Dangerfile
Souravirus 667d78a
Modified the travis.yml
Souravirus c1efddc
Changed the Dangerfile
Souravirus 6935388
Shortened test for js failure
Souravirus b2342bd
Some mistake while updation
Souravirus 0163625
Some changes in .travis.yml
Souravirus a12226b
Added junit-danger to Gemfile
Souravirus a0226f1
Modified the Dangerfile
Souravirus a1aca65
modification in Dangerfile
Souravirus d1ccec6
Modified Dangerfile
Souravirus 9a93e4e
Modified the Dangerfile
Souravirus 20da9c0
Written only junit.failures
Souravirus 5593eff
Reverted the changes required for Dangerbot reporting
Souravirus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,4 @@ test/reports/ | |
node_modules | ||
.byebug_history | ||
vendor/bundle | ||
spec/TEST-Teaspoon-Result.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,6 @@ | ||
<ul class="btn-group"> | ||
|
||
<li rel="tooltip" title="Helpful? Like it and get updates!" class="btn btn-default btn-sm btn-like" node-id="1" id="like-button-1"><span id="like-star-1" class="fa fa-star-o"></span> <span id="like-count-1">0</span></li> | ||
<li rel="tooltip" title="Helpful? Like it and get updates!" class="btn btn-default btn-sm btn-like" node-id="1" id="like-button-1"><span id="like-star-1" class="fa fa-star-o"></span> <span id="like-count-1">0</span></li> | ||
|
||
</ul> | ||
|
||
<script> | ||
jQuery(document).ready(function() { | ||
// 304 cached response yields no data to insert, which is not useful | ||
// jQuery.ajaxSetup({ | ||
// cache: false | ||
// }); | ||
|
||
// grab the like count for this node; "/likes/node/11278/count" | ||
// jQuery.getJSON("<%= like_count_path(node) %>", function (json) { | ||
// // push like count into the Like button placeholder | ||
// $('#like-count-<%= node.id %>').html(json); | ||
// }); | ||
|
||
// <% if current_user %> | ||
$('#like-button-1').on('click', clicknotliked); | ||
// <% end %> | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,106 @@ | ||
//= require application | ||
//= require jasmine-jquery | ||
//= require comment_expand | ||
|
||
//= require like | ||
var editor; | ||
|
||
describe("Plots2", function() { | ||
|
||
beforeEach(function() { | ||
|
||
// for phantomjs running | ||
jasmine.getFixtures().fixturesPath="../../spec/javascripts/fixtures"; | ||
|
||
// for in-browser running... still doesn't work | ||
//jasmine.getFixtures().fixturesPath = 'assets/fixtures'; | ||
preloadFixtures('index.html', 'unlike.html', 'comment_expand.html'); | ||
|
||
jasmine.Ajax.install(); | ||
fixture.preload('index.html', 'unlike.html', 'comment_expand.html'); | ||
|
||
}); | ||
|
||
it("sends a like request when like button is clicked", function() { | ||
|
||
afterEach(function(){ | ||
|
||
jasmine.Ajax.uninstall(); | ||
|
||
}); | ||
fixture.load('index.html'); | ||
|
||
ajaxStub = sinon.stub($, 'ajax', function(object) { | ||
|
||
it("sends a like request when like button is clicked", function() { | ||
if (object.url == '/likes/node/1/create') response = '4'; | ||
else response = 'none'; | ||
|
||
loadFixtures('index.html'); | ||
// check this if you have trouble faking a server response: | ||
if (response == '4'){ | ||
console.log('Faked response to:', object.url); | ||
} | ||
else console.log('Failed to fake response to:', object.url); | ||
|
||
ajaxSpy = spyOn($, "ajax").and.callFake(function(object) { | ||
var d = $.Deferred(); | ||
if(response == '4'){ | ||
d.resolve(response); | ||
} | ||
else{ | ||
d.reject(response); | ||
} | ||
|
||
if (object.url == '/likes/node/1/create') response = "4"; | ||
else response = 'none'; | ||
return d.promise(); | ||
|
||
// check this if you have trouble faking a server response: | ||
if (response != 'none'){ | ||
console.log('Faked response to:', object.url); | ||
console.log(response); | ||
} | ||
else console.log('Failed to fake response to:', object.url); | ||
|
||
// http://stackoverflow.com/questions/13148356/how-to-properly-unit-test-jquerys-ajax-promises-using-jasmine-and-or-sinon | ||
var d = $.Deferred(); | ||
d.resolve(response); | ||
d.reject(response); | ||
return d.promise(); | ||
}); | ||
|
||
$(document).ready(function(){ | ||
$("#like-button-1").on('click', clicknotliked); | ||
}); | ||
|
||
$('#like-button-1').trigger('click'); | ||
|
||
$("#like-button-1").click(); | ||
// should trigger the following and our ajaxSpy should return a fake response of "4": | ||
// jQuery.getJSON("/likes/node/1/create", {}, function() { ... | ||
// then triggering like.js code | ||
/*var response; | ||
jQuery.getJSON("/likes/node/1/create").done(function(data){ | ||
response = data; | ||
});*/ | ||
|
||
expect(response).toEqual('4'); | ||
expect($('#like-count-1').html()).toEqual('4'); // passing | ||
expect($('#like-star-1')[0].className).toEqual('fa fa-star'); | ||
// then triggering like.js code | ||
|
||
expect($('#like-count-1').html()).to.eql('4'); // passing | ||
expect($('#like-star-1')[0].className).to.eql('fa fa-star'); | ||
ajaxStub.restore(); | ||
}); | ||
|
||
|
||
it("unlikes a request if already liked", function() { | ||
|
||
loadFixtures('unlike.html'); | ||
fixture.load('unlike.html'); | ||
|
||
ajaxSpy = spyOn($, "ajax").and.callFake(function(object) { | ||
ajaxStub = sinon.stub($, 'ajax', function(object) { | ||
|
||
if (object.url == '/likes/node/1/delete') response = "-1"; | ||
else response = 'none'; | ||
if (object.url == '/likes/node/1/delete') response = '-1'; | ||
else response = 'none'; | ||
|
||
var d = $.Deferred(); | ||
d.resolve(response); | ||
d.reject(response); | ||
return d.promise(); | ||
// check this if you have trouble faking a server response: | ||
|
||
}); | ||
var d = $.Deferred(); | ||
if(response == '-1'){ | ||
d.resolve(response); | ||
} | ||
else{ | ||
d.reject(response); | ||
} | ||
|
||
return d.promise(); | ||
|
||
$('#like-button-1').trigger('click'); | ||
}); | ||
|
||
expect(response).toEqual('-1'); | ||
expect($('#like-count-1').html()).toEqual('0'); | ||
expect($('#like-star-1')[0].className).toEqual('fa fa-star-o'); | ||
$(document).ready(function(){ | ||
$("#like-button-1").on('click', clickliked); | ||
}); | ||
|
||
$("#like-button-1").trigger('click'); | ||
expect($('#like-count-1').html()).to.eql('0'); | ||
expect($('#like-star-1')[0].className).to.eql('fa fa-star-o'); | ||
ajaxStub.restore(); | ||
}); | ||
|
||
it("shows expand comment button with remaining comment count", function(){ | ||
loadFixtures('comment_expand.html'); | ||
fixture.load('comment_expand.html'); | ||
|
||
$('#answer-0-expand').trigger('click'); | ||
expect($('#answer-0-expand').html()).toEqual('View 2 previous comments'); | ||
expand_comments(0); | ||
expect($('#answer-0-expand').html()).to.eql('View 2 previous comments'); | ||
|
||
$('#answer-0-expand').trigger('click'); | ||
expect($('#answer-0-expand').css('display')).toEqual('none'); | ||
expand_comments(0); | ||
expect($('#answer-0-expand').css('display')).to.eql('none'); | ||
}); | ||
|
||
it("loads up i18n-js library properly", function() { | ||
expect(I18n.t('js.dashboard.selected_updates')).toBe('Selected updates') | ||
expect(I18n.t('js.dashboard.selected_updates')).to.eql('Selected updates') | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Teaspoon includes some support files, but you can use anything from your own support path too. | ||
//= require support/expect | ||
//= require support/sinon | ||
//= require support/chai | ||
//= require jquery | ||
// require support/chai-jq-0.0.7 | ||
// require support/your-support-file | ||
// | ||
// PhantomJS (Teaspoons default driver) doesn't have support for Function.prototype.bind, which has caused confusion. | ||
// Use this polyfill to avoid the confusion. | ||
//= require support/phantomjs-shims | ||
// | ||
// You can require your own javascript files here. By default this will include everything in application, however you | ||
// may get better load performance if you require the specific files that are being used in the spec that tests them. | ||
//= require application | ||
// | ||
// Deferring execution | ||
// If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call | ||
// Teaspoon.execute() after everything has been loaded. Simple example of a timeout: | ||
// | ||
// Teaspoon.defer = true | ||
// setTimeout(Teaspoon.execute, 1000) | ||
// | ||
// Matching files | ||
// By default Teaspoon will look for files that match _spec.{js,js.coffee,.coffee}. Add a filename_spec.js file in your | ||
// spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the | ||
// configuration in teaspoon_env.rb | ||
// | ||
// Manifest | ||
// If you'd rather require your spec files manually (to control order for instance) you can disable the suite matcher in | ||
// the configuration and use this file as a manifest. | ||
// | ||
// For more information: http://github.com/modeset/teaspoon | ||
// | ||
// Chai | ||
// If you're using Chai, you'll probably want to initialize your preferred assertion style. You can read more about Chai | ||
// at: http://chaijs.com/guide/styles | ||
// | ||
window.assert = chai.assert; | ||
window.expect = chai.expect; | ||
window.should = chai.should(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* | ||
//= require application | ||
//= require jasmine-jquery | ||
//= require tagging | ||
|
||
var editor; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jywarren, can I know why we used setTimeout here. Can't we test this without it?