Created
August 7, 2014 14:00
-
-
Save caryfitzhugh/d0b577c6d7ceb4ab6953 to your computer and use it in GitHub Desktop.
JS Test
This file contains hidden or 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
test("Test that added_recipes will toggle the detail state", function () { | |
// Get our recipe | |
var recipe = Factories.make_recipe({in_box: false}); | |
var other_recipe = Factories.make_recipe(); | |
// Spying -- not needed. | |
$(document).trigger('recipes.show_recipe', recipe); | |
// Now make sure that it is showing the "Save Recipe" button | |
// Meaning the 'in-box' class is not present | |
ok(this.$node.find('.controls .recipe.in-box').length === 0); | |
ok(this.$node.find('.controls .recipe').length === 1); | |
// Now we emit the "recipe" was added | |
$(document).trigger('recipes.added_recipe', recipe); | |
// Should now say "in box" | |
ok(this.$node.find('.controls .recipe.in-box').length === 1); | |
ok(this.$node.find('.controls .recipe').length === 0); | |
}); | |
test("Test that added_recipes with a different recipe will NOT toggle the detail state", function () { | |
// Get our recipe | |
var recipe = Factories.make_recipe({in_box: false}); | |
var other_recipe = Factories.make_recipe(); | |
// Spying -- not needed. | |
$(document).trigger('recipes.show_recipe', recipe); | |
// Now make sure that it is showing the "Save Recipe" button | |
// Meaning the 'in-box' class is not present | |
ok(this.$node.find('.controls .recipe.in-box').length === 0); | |
ok(this.$node.find('.controls .recipe').length === 1); | |
// Now we emit the "other_recipe" was added, nothing should change | |
$(document).trigger('recipes.added_recipe', other_recipe); | |
// Nothing should change, still Save Recipe | |
ok(this.$node.find('.controls .recipe.in-box').length === 0); | |
ok(this.$node.find('.controls .recipe').length === 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment