Skip to content

Instantly share code, notes, and snippets.

@mhairston
Created March 11, 2016 14:20
Show Gist options
  • Save mhairston/c09b9bcf95e89bd30c3b to your computer and use it in GitHub Desktop.
Save mhairston/c09b9bcf95e89bd30c3b to your computer and use it in GitHub Desktop.
Jasmine sample test code
/*
Jasmine sample code
This file is called a spec.
describe() groups related tests within a spec.
it() contains a single test.
The outer describe() matches the name of the module being tested.
Select elements only via test-foo classes!
*/
describe("VHL.MyModuleName", function () {
describe('hide translation', function() {
it('toggles the translation when both are not visible', function() {
$('.test-target').css('visibility', 'visible');
$('.test-translation').css('visibility', 'hidden');
$('.test-hide_target').trigger('click');
expect($('.test-translation')).toHaveCss({'visibility': 'visible'});
});
it('toggles the visibility', function() {
$('.test-hide_translation').trigger('click');
expect($('.test-translation')).toHaveCss({'visibility': 'hidden'});
$('.test-hide_translation').trigger('click');
expect($('.test-translation')).toHaveCss({'visibility': 'visible'});
});
it('toggles the target when both are not visible', function() {
$('.test-target').css('visibility', 'hidden');
$('.test-translation').css('visibility', 'visible');
$('.test-hide_translation').trigger('click');
expect($('.test-target')).toHaveCss({'visibility': 'visible'});
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment