Skip to content

Instantly share code, notes, and snippets.

@camwest
Created July 10, 2009 20:20
Show Gist options
  • Select an option

  • Save camwest/144784 to your computer and use it in GitHub Desktop.

Select an option

Save camwest/144784 to your computer and use it in GitHub Desktop.
public class EpisodeItemViewPresentationModelTest
{
private var model:EpisodeItemViewPresentationModel;
private var mockDispatcher:MockEventDispatcher;
//-----------------------------------------------
// Setup
//-----------------------------------------------
[Before]
public function setup():void
{
mockDispatcher = new MockEventDispatcher();
model = new EpisodeItemViewPresentationModel(mockDispatcher);
}
//-----------------------------------------------
// Tests
//-----------------------------------------------
[Test(description="Test published episode")]
public function published():void
{
model.episode = new Episode({ approved: true });
Assert.assertEquals(EpisodeItemViewPresentationModel.PUBLISHED, model.state);
}
[Test(description="Test pending episode")]
public function pending():void
{
model.episode = new Episode( { video_url : "http://someurl.flv" } );
Assert.assertEquals(EpisodeItemViewPresentationModel.PENDING, model.state);
}
[Test(description="Test uploading episode")]
public function uploading():void
{
model.episode = new Episode();
Assert.assertEquals(EpisodeItemViewPresentationModel.UPLOADING, model.state);
}
[Ignore("I don't know how to test the change watcher")]
[Test(async, description="Test video finishes uploading")]
public function testFinishUploading():void
{
var ep:Episode = new Episode();
model.episode = new Episode();
Assert.assertEquals("While uploading a new video, the state should be uploading", EpisodeItemViewPresentationModel.UPLOADING, model.state);
ep.id = 123;
Assert.assertEquals("After the episode is assigned an id we should see the state change", EpisodeItemViewPresentationModel.PENDING, model.state);
}
//-----------------------------------------------
// Helpers
//-----------------------------------------------
private function testEvent( event : Event, data : Object ) : void { };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment