fix oembed onclick behavior + specs
This commit is contained in:
parent
9534caeb05
commit
bf82fc17fe
2 changed files with 38 additions and 13 deletions
|
|
@ -78,7 +78,7 @@ app.views.ActivityStreams__Photo = app.views.Content.extend({
|
||||||
app.views.OEmbed = app.views.Base.extend({
|
app.views.OEmbed = app.views.Base.extend({
|
||||||
templateName : "oembed",
|
templateName : "oembed",
|
||||||
events : {
|
events : {
|
||||||
"click .oembed .thumb": "showOembedContent"
|
"click .thumb": "showOembedContent"
|
||||||
},
|
},
|
||||||
|
|
||||||
presenter:function () {
|
presenter:function () {
|
||||||
|
|
|
||||||
|
|
@ -3,29 +3,54 @@ describe("app.views.OEmbed", function(){
|
||||||
this.statusMessage = factory.statusMessage({
|
this.statusMessage = factory.statusMessage({
|
||||||
"o_embed_cache":{
|
"o_embed_cache":{
|
||||||
"data":{
|
"data":{
|
||||||
"html":"some html"
|
"html":"some html",
|
||||||
|
"thumbnail_url": "//example.com/thumb.jpg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
this.view = new app.views.OEmbed({model : this.statusMessage})
|
this.view = new app.views.OEmbed({model : this.statusMessage})
|
||||||
})
|
});
|
||||||
|
|
||||||
describe("rendering", function(){
|
describe("rendering", function(){
|
||||||
it("provides oembed html from the model response", function(){
|
context("with thumb", function() {
|
||||||
this.view.render()
|
it("shows the thumb with overlay", function(){
|
||||||
expect(this.view.$el.html()).toContain("some html")
|
this.view.render();
|
||||||
})
|
|
||||||
})
|
expect(this.view.$el.html()).toContain("example.com/thumb");
|
||||||
|
expect(this.view.$el.html()).toContain("video-overlay");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows the oembed html when clicking the thumb", function() {
|
||||||
|
this.view.render();
|
||||||
|
this.view.$('.thumb').click();
|
||||||
|
|
||||||
|
_.defer(function() {
|
||||||
|
expect(this.view.$el.html()).toContain("some html");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context("no thumb", function() {
|
||||||
|
beforeEach(function(){
|
||||||
|
this.statusMessage.set({"o_embed_cache" : {"data": {"html": "some html"}}});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides oembed html from the model response", function(){
|
||||||
|
this.view.render()
|
||||||
|
expect(this.view.$el.html()).toContain("some html")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("presenter", function(){
|
describe("presenter", function(){
|
||||||
it("provides oembed html from the model", function(){
|
it("provides oembed html from the model", function(){
|
||||||
expect(this.view.presenter().o_embed_html).toContain("some html")
|
expect(this.view.presenter().o_embed_html).toContain("some html")
|
||||||
})
|
});
|
||||||
|
|
||||||
it("does not provide oembed html from the model response if none is present", function(){
|
it("does not provide oembed html from the model response if none is present", function(){
|
||||||
this.statusMessage.set({"o_embed_cache" : null})
|
this.statusMessage.set({"o_embed_cache" : null})
|
||||||
expect(this.view.presenter().o_embed_html).toBe("");
|
expect(this.view.presenter().o_embed_html).toBe("");
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
Loading…
Reference in a new issue