aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-01-09 15:02:43 -0800
committerMisko Hevery2010-01-09 15:02:43 -0800
commit9b9a0dadcce82ae42ac09ad396d647739af20a06 (patch)
tree854d162ac442509d12b17d7ed5123d7d43850f1e /test
parent88eca572fdc7f68a7f384b612052c49de00df433 (diff)
downloadangular.js-9b9a0dadcce82ae42ac09ad396d647739af20a06.tar.bz2
removed nglr namespace
Diffstat (limited to 'test')
-rw-r--r--test/BinderTest.js209
-rw-r--r--test/ConsoleTest.js9
-rw-r--r--test/DataStoreTest.js96
-rw-r--r--test/EntityDeclarationTest.js8
-rw-r--r--test/FileControllerTest.js24
-rw-r--r--test/FiltersTest.js16
-rw-r--r--test/JsonTest.js54
-rw-r--r--test/LoaderTest.js18
-rw-r--r--test/ModelTest.js12
-rw-r--r--test/ParserTest.js108
-rw-r--r--test/ScopeTest.js32
-rw-r--r--test/ServerTest.js10
-rw-r--r--test/UsersTest.js4
-rw-r--r--test/WidgetsTest.js95
-rw-r--r--test/XSitePostTest.js47
-rw-r--r--test/formsTest.js4
-rw-r--r--test/testabilityPatch.js16
17 files changed, 356 insertions, 406 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js
index d033996d..0ffd2120 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -3,10 +3,10 @@ BinderTest = TestCase('BinderTest');
function compile(content, initialScope, config) {
var h = html(content);
config = config || {autoSubmit:true};
- var scope = new nglr.Scope(initialScope, "ROOT");
+ var scope = new Scope(initialScope, "ROOT");
h.data('scope', scope);
- var binder = new nglr.Binder(h[0], new nglr.WidgetFactory(), new MockUrlWatcher(), config);
- var datastore = new nglr.DataStore();
+ var binder = new Binder(h[0], new WidgetFactory(), new MockUrlWatcher(), config);
+ var datastore = new DataStore();
scope.set("$datastore", datastore);
scope.set("$binder", binder);
scope.set("$anchor", binder.anchor);
@@ -19,80 +19,79 @@ function compileToHtml(content) {
return compile(content).node.sortedHtml();
}
-
BinderTest.prototype.testParseTextWithNoBindings = function(){
- var parts = nglr.Binder.parseBindings("a");
+ var parts = Binder.parseBindings("a");
assertEquals(parts.length, 1);
assertEquals(parts[0], "a");
- assertTrue(!nglr.Binder.binding(parts[0]));
+ assertTrue(!Binder.binding(parts[0]));
};
BinderTest.prototype.testParseEmptyText = function(){
- var parts = nglr.Binder.parseBindings("");
+ var parts = Binder.parseBindings("");
assertEquals(parts.length, 1);
assertEquals(parts[0], "");
- assertTrue(!nglr.Binder.binding(parts[0]));
+ assertTrue(!Binder.binding(parts[0]));
};
BinderTest.prototype.testParseInnerBinding = function(){
- var parts = nglr.Binder.parseBindings("a{{b}}c");
+ var parts = Binder.parseBindings("a{{b}}c");
assertEquals(parts.length, 3);
assertEquals(parts[0], "a");
- assertTrue(!nglr.Binder.binding(parts[0]));
+ assertTrue(!Binder.binding(parts[0]));
assertEquals(parts[1], "{{b}}");
- assertEquals(nglr.Binder.binding(parts[1]), "b");
+ assertEquals(Binder.binding(parts[1]), "b");
assertEquals(parts[2], "c");
- assertTrue(!nglr.Binder.binding(parts[2]));
+ assertTrue(!Binder.binding(parts[2]));
};
BinderTest.prototype.testParseEndingBinding = function(){
- var parts = nglr.Binder.parseBindings("a{{b}}");
+ var parts = Binder.parseBindings("a{{b}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "a");
- assertTrue(!nglr.Binder.binding(parts[0]));
+ assertTrue(!Binder.binding(parts[0]));
assertEquals(parts[1], "{{b}}");
- assertEquals(nglr.Binder.binding(parts[1]), "b");
+ assertEquals(Binder.binding(parts[1]), "b");
};
BinderTest.prototype.testParseBeggingBinding = function(){
- var parts = nglr.Binder.parseBindings("{{b}}c");
+ var parts = Binder.parseBindings("{{b}}c");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
- assertEquals(nglr.Binder.binding(parts[0]), "b");
+ assertEquals(Binder.binding(parts[0]), "b");
assertEquals(parts[1], "c");
- assertTrue(!nglr.Binder.binding(parts[1]));
+ assertTrue(!Binder.binding(parts[1]));
};
BinderTest.prototype.testParseLoanBinding = function(){
- var parts = nglr.Binder.parseBindings(
from django.forms import ModelForm
from django.db.models import Model
from django.db.models.query import QuerySet
from django.db.models.fields.related import RelatedField

from djangorestframework.response import Response, ErrorResponse
from djangorestframework.resource import Resource
from djangorestframework import status, validators

import decimal
import inspect
import re


class ModelResource(Resource):
    """A specialized type of Resource, for resources that map directly to a Django Model.
    Useful things this provides:

    0. Default input validation based on ModelForms.
    1. Nice serialization of returned Models and QuerySets.
    2. A default set of create/read/update/delete operations."""
    
    # List of validators to validate, cleanup and type-ify the request content    
    validators = (validators.ModelFormValidator,)
    
    # The model attribute refers to the Django Model which this Resource maps to.
    # (The Model's class, rather than an instance of the Model)
    model = None
    
    # By default the set of returned fields will be the set of:
    #
    # 0. All the fields on the model, excluding 'id'.
    # 1. All the properties on the model.
    # 2. The absolute_url of the model, if a get_absolute_url method exists for the model.
    #
    # If you wish to override this behaviour,
    # you should explicitly set the fields attribute on your class.
    fields = None
    
    # By default the form used with be a ModelForm for self.model
    # If you wish to override this behaviour or provide a sub-classed ModelForm
    # you should explicitly set the form attribute on your class.
    form = None
    
    # By default the set of input fields will be the same as the set of output fields
    # If you wish to override this behaviour you should explicitly set the
    # form_fields attribute on your class. 
    #form_fields = None


    #def get_form(self, content=None):
    #    """Return a form that may be used in validation and/or rendering an html emitter"""
    #    if self.form:
    #        return super(self.__class__, self).get_form(content)
    #
    #    elif self.model:
    #
    #        class NewModelForm(ModelForm):
    #            class Meta:
    #                model = self.model
    #                fields = self.form_fields if self.form_fields else None
    #
    #        if content and isinstance(content, Model):
    #            return NewModelForm(instance=content)
    #        elif content:
    #            return NewModelForm(content)
    #        
    #        return NewModelForm()
    #
    #    return None


    #def cleanup_request(self, data, form_instance):
    #    """Override cleanup_request to drop read-only fields from the input prior to validation.
    #    This ensures that we don't error out with 'non-existent field' when these fields are supplied,
    #    and allows for a pragmatic approach to resources which include read-only elements.
    #
    #    I would actually like to be strict and verify the value of correctness of the values in these fields,
    #    although that gets tricky as it involves validating at the point that we get the model instance.
    #    
    #    See here for another example of this approach:
    #    http://fedoraproject.org/wiki/Cloud_APIs_REST_Style_Guide
    #    https://www.redhat.com/archives/rest-practices/2010-April/thread.html#00041"""
    #    read_only_fields = set(self.fields) - set(self.form_instance.fields)
    #    input_fields = set(data.keys())
    #
    #    clean_data = {}
    #    for key in input_fields - read_only_fields:
    #        clean_data[key] = data[key]
    #
    #    return super(ModelResource, self).cleanup_request(clean_data, form_instance)


    def cleanup_response(self, data):
        """A munging of Piston's pre-serialization.  Returns a dict"""

        def _any(thing, fields=()):
            """
            Dispatch, all types are routed through here.
            """
            ret = None
            
            if isinstance(thing, QuerySet):
                ret = _qs(thing, fields=fields)
            elif isinstance(thing, (tuple, list)):
                ret = _list(thing)
            elif isinstance(thing, dict):
                ret = _dict(thing)
            elif isinstance(thing, int):
                ret = thing
            elif isinstance(thing, bool):
                ret = thing
            elif isinstance(thing, type(None)):
                ret = thing
            elif isinstance(thing, decimal.Decimal):
                ret = str(thing)
            elif isinstance(thing, Model):
                ret = _model(thing, fields=fields)
            #elif isinstance(thing, HttpResponse):    TRC
            #    raise HttpStatusCode(thing)
            elif inspect.isfunction(thing):
                if not inspect.getargspec(thing)[0]:
                    ret = _any(thing())
            elif hasattr(thing, '__emittable__'):
                f = thing.__emittable__
                if inspect.ismethod(f) and len(inspect.getargspec(f)[0]) == 1:
                    ret = _any(f())
            else:
                ret = unicode(thing)  # TRC  TODO: Change this back!

            return ret

        def _fk(data, field):
            """
            Foreign keys.
            """
            return _any(getattr(data, field.name))
        
        def _related(data, fields=()):
            """
            Foreign keys.
            """
            return [ _model(m, fields) for m in data.iterator() ]
        
        def _m2m(data, field, fields=()):
            """
            Many to many (re-route to `_model`.)
            """
            return [ _model(m, fields) for m in getattr(data, field.name).iterator() ]
        

        def _method_fields(data, fields):
            if not data:
                return { }
    
            has = dir(data)
            ret = dict()
                
            for field in fields:
                if field in has:
                    ret[field] = getattr(data, field)
            
            return ret

        def _model(data, fields=()):
            """
            Models. Will respect the `fields` and/or
            `exclude` on the handler (see `typemapper`.)
            """
            ret = { }
            #handler = self.in_typemapper(type(data), self.anonymous)  # TRC
            handler = None                                             # TRC
            get_absolute_url = False
            
            if handler or fields:
                v = lambda f: getattr(data, f.attname)

                if not fields:
                    """
                    Fields was not specified, try to find teh correct
                    version in the typemapper we were sent.
                    """
                    mapped = self.in_typemapper(type(data), self.anonymous)
                    get_fields = set(mapped.fields)
                    exclude_fields = set(mapped.exclude).difference(get_fields)
                
                    if not get_fields:
                        get_fields = set([ f.attname.replace("_id", "", 1)
                            for f in data._meta.fields ])
                
                    # sets can be negated.
                    for exclude in exclude_fields:
                        if isinstance(exclude, basestring):
                            get_fields.discard(exclude)
                            
                        elif isinstance(exclude, re._pattern_type):
                            for field in get_fields.copy():
                                if exclude.match(field):
                                    get_fields.discard(field)
                    
                    get_absolute_url = True

                else:
                    get_fields = set(fields)
                    if 'absolute_url' in get_fields:   # MOVED (TRC)
                        get_absolute_url = True

                met_fields = _method_fields(handler, get_fields)  # TRC

                for f in data._meta.local_fields:
                    if f.serialize and not any([ p in met_fields for p in [ f.attname, f.name ]]):
                        if not f.rel:
                            if f.attname in get_fields:
                                ret[f.attname] = _any(v(f))
                                get_fields.remove(f.attname)
                        else:
                            if f.attname[:-3] in get_fields:
                                ret[f.name] = _fk(data, f)
                                get_fields.remove(f.name)
                
                for mf in data._meta.many_to_many:
                    if mf.serialize and mf.attname not in met_fields:
                        if mf.attname in get_fields:
                            ret[mf.name] = _m2m(data, mf)
                            get_fields.remove(mf.name)
                
                # try to get the remainder of fields
                for maybe_field in get_fields:
                    
                    if isinstance(maybe_field, (list, tuple)):
                        model, fields = maybe_field
                        inst = getattr(data, model, None)

                        if inst:
                            if hasattr(inst, 'all'):
                                ret[model] = _related(inst, fields)
                            elif callable(inst):
                                if len(inspect.getargspec(inst)[0]) == 1:
                                    ret[model] = _any(inst(), fields)
                            else:
                                ret[model] = _model(inst, fields)

                    elif maybe_field in met_fields:
                        # Overriding normal field which has a "resource method"
                        # so you can alter the contents of certain fields without
                        # using different names.
                        ret[maybe_field] = _any(met_fields[maybe_field](data))

                    else:                    
                        maybe = getattr(data, maybe_field, None)
                        if maybe:
                            if callable(maybe):
                                if len(inspect.getargspec(maybe)[0]) == 1:
                                    ret[maybe_field] = _any(maybe())
                            else:
                                ret[maybe_field] = _any(maybe)
                        else:
                            pass   # TRC
                            #handler_f = getattr(handler or self.handler, maybe_field, None)
                            #
                            #if handler_f:
                            #    ret[maybe_field] = _any(handler_f(data))

            else:
                # Add absolute_url if it exists
                get_absolute_url = True
                
                # Add all the fields
                for f in data._meta.fields:
                    if f.attname != 'id':
                        ret[f.attname] = _any(getattr(data, f.attname))
                
                # Add all the propertiess
                klass = data.__class__
                for attr in dir(klass):
                    if not attr.startswith('_') and not attr in ('pk','id') and isinstance(getattr(klass, attr, None), property):
                        #if attr.endswith('_url') or attr.endswith('_uri'):
                        #    ret[attr] = self.make_absolute(_any(getattr(data, attr)))
                        #else:
                        ret[attr] = _any(getattr(data, attr))
                #fields = dir(data.__class__) + ret.keys()
                #add_ons = [k for k in dir(data) if k not in fields and not k.startswith('_')]
                #print add_ons
                ###print dir(data.__class__)
                #from django.db.models import Model
                #model_fields = dir(Model)

                #for attr in dir(data):
                ##    #if attr.startswith('_'):
                ##    #    continue
                #    if (attr in fields) and not (attr in model_fields) and not attr.startswith('_'):
                #        print attr, type(getattr(data, attr, None)), attr in fields, attr in model_fields
                
                #for k in add_ons:
                #    ret[k] = _any(getattr(data, k))
            
            # TRC
            # resouce uri
            #if self.in_typemapper(type(data), self.anonymous):
            #    handler = self.in_typemapper(type(data), self.anonymous)
            #    if hasattr(handler, 'resource_uri'):
            #        url_id, fields = handler.resource_uri()
            #        ret['resource_uri'] = permalink( lambda: (url_id, 
            #            (getattr(data, f) for f in fields) ) )()
            
            # TRC
            #if hasattr(data, 'get_api_url') and 'resource_uri' not in ret:
            #    try: ret['resource_uri'] = data.get_api_url()
            #    except: pass
            
            # absolute uri
            if hasattr(data, 'get_absolute_url') and get_absolute_url:
                try: ret['absolute_url'] = data.get_absolute_url()
                except: pass
            
            #for key, val in ret.items():
            #    if key.endswith('_url') or key.endswith('_uri'):
            #        ret[key] = self.add_domain(val)

            return ret
        
        def _qs(data, fields=()):
            """
            Querysets.
            """
            return [ _any(v, fields) for v in data ]
                
        def _list(data):
            """
            Lists.
            """
            return [ _any(v) for v in data ]
            
        def _dict(data):
            """
            Dictionaries.
            """
            return dict([ (k, _any(v)) for k, v in data.iteritems() ])
            
        # Kickstart the seralizin'.
        return _any(data, self.fields)


    def post(self, request, *args, **kwargs):
        # TODO: test creation on a non-existing resource url
        
        # translated related_field into related_field_id
        for related_name in [field.name for field in self.model._meta.fields if isinstance(field, RelatedField)]:
            if kwargs.has_key(related_name):
                kwargs[related_name + '_id'] = kwargs[related_name]
                del kwargs[related_name]

        all_kw_args = dict(self.CONTENT.items() + kwargs.items())
        if args:
            instance = self.model(pk=args[-1], **all_kw_args)
        else:
            instance = self.model(**all_kw_args)
        instance.save()
        headers = {}
        if hasattr(instance, 'get_absolute_url'):
            headers['Location'] = instance.get_absolute_url()
        return Response(status.HTTP_201_CREATED, instance, headers)

    def get(self, request, *args, **kwargs):
        try:
            if args:
                # If we have any none kwargs then assume the last represents the primrary key
                instance = self.model.objects.get(pk=args[-1], **kwargs)
            else:
                # Otherwise assume the kwargs uniquely identify the model
                instance = self.model.objects.get(**kwargs)
        except self.model.DoesNotExist:
            raise ErrorResponse(status.HTTP_404_NOT_FOUND)

        return instance

    def put(self, request, *args, **kwargs):
        # TODO: update on the url of a non-existing resource url doesn't work correctly at the moment - will end up with a new url 
        try:
            if args:
                # If we have any none kwargs then assume the last represents the primrary key
                instance = self.model.objects.get(pk=args[-1], **kwargs)
            else:
                # Otherwise assume the kwargs uniquely identify the model
                instance = self.model.objects.get(**kwargs)

            for (key, val) in self.CONTENT.items():
                setattr(instance, key, val)
        except self.model.DoesNotExist:
            instance = self.model(**self.CONTENT)
            instance.save()

        instance.save()
        return instance

    def delete(self, request, *args, **kwargs):
        try:
            if args:
                # If we have any none kwargs then assume the last represents the primrary key
                instance = self.model.objects.get(pk=args[-1], **kwargs)
            else:
                # Otherwise assume the kwargs uniquely identify the model
                instance = self.model.objects.get(**kwargs)
        except self.model.DoesNotExist:
            raise ErrorResponse(status.HTTP_404_NOT_FOUND, None, {})

        instance.delete()
        return
        

class RootModelResource(ModelResource):
    """A Resource which provides default operations for list and create."""
    allowed_methods = ('GET', 'POST')
    queryset = None

    def get(self, request, *args, **kwargs):
        queryset = self.queryset if self.queryset else self.model.objects.all()
        return queryset.filter(**kwargs)


class QueryModelResource(ModelResource):
    """Resource with default operations for list.
    TODO: provide filter/order/num_results/paging, and a create operation to create queries."""
    allowed_methods = ('GET',)
    queryset = None

    def get_form(self, data=None):
        return None

    def get(self, request, *args, **kwargs):
        queryset = self.queryset if self.queryset else self.model.objects.all()
        return queryset.filer(**kwargs)

testItShouldThrowIfLoopInReferences = function() {
- var datastore = new nglr.DataStore();
+ var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
assertThrows("Infinite loop in join: invoice -> customer", function(){
@@ -592,7 +592,7 @@ DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() {
};
DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function() {
- var datastore = new nglr.DataStore();
+ var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
assertThrows("Named entity 'x' is undefined.", function(){
@@ -604,7 +604,7 @@ DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function
};
DataStoreTest.prototype.testItShouldThrowIfQueryOnNonPrimary = function() {
- var datastore = new nglr.DataStore();
+ var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
var InvoiceWithCustomer = datastore.join({
diff --git a/test/EntityDeclarationTest.js b/test/EntityDeclarationTest.js
index 5cab90f4..d64dd775 100644
--- a/test/EntityDeclarationTest.js
+++ b/test/EntityDeclarationTest.js
@@ -2,7 +2,7 @@ EntityDeclarationTest = TestCase('EntityDeclarationTest');
EntityDeclarationTest.prototype.testEntityTypeOnly = function(){
expectAsserts(2);
- var scope = new nglr.Scope({$datastore:{entity:function(name){
+ var scope = new Scope({$datastore:{entity:function(name){
assertEquals("Person", name);
}}});
var init = scope.entity("Person");
@@ -11,7 +11,7 @@ EntityDeclarationTest.prototype.testEntityTypeOnly = function(){
EntityDeclarationTest.prototype.testWithDefaults = function(){
expectAsserts(4);
- var scope = new nglr.Scope({$datastore:{entity:function(name, init){
+ var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals("Person", name);
assertEquals("=a:", init.a);
assertEquals(0, init.b.length);
@@ -22,7 +22,7 @@ EntityDeclarationTest.prototype.testWithDefaults = function(){
EntityDeclarationTest.prototype.testWithName = function(){
expectAsserts(2);
- var scope = new nglr.Scope({$datastore:{entity:function(name, init){
+ var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals("Person", name);
return function (){ return {}; };
}}});
@@ -34,7 +34,7 @@ EntityDeclarationTest.prototype.testMultipleEntities = function(){
expectAsserts(3);
var expect = ['Person', 'Book'];
var i=0;
- var scope = new nglr.Scope({$datastore:{entity:function(name, init){
+ var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals(expect[i], name);
i++;
return function (){ return {}; };
diff --git a/test/FileControllerTest.js b/test/FileControllerTest.js
index ca5925e4..09eb6fc5 100644
--- a/test/FileControllerTest.js
+++ b/test/FileControllerTest.js
@@ -3,7 +3,7 @@ FileControllerTest = TestCase('FileControllerTest');
FileControllerTest.prototype.testOnSelectUpdateView = function(){
var view = jQuery('<span><a/><span/></span>');
var swf = {};
- var controller = new nglr.FileController(view, null, swf);
+ var controller = new FileController(view, null, swf);
swf.uploadFile = function(path){};
controller._on_select('A', 9, '9 bytes');
assertEquals(view.find('a').text(), "A");
@@ -11,14 +11,14 @@ FileControllerTest.prototype.testOnSelectUpdateView = function(){
};
FileControllerTest.prototype.testUpdateModelView = function(){
- var view = nglr.FileController.template('');
+ var view = FileController.template('');
var input = $('<input name="value.input">');
var controller;
- var scope = new nglr.Scope({value:{}, $binder:{updateView:function(){
+ var scope = new Scope({value:{}, $binder:{updateView:function(){
controller.updateView(scope);
}}});
view.data('scope', scope);
- controller = new nglr.FileController(view, 'value.input', null, "http://server_base");
+ controller = new FileController(view, 'value.input', null, "http://server_base");
var value = '{"text":"A", "size":123, "id":"890"}';
controller._on_uploadCompleteData(value);
controller.updateView(scope);
@@ -34,7 +34,7 @@ FileControllerTest.prototype.testUpdateModelView = function(){
FileControllerTest.prototype.testFileUpload = function(){
expectAsserts(1);
var swf = {};
- var controller = new nglr.FileController(null, null, swf, "http://server_base");
+ var controller = new FileController(null, null, swf, "http://server_base");
swf.uploadFile = function(path){
assertEquals("http://server_base/_attachments", path);
};
@@ -47,16 +47,16 @@ FileControllerTest.prototype.testFileUploadNoFileIsNoop = function(){
var swf = {uploadFile:function(path){
fail();
}};
- var controller = new nglr.FileController(null, swf);
+ var controller = new FileController(null, swf);
controller.upload("basePath", null);
};
FileControllerTest.prototype.testRemoveAttachment = function(){
- var doc = nglr.FileController.template();
+ var doc = FileController.template();
var input = $('<input name="file">');
- var scope = new nglr.Scope();
+ var scope = new Scope();
input.data('scope', scope);
- var controller = new nglr.FileController(doc, 'file', null, null);
+ var controller = new FileController(doc, 'file', null, null);
controller.updateView(scope);
assertEquals(false, doc.find('input').attr('checked'));
@@ -75,10 +75,10 @@ FileControllerTest.prototype.testRemoveAttachment = function(){
};
FileControllerTest.prototype.testShouldEmptyOutOnUndefined = function () {
- var view = nglr.FileController.template('hello');
- var controller = new nglr.FileController(view, 'abc', null, null);
+ var view = FileController.template('hello');
+ var controller = new FileController(view, 'abc', null, null);
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('abc', {text: 'myname', url: 'myurl', size: 1234});
controller.updateView(scope);
diff --git a/test/FiltersTest.js b/test/FiltersTest.js
index 8943fdd4..c219f24f 100644
--- a/test/FiltersTest.js
+++ b/test/FiltersTest.js
@@ -3,7 +3,7 @@ FiltersTest = TestCase('FiltersTest');
FiltersTest.prototype.testCurrency = function(){
var html = $('<span/>');
var context = {element:html[0]};
- var currency = nglr.bind(context, angular.filter.currency);
+ var currency = bind(context, angular.filter.currency);
assertEquals(currency(0), '$0.00');
assertEquals(html.hasClass('ng-format-negative'), false);
@@ -15,8 +15,8 @@ FiltersTest.prototype.testCurrency = function(){
FiltersTest.prototype.testFilterThisIsContext = function(){
expectAsserts(2);
- var scope = new nglr.Scope();
- nglr.Scope.expressionCache = {};
+ var scope = new Scope();
+ Scope.expressionCache = {};
var context = {element:123};
angular.filter.testFn = function () {
assertEquals('Context not equal', this, context);
@@ -28,7 +28,7 @@ FiltersTest.prototype.testFilterThisIsContext = function(){
FiltersTest.prototype.testNumberFormat = function(){
var context = {jqElement:$('<span/>')};
- var number = nglr.bind(context, angular.filter.number);
+ var number = bind(context, angular.filter.number);
assertEquals('0', number(0, 0));
assertEquals('0.00', number(0));
@@ -40,7 +40,7 @@ FiltersTest.prototype.testNumberFormat = function(){
};
FiltersTest.prototype.testJson = function () {
- assertEquals(nglr.toJson({a:"b"}, true), angular.filter.json({a:"b"}));
+ assertEquals(toJson({a:"b"}, true), angular.filter.json({a:"b"}));
};
FiltersTest.prototype.testPackageTracking = function () {
@@ -48,9 +48,9 @@ FiltersTest.prototype.testPackageTracking = function () {
var val = angular.filter.trackPackage(trackingNo, title);
assertNotNull("Did Not Match: " + trackingNo, val);
assertEquals(angular.filter.Meta.TAG, val.TAG);
- assertEquals(title + ": " + nglr.trim(trackingNo), val.text);
+ assertEquals(title + ": " + trim(trackingNo), val.text);
assertNotNull(val.url);
- assertEquals(nglr.trim(trackingNo), val.trackingNo);
+ assertEquals(trim(trackingNo), val.trackingNo);
assertEquals('<a href="' + val.url + '">' + val.text + '</a>', val.html);
};
assert('UPS', ' 1Z 999 999 99 9999 999 9 ');
@@ -83,7 +83,7 @@ FiltersTest.prototype.testLink = function() {
};
FiltersTest.prototype.testBytes = function(){
- var controller = new nglr.FileController();
+ var controller = new FileController();
assertEquals(angular.filter.bytes(123), '123 bytes');
assertEquals(angular.filter.bytes(1234), '1.2 KB');
assertEquals(angular.filter.bytes(1234567), '1.1 MB');
diff --git a/test/JsonTest.js b/test/JsonTest.js
index 5c3644f5..cf49bec3 100644
--- a/test/JsonTest.js
+++ b/test/JsonTest.js
@@ -1,69 +1,69 @@
JsonTest = TestCase("JsonTest");
JsonTest.prototype.testPrimitives = function () {
- assertEquals("null", nglr.toJson(0/0));
- assertEquals("null", nglr.toJson(null));
- assertEquals("true", nglr.toJson(true));
- assertEquals("false", nglr.toJson(false));
- assertEquals("123.45", nglr.toJson(123.45));
- assertEquals('"abc"', nglr.toJson("abc"));
- assertEquals('"a \\t \\n \\r b \\\\"', nglr.toJson("a \t \n \r b \\"));
+ assertEquals("null", toJson(0/0));
+ assertEquals("null", toJson(null));
+ assertEquals("true", toJson(true));
+ assertEquals("false", toJson(false));
+ assertEquals("123.45", toJson(123.45));
+ assertEquals('"abc"', toJson("abc"));
+ assertEquals('"a \\t \\n \\r b \\\\"', toJson("a \t \n \r b \\"));
};
JsonTest.prototype.testEscaping = function () {
- assertEquals("\"7\\\\\\\"7\"", nglr.toJson("7\\\"7"));
+ assertEquals("\"7\\\\\\\"7\"", toJson("7\\\"7"));
};
JsonTest.prototype.testObjects = function () {
- assertEquals('{"a":1,"b":2}', nglr.toJson({a:1,b:2}));
- assertEquals('{"a":{"b":2}}', nglr.toJson({a:{b:2}}));
- assertEquals('{"a":{"b":{"c":0}}}', nglr.toJson({a:{b:{c:0}}}));
- assertEquals('{"a":{"b":null}}', nglr.toJson({a:{b:0/0}}));
+ assertEquals('{"a":1,"b":2}', toJson({a:1,b:2}));
+ assertEquals('{"a":{"b":2}}', toJson({a:{b:2}}));
+ assertEquals('{"a":{"b":{"c":0}}}', toJson({a:{b:{c:0}}}));
+ assertEquals('{"a":{"b":null}}', toJson({a:{b:0/0}}));
};
JsonTest.prototype.testObjectPretty = function () {
- assertEquals('{\n "a":1,\n "b":2}', nglr.toJson({a:1,b:2}, true));
- assertEquals('{\n "a":{\n "b":2}}', nglr.toJson({a:{b:2}}, true));
+ assertEquals('{\n "a":1,\n "b":2}', toJson({a:1,b:2}, true));
+ assertEquals('{\n "a":{\n "b":2}}', toJson({a:{b:2}}, true));
};
JsonTest.prototype.testArray = function () {
- assertEquals('[]', nglr.toJson([]));
- assertEquals('[1,"b"]', nglr.toJson([1,"b"]));
+ assertEquals('[]', toJson([]));
+ assertEquals('[1,"b"]', toJson([1,"b"]));
};
JsonTest.prototype.testIgnoreFunctions = function () {
- assertEquals('[null,1]', nglr.toJson([function(){},1]));
- assertEquals('{}', nglr.toJson({a:function(){}}));
+ assertEquals('[null,1]', toJson([function(){},1]));
+ assertEquals('{}', toJson({a:function(){}}));
};
JsonTest.prototype.testParseNull = function () {
- assertNull(nglr.fromJson("null"));
+ assertNull(fromJson("null"));
};
JsonTest.prototype.testParseBoolean = function () {
- assertTrue(nglr.fromJson("true"));
- assertFalse(nglr.fromJson("false"));
+ assertTrue(fromJson("true"));
+ assertFalse(fromJson("false"));
};
JsonTest.prototype.test$$isIgnored = function () {
- assertEquals("{}", nglr.toJson({$$:0}));
+ assertEquals("{}", toJson({$$:0}));
};
JsonTest.prototype.testArrayWithEmptyItems = function () {
var a = [];
a[1] = "X";
- assertEquals('[null,"X"]', nglr.toJson(a));
+ assertEquals('[null,"X"]', toJson(a));
};
JsonTest.prototype.testItShouldEscapeUnicode = function () {
assertEquals(1, "\u00a0".length);
- assertEquals(8, nglr.toJson("\u00a0").length);
- assertEquals(1, nglr.fromJson(nglr.toJson("\u00a0")).length);
+ assertEquals(8, toJson("\u00a0").length);
+ assertEquals(1, fromJson(toJson("\u00a0")).length);
};
JsonTest.prototype.testItShouldUTCDates = function() {
var date = angular.String.toDate("2009-10-09T01:02:03Z");
- assertEquals('"2009-10-09T01:02:03Z"', nglr.toJson(date));
+ assertEquals('"2009-10-09T01:02:03Z"', toJson(date));
assertEquals(date.getTime(),
- nglr.fromJson('"2009-10-09T01:02:03Z"').getTime());
+ fromJson('"2009-10-09T01:02:03Z"').getTime());
};
diff --git a/test/LoaderTest.js b/test/LoaderTest.js
index 91a804a5..88ae3efa 100644
--- a/test/LoaderTest.js
+++ b/test/LoaderTest.js
@@ -3,7 +3,7 @@ LoaderTest = TestCase('LoaderTest');
LoaderTest.prototype.testLoadCss = function(){
if ($.browser.safari) return;
var head = jQuery('<head/>')[0];
- var loader = new nglr.Loader(document, head, {});
+ var loader = new Loader(document, head, {});
var log = '';
loader.config.server = 'http://';
loader.loadCss('x');
@@ -11,15 +11,15 @@ LoaderTest.prototype.testLoadCss = function(){
};
LoaderTest.prototype.testDefaultDatabasePathFromSubdomain = function() {
- var loader = new nglr.Loader(null, null, {server:"http://account.getangular.com", database:"database"});
+ var loader = new Loader(null, null, {server:"http://account.getangular.com", database:"database"});
loader.computeConfiguration();
assertEquals("database", loader.config.database);
- loader = new nglr.Loader(null, null, {server:"http://account.getangular.com"});
+ loader = new Loader(null, null, {server:"http://account.getangular.com"});
loader.computeConfiguration();
assertEquals("account", loader.config.database);
- loader = new nglr.Loader(null, null, {server:"https://account.getangular.com"});
+ loader = new Loader(null, null, {server:"https://account.getangular.com"});
loader.computeConfiguration();
assertEquals("account", loader.config.database);
};
@@ -31,7 +31,7 @@ UrlWatcherTest = TestCase('UrlWatcherTest');
UrlWatcherTest.prototype.testUrlWatcher = function () {
expectAsserts(2);
var location = {href:"http://server", hash:""};
- var watcher = new nglr.UrlWatcher(location);
+ var watcher = new UrlWatcher(location);
watcher.delay = 1;
watcher.listener = function(url){
assertEquals('http://getangular.test', url);
@@ -49,9 +49,9 @@ UrlWatcherTest.prototype.testUrlWatcher = function () {
UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = function(){
expectAsserts(2);
var location = {href:"http://server", hash:"#$iframe_notify=1234"};
- var watcher = new nglr.UrlWatcher(location);
- nglr._iframe_notify_1234 = function () {
- assertEquals("undefined", typeof nglr._iframe_notify_1234);
+ var watcher = new UrlWatcher(location);
+ callbacks._iframe_notify_1234 = function () {
+ assertEquals("undefined", typeof callbacks._iframe_notify_1234);
assertEquals("http://server2#", location.href);
};
watcher.delay = 1;
@@ -66,5 +66,5 @@ UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = functi
FunctionTest = TestCase("FunctionTest");
FunctionTest.prototype.testEscapeHtml = function () {
- assertEquals("&lt;div&gt;&amp;amp;&lt;/div&gt;", nglr.escapeHtml('<div>&amp;</div>'));
+ assertEquals("&lt;div&gt;&amp;amp;&lt;/div&gt;", escapeHtml('<div>&amp;</div>'));
}; \ No newline at end of file
diff --git a/test/ModelTest.js b/test/ModelTest.js
index 5d9119a1..dbd97778 100644
--- a/test/ModelTest.js
+++ b/test/ModelTest.js
@@ -1,7 +1,7 @@
ModelTest = TestCase('ModelTest');
ModelTest.prototype.testLoadSaveOperations = function(){
- var m1 = new nglr.DataStore().entity('A')();
+ var m1 = new DataStore().entity('A')();
m1.a = 1;
var m2 = {b:1};
@@ -13,7 +13,7 @@ ModelTest.prototype.testLoadSaveOperations = function(){
};
ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){
- var m1 = new nglr.DataStore().entity('A')();
+ var m1 = new DataStore().entity('A')();
m1.id = function(){return 'OK';};
m1.$loadFrom({id:null});
assertEquals(m1.id(), 'OK');
@@ -24,7 +24,7 @@ ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){
};
ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){
- var ds = new nglr.DataStore();
+ var ds = new DataStore();
var m = ds.entity('A')();
assertTrue(m.$$entity.datastore === ds);
m.$loadFrom({});
@@ -33,7 +33,7 @@ ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){
ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){
expectAsserts(7);
- var datastore = new nglr.DataStore();
+ var datastore = new DataStore();
var model = datastore.entity("A", {a:1})();
var fn = {};
datastore.save = function(instance, callback) {
@@ -56,7 +56,7 @@ ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){
ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){
expectAsserts(6);
- var datastore = new nglr.DataStore();
+ var datastore = new DataStore();
var model = datastore.entity("A", {a:1})();
datastore.save = function(instance, callback) {
@@ -77,7 +77,7 @@ ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){
ModelTest.prototype.testItShouldMakeDeepCopyOfInitialValues = function (){
var initial = {a:[]};
- var entity = new nglr.DataStore().entity("A", initial);
+ var entity = new DataStore().entity("A", initial);
var model = entity();
model.a.push(1);
assertEquals(0, entity().a.length);
diff --git a/test/ParserTest.js b/test/ParserTest.js
index 7fe8e6a4..058010f3 100644
--- a/test/ParserTest.js
+++ b/test/ParserTest.js
@@ -1,7 +1,7 @@
LexerTest = TestCase('LexerTest');
LexerTest.prototype.testTokenizeAString = function(){
- var lexer = new nglr.Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
+ var lexer = new Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@@ -54,7 +54,7 @@ LexerTest.prototype.testTokenizeAString = function(){
LexerTest.prototype.testTokenizeRegExp = function(){
- var lexer = new nglr.Lexer("/r 1/");
+ var lexer = new Lexer("/r 1/");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@@ -64,7 +64,7 @@ LexerTest.prototype.testTokenizeRegExp = function(){
LexerTest.prototype.testQuotedString = function(){
var str = "['\\'', \"\\\"\"]";
- var lexer = new nglr.Lexer(str);
+ var lexer = new Lexer(str);
var tokens = lexer.parse();
assertEquals(1, tokens[1].index);
@@ -77,21 +77,21 @@ LexerTest.prototype.testQuotedString = function(){
LexerTest.prototype.testQuotedStringEscape = function(){
var str = '"\\"\\n\\f\\r\\t\\v\\u00A0"';
- var lexer = new nglr.Lexer(str);
+ var lexer = new Lexer(str);
var tokens = lexer.parse();
assertEquals('"\n\f\r\t\v\u00A0', tokens[0].text);
};
LexerTest.prototype.testTokenizeUnicode = function(){
- var lexer = new nglr.Lexer('"\\u00A0"');
+ var lexer = new Lexer('"\\u00A0"');
var tokens = lexer.parse();
assertEquals(1, tokens.length);
assertEquals('\u00a0', tokens[0].text);
};
LexerTest.prototype.testTokenizeRegExpWithOptions = function(){
- var lexer = new nglr.Lexer("/r/g");
+ var lexer = new Lexer("/r/g");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@@ -101,7 +101,7 @@ LexerTest.prototype.testTokenizeRegExpWithOptions = function(){
};
LexerTest.prototype.testTokenizeRegExpWithEscape = function(){
- var lexer = new nglr.Lexer("/\\/\\d/");
+ var lexer = new Lexer("/\\/\\d/");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@@ -110,14 +110,14 @@ LexerTest.prototype.testTokenizeRegExpWithEscape = function(){
};
LexerTest.prototype.testIgnoreWhitespace = function(){
- var lexer = new nglr.Lexer("a \t \n \r b");
+ var lexer = new Lexer("a \t \n \r b");
var tokens = lexer.parse();
assertEquals(tokens[0].text, 'a');
assertEquals(tokens[1].text, 'b');
};
LexerTest.prototype.testRelation = function(){
- var lexer = new nglr.Lexer("! == != < > <= >=");
+ var lexer = new Lexer("! == != < > <= >=");
var tokens = lexer.parse();
assertEquals(tokens[0].text, '!');
assertEquals(tokens[1].text, '==');
@@ -129,7 +129,7 @@ LexerTest.prototype.testRelation = function(){
};
LexerTest.prototype.testStatements = function(){
- var lexer = new nglr.Lexer("a;b;");
+ var lexer = new Lexer("a;b;");
var tokens = lexer.parse();
assertEquals(tokens[0].text, 'a');
assertEquals(tokens[1].text, ';');
@@ -140,7 +140,7 @@ LexerTest.prototype.testStatements = function(){
ParserTest = TestCase('ParserTest');
ParserTest.prototype.testExpressions = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("-1"), -1);
assertEquals(scope.eval("1 + 2.5"), 3.5);
assertEquals(scope.eval("1 + -2.5"), -1.5);
@@ -151,7 +151,7 @@ ParserTest.prototype.testExpressions = function(){
};
ParserTest.prototype.testComparison = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("false"), false);
assertEquals(scope.eval("!true"), false);
assertEquals(scope.eval("1==1"), true);
@@ -163,14 +163,14 @@ ParserTest.prototype.testComparison = function(){
};
ParserTest.prototype.testLogical = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("0&&2"), 0&&2);
assertEquals(scope.eval("0||2"), 0||2);
assertEquals(scope.eval("0||1&&2"), 0||1&&2);
};
ParserTest.prototype.testString = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("'a' + 'b c'"), "ab c");
};
@@ -182,7 +182,7 @@ ParserTest.prototype.testFilters = function(){
angular.filter.upper = {_case:function(input) {
return input.toUpperCase();
}};
- var scope = new nglr.Scope();
+ var scope = new Scope();
try {
scope.eval("1|nonExistant");
fail();
@@ -196,7 +196,7 @@ ParserTest.prototype.testFilters = function(){
};
ParserTest.prototype.testScopeAccess = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('a', 123);
scope.set('b.c', 456);
assertEquals(scope.eval("a", scope), 123);
@@ -205,16 +205,16 @@ ParserTest.prototype.testScopeAccess = function(){
};
ParserTest.prototype.testGrouping = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("(1+2)*3"), (1+2)*3);
};
ParserTest.prototype.testAssignments = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("a=12"), 12);
assertEquals(scope.get("a"), 12);
- scope = new nglr.Scope();
+ scope = new Scope();
assertEquals(scope.eval("x.y.z=123;"), 123);
assertEquals(scope.get("x.y.z"), 123);
@@ -224,13 +224,13 @@ ParserTest.prototype.testAssignments = function(){
};
ParserTest.prototype.testFunctionCallsNoArgs = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('const', function(a,b){return 123;});
assertEquals(scope.eval("const()"), 123);
};
ParserTest.prototype.testFunctionCalls = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('add', function(a,b){
return a+b;
});
@@ -238,7 +238,7 @@ ParserTest.prototype.testFunctionCalls = function(){
};
ParserTest.prototype.testCalculationBug = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('taxRate', 8);
scope.set('subTotal', 100);
assertEquals(scope.eval("taxRate / 100 * subTotal"), 8);
@@ -246,7 +246,7 @@ ParserTest.prototype.testCalculationBug = function(){
};
ParserTest.prototype.testArray = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("[]").length, 0);
assertEquals(scope.eval("[1, 2]").length, 2);
assertEquals(scope.eval("[1, 2]")[0], 1);
@@ -254,7 +254,7 @@ ParserTest.prototype.testArray = function(){
};
ParserTest.prototype.testArrayAccess = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("[1][0]"), 1);
assertEquals(scope.eval("[[1]][0][0]"), 1);
assertEquals(scope.eval("[].length"), 0);
@@ -262,33 +262,33 @@ ParserTest.prototype.testArrayAccess = function(){
};
ParserTest.prototype.testObject = function(){
- var scope = new nglr.Scope();
- assertEquals(nglr.toJson(scope.eval("{}")), "{}");
- assertEquals(nglr.toJson(scope.eval("{a:'b'}")), '{"a":"b"}');
- assertEquals(nglr.toJson(scope.eval("{'a':'b'}")), '{"a":"b"}');
- assertEquals(nglr.toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}');
+ var scope = new Scope();
+ assertEquals(toJson(scope.eval("{}")), "{}");
+ assertEquals(toJson(scope.eval("{a:'b'}")), '{"a":"b"}');
+ assertEquals(toJson(scope.eval("{'a':'b'}")), '{"a":"b"}');
+ assertEquals(toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}');
};
ParserTest.prototype.testObjectAccess = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals("WC", scope.eval("{false:'WC', true:'CC'}[false]"));
};
ParserTest.prototype.testJSON = function(){
- var scope = new nglr.Scope();
- assertEquals(nglr.toJson(scope.eval("[{}]")), "[{}]");
- assertEquals(nglr.toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]');
+ var scope = new Scope();
+ assertEquals(toJson(scope.eval("[{}]")), "[{}]");
+ assertEquals(toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]');
};
ParserTest.prototype.testMultippleStatements = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(scope.eval("a=1;b=3;a+b"), 4);
assertEquals(scope.eval(";;1;;"), 1);
};
ParserTest.prototype.testParseThrow = function(){
expectAsserts(1);
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('e', 'abc');
try {
scope.eval("throw e");
@@ -298,7 +298,7 @@ ParserTest.prototype.testParseThrow = function(){
};
ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var C = function (){
this.a=123;
};
@@ -310,7 +310,7 @@ ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){
assertEquals(123, scope.eval("obj.getA()"));
};
ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var C = function (){
this.a=123;
};
@@ -326,13 +326,13 @@ ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){
};
ParserTest.prototype.testObjectPointsToScopeValue = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('a', "abc");
assertEquals("abc", scope.eval("{a:a}").a);
};
ParserTest.prototype.testFieldAccess = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var fn = function(){
return {name:'misko'};
};
@@ -341,14 +341,14 @@ ParserTest.prototype.testFieldAccess = function(){
};
ParserTest.prototype.testArrayIndexBug = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('items', [{}, {name:'misko'}]);
assertEquals("misko", scope.eval('items[1].name'));
};
ParserTest.prototype.testArrayAssignment = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('items', []);
assertEquals("abc", scope.eval('items[1] = "abc"'));
@@ -359,30 +359,30 @@ ParserTest.prototype.testArrayAssignment = function () {
};
ParserTest.prototype.testFiltersCanBeGrouped = function () {
- var scope = new nglr.Scope({name:'MISKO'});
+ var scope = new Scope({name:'MISKO'});
assertEquals('misko', scope.eval('n = (name|lowercase)'));
assertEquals('misko', scope.eval('n'));
};
ParserTest.prototype.testFiltersCanBeGrouped = function () {
- var scope = new nglr.Scope({name:'MISKO'});
+ var scope = new Scope({name:'MISKO'});
assertEquals('misko', scope.eval('n = (name|lowercase)'));
assertEquals('misko', scope.eval('n'));
};
ParserTest.prototype.testRemainder = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(1, scope.eval('1%2'));
};
ParserTest.prototype.testSumOfUndefinedIsNotUndefined = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(1, scope.eval('1+undefined'));
assertEquals(1, scope.eval('undefined+1'));
};
ParserTest.prototype.testMissingThrowsError = function() {
- var scope = new nglr.Scope();
+ var scope = new Scope();
try {
scope.eval('[].count(');
fail();
@@ -392,7 +392,7 @@ ParserTest.prototype.testMissingThrowsError = function() {
};
ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () {
- var scope = new nglr.Scope({count:0});
+ var scope = new Scope({count:0});
scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
scope.watchListeners["$anchor.a"].listeners[0]();
@@ -403,7 +403,7 @@ ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () {
assertEquals(321, scope.get("count"));
};
ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () {
- var scope = new nglr.Scope({count:0});
+ var scope = new Scope({count:0});
var listeners = {a:[], b:[]};
scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
function(n, fn){listeners[n].push(fn);});
@@ -417,12 +417,12 @@ ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () {
};
ParserTest.prototype.testItShouldParseEmptyOnChangeAsNoop = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.watch("", function(){fail();});
};
ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
var fn = scope.eval("{:value}");
scope.set("value", 1);
assertEquals(1, fn());
@@ -433,7 +433,7 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function
};
ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function () {
- var scope = new nglr.Scope();
+ var scope = new Scope();
var fn = scope.eval("{(a):value+a}");
scope.set("value", 1);
assertEquals(11, fn(10));
@@ -444,14 +444,14 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function (
};
ParserTest.prototype.testItShouldHaveDefaultArugument = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var fn = scope.eval("{:$*2}");
assertEquals(4, fn(2));
};
ParserTest.prototype.testReturnFunctionsAreNotBound = function(){
- var scope = new nglr.Scope();
- scope.set("$datastore", new nglr.DataStore());
+ var scope = new Scope();
+ scope.set("$datastore", new DataStore());
scope.entity("Group");
var Group = scope.get("Group");
assertEquals("eval Group", "function", typeof scope.eval("Group"));
diff --git a/test/ScopeTest.js b/test/ScopeTest.js
index c66a2329..e1c5c8ce 100644
--- a/test/ScopeTest.js
+++ b/test/ScopeTest.js
@@ -23,13 +23,13 @@ ScopeTest.prototype.testNoScopeDoesNotCauseInfiniteRecursion = function(){
};
ScopeTest.prototype.testScopeEval = function(){
- var scope = new nglr.Scope({b:345});
+ var scope = new Scope({b:345});
assertEquals(scope.eval('b = 123'), 123);
assertEquals(scope.get('b'), 123);
};
ScopeTest.prototype.testScopeFromPrototype = function(){
- var scope = new nglr.Scope({b:123});
+ var scope = new Scope({b:123});
scope.eval('a = b');
scope.eval('b = 456');
assertEquals(scope.get('a'), 123);
@@ -37,32 +37,32 @@ ScopeTest.prototype.testScopeFromPrototype = function(){
};
ScopeTest.prototype.testSetScopeGet = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('a', 987);
assertEquals(scope.get('a'), 987);
assertEquals(scope.eval('a'), 987);
};
ScopeTest.prototype.testGetChain = function(){
- var scope = new nglr.Scope({a:{b:987}});
+ var scope = new Scope({a:{b:987}});
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
};
ScopeTest.prototype.testGetUndefinedChain = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
assertEquals(typeof scope.get('a.b'), 'undefined');
};
ScopeTest.prototype.testSetChain = function(){
- var scope = new nglr.Scope({a:{}});
+ var scope = new Scope({a:{}});
scope.set('a.b', 987);
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
};
ScopeTest.prototype.testSetGetOnChain = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('a.b', 987);
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
@@ -70,7 +70,7 @@ ScopeTest.prototype.testSetGetOnChain = function(){
ScopeTest.prototype.testGlobalFunctionAccess =function(){
window['scopeAddTest'] = function (a, b) {return a+b;};
- var scope = new nglr.Scope({window:window});
+ var scope = new Scope({window:window});
assertEquals(scope.eval('window.scopeAddTest(1,2)'), 3);
scope.set('add', function (a, b) {return a+b;});
@@ -82,7 +82,7 @@ ScopeTest.prototype.testGlobalFunctionAccess =function(){
ScopeTest.prototype.testValidationEval = function(){
expectAsserts(4);
- var scope = new nglr.Scope();
+ var scope = new Scope();
angular.validator.testValidator = function(value, expect){
assertEquals(scope, this.scope);
return value == expect ? null : "Error text";
@@ -96,7 +96,7 @@ ScopeTest.prototype.testValidationEval = function(){
ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException = function() {
expectAsserts(1);
- var scope = new nglr.Scope({obj:{}});
+ var scope = new Scope({obj:{}});
try {
scope.eval("obj.iDontExist()");
fail();
@@ -106,7 +106,7 @@ ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException =
};
ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() {
- var scope = new nglr.Scope();
+ var scope = new Scope();
try {
scope.get('a.{{b}}');
fail();
@@ -116,25 +116,25 @@ ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() {
};
ScopeTest.prototype.testItShouldHave$parent = function() {
- var parent = new nglr.Scope({}, "ROOT");
- var child = new nglr.Scope(parent.state);
+ var parent = new Scope({}, "ROOT");
+ var child = new Scope(parent.state);
assertSame("parent", child.state.$parent, parent.state);
assertSame("root", child.state.$root, parent.state);
};
ScopeTest.prototype.testItShouldHave$root = function() {
- var scope = new nglr.Scope({}, "ROOT");
+ var scope = new Scope({}, "ROOT");
assertSame(scope.state.$root, scope.state);
};
ScopeTest.prototype.testItShouldBuildPathOnUndefined = function(){
- var scope = new nglr.Scope({}, "ROOT");
+ var scope = new Scope({}, "ROOT");
scope.setEval("a.$b.c", 1);
assertJsonEquals({$b:{c:1}}, scope.get("a"));
};
ScopeTest.prototype.testItShouldMapUnderscoreFunctions = function(){
- var scope = new nglr.Scope({}, "ROOT");
+ var scope = new Scope({}, "ROOT");
scope.set("a", [1,2,3]);
assertEquals('function', typeof scope.get("a.$size"));
scope.eval("a.$includeIf(4,true)");
diff --git a/test/ServerTest.js b/test/ServerTest.js
index d1f662f9..e367c90a 100644
--- a/test/ServerTest.js
+++ b/test/ServerTest.js
@@ -1,7 +1,7 @@
ServerTest = TestCase("ServerTest");
ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
var log = "";
- var server = new nglr.Server("http://server", function(url){
+ var server = new Server("http://server", function(url){
log += "|" + url;
});
server.maxSize = 30;
@@ -10,7 +10,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
assertEquals(200, code);
assertEquals("response", r);
});
- nglr.uuid0("response");
+ callbacks.uuid0("response");
assertEquals(
"|http://server/$/uuid0/2/1?h=eyJtIjoiUE9TVCIsInAiOnt9LCJ1Ij" +
"|http://server/$/uuid0/2/2?h=oiL2RhdGEvZGF0YWJhc2UifQ==",
@@ -18,7 +18,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
};
ServerTest.prototype.testItShouldEncodeUsingUrlRules = function() {
- var server = new nglr.Server("http://server");
+ var server = new Server("http://server");
assertEquals("fn5-fn5-", server.base64url("~~~~~~"));
assertEquals("fn5_fn5_", server.base64url("~~\u007f~~\u007f"));
};
@@ -28,13 +28,13 @@ FrameServerTest = TestCase("FrameServerTest");
FrameServerTest.prototype = {
testRead:function(){
var window = {name:'$DATASET:"MyData"'};
- var server = new nglr.FrameServer(window);
+ var server = new FrameServer(window);
server.read();
assertEquals("MyData", server.data);
},
testWrite:function(){
var window = {};
- var server = new nglr.FrameServer(window);
+ var server = new FrameServer(window);
server.data = "TestData"
server.write();
assertEquals('$DATASET:"TestData"', window.name);
diff --git a/test/UsersTest.js b/test/UsersTest.js
index c808885c..f0ff545a 100644
--- a/test/UsersTest.js
+++ b/test/UsersTest.js
@@ -10,10 +10,10 @@ UsersTest.prototype = {
testItShouldFetchCurrentUser:function(){
expectAsserts(5);
var user;
- var users = new nglr.Users({request:function(method, url, request, callback){
+ var users = new Users({request:function(method, url, request, callback){
assertEquals("GET", method);
assertEquals("/account.json", url);
- assertEquals("{}", nglr.toJson(request));
+ assertEquals("{}", toJson(request));
callback(200, {$status_code:200, user:{name:'misko'}});
}});
users.fetchCurrentUser(function(u){
diff --git a/test/WidgetsTest.js b/test/WidgetsTest.js
index a245abda..fe20e664 100644
--- a/test/WidgetsTest.js
+++ b/test/WidgetsTest.js
@@ -2,8 +2,8 @@ WidgetTest = TestCase('WidgetTest');
WidgetTest.prototype.testRequired = function () {
var view = $('<input name="a" ng-required>');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
cntl.updateView(scope);
assertTrue(view.hasClass('ng-validation-error'));
assertEquals("Required Value", view.attr('ng-error'));
@@ -15,8 +15,8 @@ WidgetTest.prototype.testRequired = function () {
WidgetTest.prototype.testValidator = function () {
var view = $('<input name="a" ng-validate="testValidator:\'ABC\'">');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@@ -43,8 +43,8 @@ WidgetTest.prototype.testValidator = function () {
WidgetTest.prototype.testRequiredValidator = function () {
var view = $('<input name="a" ng-required ng-validate="testValidator:\'ABC\'">');
- var scope = new nglr.Scope({$invalidWidgets:[]});
- var cntl = new nglr.TextController(view[0], 'a');
+ var scope = new Scope({$invalidWidgets:[]});
+ var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@@ -67,29 +67,29 @@ WidgetTest.prototype.testRequiredValidator = function () {
delete angular.validator['testValidator'];
};
-TextController = TestCase("TextController");
+TextControllerTest = TestCase("TextControllerTest");
-TextController.prototype.testDatePicker = function() {
+TextControllerTest.prototype.testDatePicker = function() {
var input = $('<input type="text" ng-widget="datepicker">');
- input.data('scope', new nglr.Scope());
+ input.data('scope', new Scope());
var body = $(document.body);
body.append(input);
- var binder = new nglr.Binder(input[0], new nglr.WidgetFactory());
+ var binder = new Binder(input[0], new WidgetFactory());
assertTrue('before', input.data('datepicker') === undefined);
binder.compile();
assertTrue('after', input.data('datepicker') !== null);
assertTrue(body.html(), input.hasClass('hasDatepicker'));
};
-RepeaterUpdater = TestCase("RepeaterUpdater");
+RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
-RepeaterUpdater.prototype.testRemoveThenAdd = function() {
+RepeaterUpdaterTest.prototype.testRemoveThenAdd = function() {
var view = $("<div><span/></div>");
var template = function () {
return $("<li/>");
};
- var repeater = new nglr.RepeaterUpdater(view.find("span"), "a in b", template, "");
- var scope = new nglr.Scope();
+ var repeater = new RepeaterUpdater(view.find("span"), "a in b", template, "");
+ var scope = new Scope();
scope.set('b', [1,2]);
repeater.updateView(scope);
@@ -102,14 +102,14 @@ RepeaterUpdater.prototype.testRemoveThenAdd = function() {
assertEquals(1, view.find("li").size());
};
-RepeaterUpdater.prototype.testShouldBindWidgetOnRepeaterClone = function(){
+RepeaterUpdaterTest.prototype.testShouldBindWidgetOnRepeaterClone = function(){
//fail();
};
-RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
+RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){
expectAsserts(1);
try {
- var repeater = new nglr.RepeaterUpdater(null, "a=b");
+ var repeater = new RepeaterUpdater(null, "a=b");
} catch (e) {
assertEquals("Expected ng-repeat in form of 'item in collection' but got 'a=b'.", e);
}
@@ -118,17 +118,17 @@ RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
SelectControllerTest = TestCase("SelectControllerTest");
SelectControllerTest.prototype.testShouldUpdateModelNullOnNothingSelected = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var view = {selectedIndex:-1, options:[]};
- var cntl = new nglr.SelectController(view, 'abc');
+ var cntl = new SelectController(view, 'abc');
cntl.updateModel(scope);
assertNull(scope.get('abc'));
};
SelectControllerTest.prototype.testShouldUpdateModelWhenNothingSelected = function(){
- var scope = new nglr.Scope();
+ var scope = new Scope();
var view = {value:'123'};
- var cntl = new nglr.SelectController(view, 'abc');
+ var cntl = new SelectController(view, 'abc');
cntl.updateView(scope);
assertEquals("123", scope.get('abc'));
};
@@ -137,8 +137,8 @@ BindUpdaterTest = TestCase("BindUpdaterTest");
BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "{{a}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{a}}");
+ var scope = new Scope();
scope.set('a', undefined);
controller.updateView(scope);
@@ -151,20 +151,20 @@ BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
BindUpdaterTest.prototype.testShouldDisplayJsonForNonStrings = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
+ var controller = new BindUpdater(view[0], "{{obj}}");
- controller.updateView(new nglr.Scope({obj:[]}));
+ controller.updateView(new Scope({obj:[]}));
assertEquals("[]", view.text());
- controller.updateView(new nglr.Scope({obj:{text:'abc'}}));
- assertEquals('abc', nglr.fromJson(view.text()).text);
+ controller.updateView(new Scope({obj:{text:'abc'}}));
+ assertEquals('abc', fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
var view = $('<span />');
- var controller = new nglr.BindUpdater(view[0], "<fake>&{{obj}}</fake>");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "<fake>&{{obj}}</fake>");
+ var scope = new Scope();
scope.set("obj", $('<div>myDiv</div>')[0]);
controller.updateView(scope);
@@ -174,8 +174,8 @@ BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{obj}}");
+ var scope = new Scope();
scope.set("obj", new angular.filter.Meta({text:function(){return "abc";}}));
controller.updateView(scope);
@@ -187,13 +187,13 @@ BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
scope.set("obj", {text:"123"});
controller.updateView(scope);
- assertEquals("123", nglr.fromJson(view.text()).text);
+ assertEquals("123", fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{obj}}");
- var scope = new nglr.Scope();
+ var controller = new BindUpdater(view[0], "{{obj}}");
+ var scope = new Scope();
scope.set("obj", new angular.filter.Meta({html:function(){return "a<div>b</div>c";}}));
controller.updateView(scope);
@@ -205,13 +205,13 @@ BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
scope.set("obj", {html:"123"});
controller.updateView(scope);
- assertEquals("123", nglr.fromJson(view.text()).html);
+ assertEquals("123", fromJson(view.text()).html);
};
BindUpdaterTest.prototype.testUdateBoolean = function() {
var view = $('<div />');
- var controller = new nglr.BindUpdater(view[0], "{{true}}, {{false}}");
- controller.updateView(new nglr.Scope());
+ var controller = new BindUpdater(view[0], "{{true}}, {{false}}");
+ controller.updateView(new Scope());
assertEquals('true, false', view.text());
};
@@ -219,9 +219,9 @@ BindAttrUpdaterTest = TestCase("BindAttrUpdaterTest");
BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = function () {
var view = $('<img />');
- var controller = new nglr.BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
+ var controller = new BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
- var scope = new nglr.Scope();
+ var scope = new Scope();
scope.set('imageUrl', undefined);
scope.set('config.server', 'http://server');
@@ -229,16 +229,15 @@ BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = f
assertEquals("http://server/images/blank.gif", view.attr('src'));
};
-RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() {
- var rep = new nglr.RepeaterUpdater(null, "$item in items", null, null);
- var scope = new nglr.Scope();
+ var rep = new RepeaterUpdater(null, "$item in items", null, null);
+ var scope = new Scope();
scope.set('items', undefined);
rep.updateView(scope);
};
RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
- var rep = new nglr.RepeaterUpdater(null, "($k,_v) in items", null, null);
+ var rep = new RepeaterUpdater(null, "($k,_v) in items", null, null);
assertEquals("items", rep.iteratorExp);
assertEquals("_v", rep.valueExp);
assertEquals("$k", rep.keyExp);
@@ -247,14 +246,14 @@ RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
EvalUpdaterTest = TestCase("EvalUpdaterTest");
EvalUpdaterTest.prototype.testEvalThrowsException = function(){
var view = $('<div/>');
- var eval = new nglr.EvalUpdater(view[0], 'undefined()');
+ var eval = new EvalUpdater(view[0], 'undefined()');
- eval.updateView(new nglr.Scope());
+ eval.updateView(new Scope());
assertTrue(!!view.attr('ng-error'));
assertTrue(view.hasClass('ng-exception'));
eval.exp = "1";
- eval.updateView(new nglr.Scope());
+ eval.updateView(new Scope());
assertFalse(!!view.attr('ng-error'));
assertFalse(view.hasClass('ng-exception'));
};
@@ -262,8 +261,8 @@ EvalUpdaterTest.prototype.testEvalThrowsException = function(){
RadioControllerTest = TestCase("RadioController");
RadioControllerTest.prototype.testItShouldTreatTrueStringAsBoolean = function () {
var view = $('<input type="radio" name="select" value="true"/>');
- var radio = new nglr.RadioController(view[0], 'select');
- var scope = new nglr.Scope({select:true});
+ var radio = new RadioController(view[0], 'select');
+ var scope = new Scope({select:true});
radio.updateView(scope);
assertTrue(view[0].checked);
};
diff --git a/test/XSitePostTest.js b/test/XSitePostTest.js
deleted file mode 100644
index 8a3e4d6f..00000000
--- a/test/XSitePostTest.js
+++ /dev/null
@@ -1,47 +0,0 @@
-XSitePost = TestCase("XSitePost");
-
-var e = function(text){ return Base64.encode(text); };
-
-XSitePost.prototype.testMessageReceived = function () {
- expectAsserts(4);
- var xPost = new nglr.XSitePost();
- xPost.baseUrl = "http://getangular.test";
- xPost.post = function(url, request, callback){
- assertEquals('http://getangular.test/url', url);
- assertEquals('abc', request.a);
- assertEquals('xyz', request.x);
- };
- xPost.incomingFragment('#id;0;1;'+e('/url')+':a:'+e('abc')+':x:'+e('xyz'));
- assertEquals('{}', nglr.toJson(xPost.inQueue));
-};
-
-XSitePost.prototype.testMessageReceivedInParts = function () {
- expectAsserts(5);
- var xPost = new nglr.XSitePost();
- xPost.baseUrl = "http://getangular.test";
- xPost.post = function(url, request, callback){
- assertEquals('http://getangular.test/url', url);
- assertEquals('abc', request.a);
- assertEquals('xyz', request.x);
- };
- xPost.incomingFragment('#id;1;2;:x:'+e('xyz'));
- assertNotSame('{}', nglr.toJson(xPost.inQueue));
- xPost.incomingFragment('#id;0;2;'+e('/url')+':a:'+e('abc'));
- assertEquals('{}', nglr.toJson(xPost.inQueue));
-};
-
-XSitePost.prototype.testPostResponsIsEnqueued = function () {
- var xPost = new nglr.XSitePost();
- xPost.maxMsgSize = 11;
- xPost.response("id", "response", "status");
-
- assertEquals('["id:0:2:cmVzcG9uc2U","id:1:2:="]',
- nglr.toJson(xPost.outQueue));
-};
-
-XSitePost.prototype.testPush = function () {
- var window = {};
- var xPost = new nglr.XSitePost(window);
- xPost.response("id", "response", "status");
- assertEquals('id:0:1:cmVzcG9uc2U=', xPost.outQueue[0]);
-};
diff --git a/test/formsTest.js b/test/formsTest.js
index 66c4ec69..ccade915 100644
--- a/test/formsTest.js
+++ b/test/formsTest.js
@@ -2,7 +2,7 @@ nglrTest = TestCase('nglrTest');
nglrTest.prototype.testShiftBind = function(){
expectAsserts(3);
- nglr.shiftBind('this', function(target, arg) {
+ shiftBind('this', function(target, arg) {
assertEquals(this, 'this');
assertEquals(target, 'target');
assertEquals(arg, 'arg');
@@ -11,7 +11,7 @@ nglrTest.prototype.testShiftBind = function(){
nglrTest.prototype.testBind = function(){
expectAsserts(2);
- nglr.bind('this', function(arg) {
+ bind('this', function(arg) {
assertEquals(this, 'this');
assertEquals(arg, 'arg');
}).apply('XXX', ['arg']);
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index 13378d36..dde21846 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -6,8 +6,8 @@ HIDDEN = jQuery.browser.msie ?
' style="display: none; "' :
' style="display: none;"';
-nglr.msie = jQuery.browser.msie;
-nglr.alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);};
+msie = jQuery.browser.msie;
+alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);};
function noop(){}
@@ -50,7 +50,7 @@ jQuery.fn.sortedHtml = function() {
var toString = function(index, node) {
node = node || this;
if (node.nodeName == "#text") {
- html += nglr.escapeHtml(node.nodeValue);
+ html += escapeHtml(node.nodeValue);
} else {
html += '<' + node.nodeName.toLowerCase();
var attributes = node.attributes || [];
@@ -89,14 +89,14 @@ jQuery.fn.sortedHtml = function() {
};
function encode64(obj){
- return Base64.encode(nglr.toJson(obj));
+ return Base64.encode(toJson(obj));
}
function decode64(base64){
- return nglr.fromJson(Base64.decode(base64));
+ return fromJson(Base64.decode(base64));
}
-nglr.Loader.prototype.configureJQueryPlugins();
+Loader.prototype.configureJQueryPlugins();
function assertHidden(node) {
var display = node.css('display');
@@ -110,7 +110,7 @@ function assertVisible(node) {
}
function assertJsonEquals(expected, actual) {
- assertEquals(nglr.toJson(expected), nglr.toJson(actual));
+ assertEquals(toJson(expected), toJson(actual));
}
function assertUndefined(value) {
@@ -118,7 +118,7 @@ function assertUndefined(value) {
}
function assertDefined(value) {
- assertTrue(nglr.toJson(value), !!value);
+ assertTrue(toJson(value), !!value);
}
function assertThrows(error, fn){