Skip to content

Instantly share code, notes, and snippets.

@joehoyle
Created October 11, 2013 17:14
Show Gist options
  • Save joehoyle/6938515 to your computer and use it in GitHub Desktop.
Save joehoyle/6938515 to your computer and use it in GitHub Desktop.
var postL10n = {
comma: ','
}
jQuery( function() {
module( 'post-tags-metabox' );
// mock the tags div
var tagsDiv = jQuery( '<div />' ).addClass('tagsdiv').append(
jQuery( '<textarea>' ).val( 'tag1,tag2,"tag,with,comma"' ).addClass('the-tags')
);
test( "tags should be parsed from textarea return ['tag2', 'tag1']", function() {
tagBox.quickClicks( tagsDiv )
ok( tagsDiv.data('tags').indexOf( 'tag2') > -1 )
ok( tagsDiv.data('tags').indexOf( 'tag1') > -1 )
ok( tagsDiv.data('tags').indexOf( 'tag,with,comma') > -1 )
ok( tagsDiv.data('tags').length == 3 )
});
test( "DOM input elements should exist for each tag", function() {
ok( tagsDiv.find( 'input[value="tag1"]' ).length == 1, 'DOM element was not found for tag' )
})
test( "removing a tag should remove from tags data", function() {
tagBox.removeTag(tagsDiv, 'tag1')
ok( tagsDiv.data('tags').indexOf( 'tag1') == -1, 'Tag is still found after removing' )
})
test( "removing a tag should remove the tag DOM input element", function() {
ok( tagsDiv.find( 'input[value="tag1"]' ).length == 0, 'DOM element was still found for removed tag' )
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment