Angular Jasmine,angular.mock.inject和inject之间有什么区别?

时间:2017-02-16 13:27:53

标签: javascript angularjs unit-testing jasmine karma-jasmine

在描述单元测试时,我们执行以下操作:

angular.mock.inject()

在每次测试之前,我们可能希望为所有规范注入依赖项,但是有两种方法可以执行此操作。 在beforeEach()中使用inject()beforeEach(angular.mock.inject(function ($injector) { someService = $injector.get('someService'); })); 之间有什么区别?

beforeEach(inject(function ($injector) {
    someService = $injector.get('someService');
}));

server {
    listen   443 ssl;
    ssl on;
    ssl_certificate /xyz.crt;
    ssl_certificate_key /xyz.key;

    root /var/www/mysite;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    client_max_body_size 2G;
    client_body_buffer_size 128k;

error_page 404 =200 /dir-b;
    location = / {
            try_files $uri $uri/ /dir-a;
    }

    # Serve static assets
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {

            gzip  on;
            gzip_http_version 1.0;
            gzip_vary on;
            gzip_comp_level 9;
            gzip_proxied any;
            gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
            gzip_buffers 16 8k;

            access_log off;
            expires max;
            add_header Cache-Control public;

            break;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            fastcgi_buffer_size 256k;
            fastcgi_buffers 8 256k;
            fastcgi_busy_buffers_size 256k;

            fastcgi_param HTTPS on;
            fastcgi_read_timeout 6000;
            fastcgi_param APPLICATION_ENV production;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
            deny all;
    }
}

谢谢:)

1 个答案:

答案 0 :(得分:2)

function strip_3bytes_utf($text) { return preg_replace("#([\xE0-\xEF][\x80-\xBF]{2})#i", '', $text); } function strip_4bytes_utf($text) { return preg_replace("#([\xF0-\xF7]{1}[\x80-\xBF]{3})#i", '', $text); } 只是inject()的快捷方式。