Skip to content

Instantly share code, notes, and snippets.

@skw
Forked from seanhagen/video.js
Created October 23, 2013 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skw/7123881 to your computer and use it in GitHub Desktop.
Save skw/7123881 to your computer and use it in GitHub Desktop.
describe( "Video model", function(){
var MOCK_GET_DATA = {
channelName: "tgndeveloperedu",
commentCount: 0,
defaultOrder: 0,
dislikeCount: 0,
facebookCount: "0",
googleCount: "0",
likeCount: 0,
optimized: false,
originalSrc: null,
overlaySrc: null,
pinterestCount: "0",
published: "2013-10-08 13:58:28",
revenue: 0,
schedulerPublishDate: null,
schedulerSelectedTz: null,
schedulerStatus: null,
selectedThumbnailSrc: null,
smallOriginalSrc: null,
status: "private",
subscribersGained: 0,
thumbnailOptimized: false,
thumbnailPublishDate: false,
thumbnailsAvailable: false,
title: "sample_iPod 2.m4v",
twitterCount: "0",
updatedThumbnailSrc: null,
updatedThumbnailUploaded: null,
uploadedThumbnailSrc: null,
videoId: "7O_vD_3Qmss",
videoUploaderStatus: "8",
viewCount: 0,
watchTime: 0
};
var MOCK_POST_DATA = {
success: true
};
describe( "when it fetches", function(){
var model;
var spy;
beforeEach( function(){
//spy = sinon.spy( jQuery, "ajax" );
model = new VideoModel({videoId: '7O_vD_3Qmss'});
this.server = sinon.fakeServer.create();
this.server.respondWith(
"GET",
"/api/video/7O_vD_3Qmss",
[
200,
{ "Content-Type": "application/json" },
JSON.stringify( MOCK_GET_DATA )
]
);
model.fetch();
this.server.respond();
});
afterEach( function(){
//jQuery.ajax.restore();
model = null;
spy = null;
this.server.restore();
});
it('should be able to parse mocked service response', function(){
expect(_.isEmpty(model.attributes)).to.equal(false);
expect( model.get('channelName') ).to.equal( MOCK_GET_DATA.channelName );
expect( model.get('published') ).to.equal( MOCK_GET_DATA.published );
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment