小编Ero*_*ano的帖子

开玩笑描述套件失败但独立运行测试成功

当我单独运行每个测试时,它们都会成功。但是当我npm test第二次测试失败时将它们一起运行时:

Expected number of calls: 2
Received number of calls: 4
Run Code Online (Sandbox Code Playgroud)

我有以下代码:(简短且精简)

describe('checkDonations', () => {
test('it should call twice (test 1)', async () => {
    const axiosSpy = jest.spyOn(axios.default, 'get')
        .mockImplementation(() => {
            return new Promise(resolve => {
                resolve({
                    data: {
                        status: [
                            {
                                "created": "2020-04-08 21:20:17",
                                "timestamp": "1586373617",
                                "statusName": "new"
                            }
                        ]
                    }
                })
            })
        });

    await checkDonations(null, {});

    expect(axiosSpy).toHaveBeenCalledTimes(2);
})

test('it should call twice (test 2)', async () => {
    const axiosSpy = jest.spyOn(axios.default, …
Run Code Online (Sandbox Code Playgroud)

typescript jestjs

9
推荐指数
1
解决办法
1万
查看次数

LocationManager:java.lang.NoSuchMethodError

我是这个社区的新手,但我已经习惯了很多东西!实际上我开始在Android Studio上编程,但现在我卡在了某个地方.我相信你会很快找到它.

在模拟器Nexus 5 API 23(已经安装在Android Studio中的那个)中,它正在运行,但在我的移动Android 5.1.1 API 22上,它开始运行.

错误: 09-20 19:15:11.526 17776-17776/com.example.stefano.aiutomamma01 E/AndroidRuntime? FATAL EXCEPTION: main Process: com.example.stefano.aiutomamma01, PID: 17776 java.lang.NoSuchMethodError: No virtual method checkSelfPermission(Ljava/lang/String;)I in class Lcom/example/stefano/aiutomamma01/MainActivity; or its super classes (declaration of 'com.example.stefano.aiutomamma01.MainActivity' appears in /data/app/com.example.stefano.aiutomamma01-2/base.apk) at com.example.stefano.aiutomamma01.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5373) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)

JAVA代码:

package com.example.stefano.aiutomamma01;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import …
Run Code Online (Sandbox Code Playgroud)

android android-studio

8
推荐指数
1
解决办法
1万
查看次数

Joomla JText :: _("")

我试图改变Joomla的语言!组件称为DigiCom.其实这里我不明白这一行:

<th class="text-center"><?php echo JText::_("COM_DIGICOM_PRICE_PLAN");?></th>
Run Code Online (Sandbox Code Playgroud)

我想这可能是一个参考,因为显示的文本不是COM_DIGICOM_PRICE_PLAN.如果我是对的,你知道我在哪里可以改变吗?

以下是代码的一部分:

<?php
/**
 * @package     DigiCom
 * @author      ThemeXpert http://www.themexpert.com
 * @copyright   Copyright (c) 2010-2015 ThemeXpert. All rights reserved.
 * @license     GNU General Public License version 3 or later; see LICENSE.txt
 * @since       1.0.0
 */

defined('_JEXEC') or die;


JHTML::_('behavior.formvalidation');

$pg_plugin = $this->pg_plugin;
$configs = $this->configs;
$data = $this->data;
?>
<div id="digicom" class="dc dc-checkout">

    <?php
    $this->setLayout('cart');
    echo $this->loadTemplate('steps');
    ?>

    <h1 class="page-title"><?php echo JText::sprintf("COM_DIGICOM_CHECKOUT_PAYMENT_DETAILS_PAGE_TITLE", $pg_plugin); ?></h1>

    <div class="dc-checkout-items">

        <h4 class="align-center"><?php echo JText::_("COM_DIGICOM_SUMMARY_YOUR_ORDER");?></h4>
Run Code Online (Sandbox Code Playgroud)

php joomla

4
推荐指数
1
解决办法
6860
查看次数

如何使用 Firebase 函数在 Firebase 存储上上传包含 JSON 的新文件?

如何使用 Firebase 函数在 Firebase 存储上上传包含 JSON 的新文件?到目前为止我的代码:

exports.scheduledFunctionCrontab = functions.pubsub.schedule("0 0 * * *")
    .onRun(async () => {
        try {
            const response = await axios.get("api.com");
   
            const bucket = await admin.storage().bucket();

            // What now?

        } catch (e) {
            functions.logger.error(e);
        }

        return null;
    })
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-platform google-cloud-functions firebase-storage

4
推荐指数
1
解决办法
554
查看次数

firebase auth 在刷新时丢失 cookie

技术:框架:Angular,组件:Ionic,Auth-Service:Firebase,NPM-Module:https : //www.npmjs.com/package/@angular/fire

情况:用户可以通过用户名和密码登录,也可以使用 Google Auth 登录。当用户登录时,一些 cookie 会存储在浏览器中。

按照这里的要求是我用来登录的代码:

登录

loginWithGoogle() {
    from(this.authService.logIn())
        .pipe(
            concatMap(() => this.authService.getAuth().signInWithPopup(new auth.GoogleAuthProvider())),
            concatMap(userCredential => this.initStateAndRoute(userCredential)),
        )
        .subscribe();
}
Run Code Online (Sandbox Code Playgroud)

认证服务

export class AuthService {

constructor(
    private fireAuth: AngularFireAuth,
) {
}

getUser(): Observable<firebase.User> {
    return this.fireAuth.user;
}

logOut() {
    return this.fireAuth.auth.signOut();
}

getAuth() {
    return this.fireAuth.auth;
}

logIn() {
    return this.fireAuth.auth.setPersistence(firebase.auth.Auth.Persistence.LOCAL);
}
Run Code Online (Sandbox Code Playgroud)

}

Auth-Guard-Service

@Injectable({
providedIn: 'root'
})
export class AuthGuardService implements CanActivate {
constructor( …
Run Code Online (Sandbox Code Playgroud)

google-authentication firebase firebase-authentication angular

3
推荐指数
1
解决办法
716
查看次数