'use strict'; describe('ngShow / ngHide', function() { var element; afterEach(function() { dealoc(element); }); describe('ngShow', function() { it('should show and hide an element', inject(function($rootScope, $compile) { element = jqLite('
'); element = $compile(element)($rootScope); $rootScope.$digest(); expect(element).toBeHidden(); $rootScope.exp = true; $rootScope.$digest(); expect(element).toBeShown(); })); it('should make hidden element visible', inject(function($rootScope, $compile) { element = jqLite('
'); element = $compile(element)($rootScope); expect(element).toBeHidden(); $rootScope.exp = true; $rootScope.$digest(); expect(element).toBeShown(); })); }); describe('ngHide', function() { it('should hide an element', inject(function($rootScope, $compile) { element = jqLite('
'); element = $compile(element)($rootScope); expect(element).toBeShown(); $rootScope.exp = true; $rootScope.$digest(); expect(element).toBeHidden(); })); }); }); describe('ngShow / ngHide animations', function() { var body, element, $rootElement; function html(html) { body.append($rootElement); $rootElement.html(html); element = $rootElement.children().eq(0); return element; } beforeEach(function() { // we need to run animation on attached elements; body = jqLite(document.body); }); afterEach(function(){ dealoc(body); dealoc(element); body.removeAttr('ng-animation-running'); }); beforeEach(module('mock.animate')); beforeEach(module(function($animateProvider, $provide) { return function(_$rootElement_) { $rootElement = _$rootElement_; }; })); describe('ngShow', function() { it('should fire off the $animate.show and $animate.hide animation', inject(function($compile, $rootScope, $animate) { var item; var $scope = $rootScope.$new(); $scope.on = true; element = $compile(html( '
data
' ))($scope); $scope.$digest(); item = $animate.flushNext('removeClass').element; expect(item.text()).toBe('data'); expect(item).toBeShown(); $scope.on = false; $scope.$digest(); item = $animate.flushNext('addClass').element; expect(item.text()).toBe('data'); expect(item).toBeHidden(); })); }); describe('ngHide', function() { it('should fire off the $animate.show and $animate.hide animation', inject(function($compile, $rootScope, $animate) { var item; var $scope = $rootScope.$new(); $scope.off = true; element = $compile(html( '
datum
' ))($scope); $scope.$digest(); item = $animate.flushNext('addClass').element; expect(item.text()).toBe('datum'); expect(item).toBeHidden(); $scope.off = false; $scope.$digest(); item = $animate.flushNext('removeClass').element; expect(item.text()).toBe('datum'); expect(item).toBeShown(); })); }); }); cf6fab3d9b21ad50d7a115a0c917c0e23a1a738'>root/djangorestframework/runtests/runtests.py
blob: 9f5cc7aa69e3ab43db2a563c584245d371076da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'''
Created on Mar 10, 2011

@author: tomchristie
'''
# http://ericholscher.com/blog/2009/jun/29/enable-setuppy-test-your-django-apps/
# http://www.travisswicegood.com/2010/01/17/django-virtualenv-pip-and-fabric/
# http://code.djangoproject.com/svn/django/trunk/tests/runtests.py
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'djangorestframework.runtests.settings'

from django.conf import settings
from django.test.utils import get_runner

def usage():
    return """
    Usage: python runtests.py [UnitTestClass].[method]

    You can pass the Class name of the `UnitTestClass` you want to test.

    Append a method name if you only want to test a specific method of that class.
    """

def main():
    TestRunner = get_runner(settings)

    test_runner = TestRunner()
    if len(sys.argv) == 2:
        test_case = '.' + sys.argv[1]
    elif len(sys.argv) == 1:
        test_case = ''
    else:
        print usage()
        sys.exit(1)
    failures = test_runner.run_tests(['djangorestframework' + test_case])

    sys.exit(failures)

if __name__ == '__main__':
    main()