Browse Source

test(Anchor): optimize dataNowMockFn, avoid being consumed in advance (#18663)

* 优化 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
pull/18697/head
骗你是小猫咪 5 years ago
committed by 偏右
parent
commit
d9bfc689a4
  1. 2
      .circleci/config.yml
  2. 11
      components/anchor/__tests__/Anchor.test.js

2
.circleci/config.yml

@ -3,7 +3,7 @@ version: 2
references: references:
container_config: &container_config container_config: &container_config
docker: docker:
- image: circleci/node:8 - image: circleci/node:lts
working_directory: ~/ant-design working_directory: ~/ant-design
attach_workspace: &attach_workspace attach_workspace: &attach_workspace

11
components/anchor/__tests__/Anchor.test.js

@ -279,10 +279,13 @@ describe('Anchor Render', () => {
let dateNowMock; let dateNowMock;
function dataNowMockFn() { function dataNowMockFn() {
return jest let start = 0;
.spyOn(Date, 'now')
.mockImplementationOnce(() => 0) const handler = () => {
.mockImplementationOnce(() => 1000); return (start += 1000);
};
return jest.spyOn(Date, 'now').mockImplementation(handler);
} }
dateNowMock = dataNowMockFn(); dateNowMock = dataNowMockFn();

Loading…
Cancel
Save