Browse Source

chore: Delete netlify.toml and update devDeps (#24343)

* Delete netlify.toml

* 🆙 upgrade dev deps

* fix mockdate tsd

* fix tsc noEmit
pull/24371/head
偏右 5 years ago
committed by GitHub
parent
commit
1bba2ef65e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 106
      components/calendar/__tests__/index.test.js
  2. 2
      components/date-picker/__tests__/DatePicker.test.js
  3. 2
      components/locale-provider/__tests__/index.test.js
  4. 4
      components/statistic/__tests__/index.test.js
  5. 111
      netlify.toml
  6. 13
      package.json
  7. 2
      tests/shared/demoTest.ts
  8. 2
      tests/shared/rtlTest.tsx
  9. 3
      tests/utils.ts

106
components/calendar/__tests__/index.test.js

@ -16,10 +16,7 @@ describe('Calendar', () => {
rtlTest(Calendar, true);
function openSelect(wrapper, className) {
wrapper
.find(className)
.find('.ant-select-selector')
.simulate('mousedown');
wrapper.find(className).find('.ant-select-selector').simulate('mousedown');
}
function findSelectItem(wrapper) {
@ -27,18 +24,13 @@ describe('Calendar', () => {
}
function clickSelectItem(wrapper, index = 0) {
findSelectItem(wrapper)
.at(index)
.simulate('click');
findSelectItem(wrapper).at(index).simulate('click');
}
it('Calendar should be selectable', () => {
const onSelect = jest.fn();
const wrapper = mount(<Calendar onSelect={onSelect} />);
wrapper
.find('.ant-picker-cell')
.at(0)
.simulate('click');
wrapper.find('.ant-picker-cell').at(0).simulate('click');
expect(onSelect).toHaveBeenCalledWith(expect.anything());
const value = onSelect.mock.calls[0][0];
expect(Moment.isMoment(value)).toBe(true);
@ -50,14 +42,8 @@ describe('Calendar', () => {
const wrapper = mount(
<Calendar onSelect={onSelect} validRange={validRange} defaultValue={Moment('2018-02-02')} />,
);
wrapper
.find('[title="2018-02-01"]')
.at(0)
.simulate('click');
wrapper
.find('[title="2018-02-02"]')
.at(0)
.simulate('click');
wrapper.find('[title="2018-02-01"]').at(0).simulate('click');
wrapper.find('[title="2018-02-02"]').at(0).simulate('click');
expect(onSelect.mock.calls.length).toBe(1);
});
@ -67,10 +53,7 @@ describe('Calendar', () => {
const wrapper = mount(
<Calendar onSelect={onSelect} validRange={validRange} defaultValue={Moment('2018-02-02')} />,
);
wrapper
.find('[title="2018-02-20"]')
.at(0)
.simulate('click');
wrapper.find('[title="2018-02-20"]').at(0).simulate('click');
const elem = wrapper.find('[title="2018-02-20"]').hasClass('ant-picker-cell-disabled');
expect(elem).toEqual(true);
expect(onSelect.mock.calls.length).toBe(0);
@ -87,32 +70,13 @@ describe('Calendar', () => {
mode="year"
/>,
);
expect(
wrapper
.find('[title="2018-01"]')
.at(0)
.hasClass('ant-picker-cell-disabled'),
).toBe(true);
expect(
wrapper
.find('[title="2018-02"]')
.at(0)
.hasClass('ant-picker-cell-disabled'),
).toBe(false);
expect(
wrapper
.find('[title="2018-06"]')
.at(0)
.hasClass('ant-picker-cell-disabled'),
).toBe(true);
wrapper
.find('[title="2018-01"]')
.at(0)
.simulate('click');
wrapper
.find('[title="2018-03"]')
.at(0)
.simulate('click');
expect(wrapper.find('[title="2018-01"]').at(0).hasClass('ant-picker-cell-disabled')).toBe(true);
expect(wrapper.find('[title="2018-02"]').at(0).hasClass('ant-picker-cell-disabled')).toBe(
false,
);
expect(wrapper.find('[title="2018-06"]').at(0).hasClass('ant-picker-cell-disabled')).toBe(true);
wrapper.find('[title="2018-01"]').at(0).simulate('click');
wrapper.find('[title="2018-03"]').at(0).simulate('click');
expect(onSelect.mock.calls.length).toBe(1);
});
@ -155,7 +119,7 @@ describe('Calendar', () => {
});
it('Calendar should support locale', () => {
MockDate.set(Moment('2018-10-19'));
MockDate.set(Moment('2018-10-19').valueOf());
// eslint-disable-next-line global-require
const zhCN = require('../locale/zh_CN').default;
const wrapper = mount(<Calendar locale={zhCN} />);
@ -168,10 +132,7 @@ describe('Calendar', () => {
const date = new Moment('1990-09-03');
const wrapper = mount(<Calendar onPanelChange={onPanelChange} value={date} />);
wrapper
.find('.ant-picker-cell')
.at(0)
.simulate('click');
wrapper.find('.ant-picker-cell').at(0).simulate('click');
expect(onPanelChange).toHaveBeenCalled();
expect(onPanelChange.mock.calls[0][0].month()).toEqual(date.month() - 1);
@ -242,10 +203,7 @@ describe('Calendar', () => {
/>,
);
openSelect(wrapper, '.ant-picker-calendar-year-select');
wrapper
.find('.ant-select-item-option')
.last()
.simulate('click');
wrapper.find('.ant-select-item-option').last().simulate('click');
expect(onValueChange).toHaveBeenCalledWith(value.year('2019').month('2'));
});
@ -283,10 +241,7 @@ describe('Calendar', () => {
type="date"
/>,
);
wrapper
.find('input[type="radio"]')
.at(1)
.simulate('change');
wrapper.find('input[type="radio"]').at(1).simulate('change');
expect(onTypeChange).toHaveBeenCalledWith('year');
});
@ -324,9 +279,7 @@ describe('Calendar', () => {
openSelect(wrapperWithYear, '.ant-select');
wrapperWithYear.update();
findSelectItem(wrapperWithYear)
.last()
.simulate('click');
findSelectItem(wrapperWithYear).last().simulate('click');
expect(onYearChange).toHaveBeenCalled();
@ -371,9 +324,7 @@ describe('Calendar', () => {
openSelect(wrapperWithMonth, '.ant-select');
wrapperWithMonth.update();
findSelectItem(wrapperWithMonth)
.last()
.simulate('click');
findSelectItem(wrapperWithMonth).last().simulate('click');
expect(onMonthChange).toHaveBeenCalled();
@ -391,10 +342,7 @@ describe('Calendar', () => {
<Calendar fullscreen={false} headerRender={headerRenderWithTypeChange} />,
);
wrapperWithTypeChange
.find('.ant-radio-button-input')
.last()
.simulate('change');
wrapperWithTypeChange.find('.ant-radio-button-input').last().simulate('change');
expect(onTypeChange).toHaveBeenCalled();
});
@ -402,23 +350,13 @@ describe('Calendar', () => {
const wrapper = mount(
<Calendar dateFullCellRender={() => <div className="light">Bamboo</div>} />,
);
expect(
wrapper
.find('.light')
.first()
.text(),
).toEqual('Bamboo');
expect(wrapper.find('.light').first().text()).toEqual('Bamboo');
});
it('monthFullCellRender', () => {
const wrapper = mount(
<Calendar mode="year" monthFullCellRender={() => <div className="bamboo">Light</div>} />,
);
expect(
wrapper
.find('.bamboo')
.first()
.text(),
).toEqual('Light');
expect(wrapper.find('.bamboo').first().text()).toEqual('Light');
});
});

2
components/date-picker/__tests__/DatePicker.test.js

@ -11,7 +11,7 @@ describe('DatePicker', () => {
focusTest(DatePicker, { refFocus: true });
beforeEach(() => {
MockDate.set(moment('2016-11-22'));
MockDate.set(moment('2016-11-22').valueOf());
});
afterEach(() => {

2
components/locale-provider/__tests__/index.test.js

@ -174,7 +174,7 @@ describe('Locale Provider', () => {
));
beforeAll(() => {
MockDate.set(moment('2017-09-18T03:30:07.795'));
MockDate.set(moment('2017-09-18T03:30:07.795').valueOf());
});
afterAll(() => {

4
components/statistic/__tests__/index.test.js

@ -14,7 +14,7 @@ describe('Statistic', () => {
rtlTest(Statistic);
beforeAll(() => {
MockDate.set(moment('2018-11-28 00:00:00'));
MockDate.set(moment('2018-11-28 00:00:00').valueOf());
});
afterAll(() => {
@ -102,7 +102,7 @@ describe('Statistic', () => {
const wrapper = mount(<Statistic.Countdown value={now} onFinish={onFinish} />);
wrapper.update();
MockDate.set(moment('2019-11-28 00:00:00'));
MockDate.set(moment('2019-11-28 00:00:00').valueOf());
jest.runAllTimers();
expect(onFinish).toHaveBeenCalled();

111
netlify.toml

@ -1,111 +0,0 @@
[build]
publish = "_site"
command = "npm run site"
[[redirects]]
from = "/docs/resource/download"
to = "/docs/spec/download"
status = 301
force = false
[[redirects]]
from = "/docs/resource/download-cn"
to = "/docs/spec/download-cn"
status = 301
force = false
[[redirects]]
from = "/docs/resource/reference"
to = "/docs/spec/reference"
status = 301
force = false
[[redirects]]
from = "/docs/resource/reference-cn"
to = "/docs/spec/reference-cn"
status = 301
force = false
[[redirects]]
from = "/docs/spec/feature"
to = "/docs/spec/values"
status = 301
force = false
[[redirects]]
from = "/docs/spec/feature-cn"
to = "/docs/spec/values-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/advanced-search"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/advanced-search-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/complex-table"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/complex-table-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/form"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/form-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/list"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/list-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/navigation"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/navigation-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/table"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/table-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false

13
package.json

@ -62,7 +62,7 @@
"deploy": "bisheng gh-pages --push-only --dotfiles",
"deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages",
"dist": "antd-tools run dist",
"lint": "npm run lint:tsc && npm run lint:script && npm run lint:demo && npm run lint:style && npm run lint:deps && npm run lint:md",
"lint": "npm run tsc && npm run lint:script && npm run lint:demo && npm run lint:style && npm run lint:deps && npm run lint:md",
"lint-fix": "npm run lint-fix:script && npm run lint-fix:demo && npm run lint-fix:style",
"lint-fix:demo": "eslint-tinker ./components/*/demo/*.md",
"lint-fix:script": "npm run lint:script -- --fix",
@ -72,7 +72,6 @@
"lint:md": "remark . -f -q",
"lint:script": "eslint . --ext '.js,.jsx,.ts,.tsx'",
"lint:style": "stylelint '{site,components}/**/*.less' --syntax less",
"lint:tsc": "npm run tsc -- --noEmit",
"pre-publish": "npm run check-commit && npm run test-all",
"prettier": "prettier -c --write '**/*'",
"pretty-quick": "pretty-quick",
@ -87,7 +86,7 @@
"test:update": "jest --config .jest.js --no-cache --update-snapshot",
"test-all": "./scripts/test-all.sh",
"test-node": "jest --config .jest.node.js --no-cache",
"tsc": "tsc",
"tsc": "tsc --noEmit",
"site:test": "jest --config .jest.site.js --cache=false",
"test:image": "npm install puppeteer@2.1.1 --no-save && jest --config .jest.image.js --no-cache",
"version": "node ./scripts/generate-version"
@ -160,10 +159,10 @@
"@types/enzyme": "^3.10.5",
"@types/gtag.js": "^0.0.3",
"@types/jest": "^25.1.0",
"@types/jest-image-snapshot": "^2.12.0",
"@types/jest-image-snapshot": "^3.1.0",
"@types/lodash": "^4.14.139",
"@types/prop-types": "^15.7.1",
"@types/puppeteer": "^2.0.1",
"@types/puppeteer": "^3.0.0",
"@types/raf": "^3.4.0",
"@types/react": "^16.9.21",
"@types/react-color": "^3.0.1",
@ -216,7 +215,7 @@
"inquirer": "^7.1.0",
"intersection-observer": "^0.10.0",
"jest": "^26.0.0",
"jest-image-snapshot": "^3.1.0",
"jest-image-snapshot": "^4.0.0",
"jest-stare": "^2.0.1",
"jquery": "^3.4.1",
"jsdom": "^16.0.0",
@ -225,7 +224,7 @@
"logrocket": "^1.0.0",
"logrocket-react": "^4.0.0",
"lz-string": "^1.4.4",
"mockdate": "^2.0.2",
"mockdate": "^3.0.0",
"node-fetch": "^2.6.0",
"open": "^7.0.3",
"preact": "^10.0.0",

2
tests/shared/demoTest.ts

@ -53,7 +53,7 @@ export default function demoTest(component: string, options: Options = {}) {
testMethod = test.skip;
}
testMethod(`renders ${file} correctly`, () => {
MockDate.set(moment('2016-11-22').toDate());
MockDate.set(moment('2016-11-22').valueOf());
const demo = require(`../.${file}`).default; // eslint-disable-line global-require, import/no-dynamic-require
const wrapper = render(demo);

2
tests/shared/rtlTest.tsx

@ -9,7 +9,7 @@ export default function rtlTest(Component: React.ComponentType, mockDate?: boole
describe(`rtl render`, () => {
it(`component should be rendered correctly in RTL direction`, () => {
if (mockDate) {
MockDate.set(Moment('2000-09-28').toDate());
MockDate.set(Moment('2000-09-28').valueOf());
}
const wrapper = mount(
<ConfigProvider direction="rtl">

3
tests/utils.ts

@ -1,8 +1,7 @@
import moment from 'moment';
import MockDate from 'mockdate';
export function setMockDate(dateString = '2017-09-18T03:30:07.795') {
MockDate.set(moment(dateString).toDate());
MockDate.set(dateString);
}
export function resetMockDate() {

Loading…
Cancel
Save