From d9bfc689a44eeae31b241d5a7a32d69eee487115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AA=97=E4=BD=A0=E6=98=AF=E5=B0=8F=E7=8C=AB=E5=92=AA?= Date: Thu, 5 Sep 2019 11:33:11 +0800 Subject: [PATCH] test(Anchor): optimize dataNowMockFn, avoid being consumed in advance (#18663) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化 dataNowMockFn, 避免被提前消费 * test circleci/node:latest * change .circleci circleci/node:latest -> circleci/node:lts * add step command [node -v] check current node version * retry ci test * rebase master * retry CI test --- .circleci/config.yml | 2 +- components/anchor/__tests__/Anchor.test.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f219e68c6..a280fde28d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 references: container_config: &container_config docker: - - image: circleci/node:8 + - image: circleci/node:lts working_directory: ~/ant-design attach_workspace: &attach_workspace diff --git a/components/anchor/__tests__/Anchor.test.js b/components/anchor/__tests__/Anchor.test.js index 65be9cfa2e..3cf43c755c 100644 --- a/components/anchor/__tests__/Anchor.test.js +++ b/components/anchor/__tests__/Anchor.test.js @@ -279,10 +279,13 @@ describe('Anchor Render', () => { let dateNowMock; function dataNowMockFn() { - return jest - .spyOn(Date, 'now') - .mockImplementationOnce(() => 0) - .mockImplementationOnce(() => 1000); + let start = 0; + + const handler = () => { + return (start += 1000); + }; + + return jest.spyOn(Date, 'now').mockImplementation(handler); } dateNowMock = dataNowMockFn();