Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync upsteam Akiran master #110

Merged
merged 62 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2f7fdf5
remove old tests
akiran Jul 26, 2022
472c848
test setup with testing library
akiran Jul 26, 2022
4e6250b
wrote tests for basic slider example
akiran Jul 26, 2022
89d1e89
Fixed broken link from CONTRIBUTING.md
pZacca Oct 15, 2022
7035d84
tests init
akiran May 15, 2023
34b4ca0
Merge branch 'master' into fix-2166
akiran May 15, 2023
0711da9
completed the simpleslider test and started centerMode test
pratyushbh May 15, 2023
c4f6fde
migrated all the test of examples from enezyme to react-testing-library
pratyushbh May 16, 2023
338201f
migrated all the tests to testing-library/react and removed Snapshots
pratyushbh May 18, 2023
83423c8
removed the console logs
pratyushbh May 19, 2023
b03b477
renamed few test utils
akiran May 21, 2023
e6b231a
fix current slide issue
akiran May 21, 2023
e45defb
added a comment
akiran May 21, 2023
90b1aff
Merge pull request #2238 from akiran/fix-2166-2
akiran May 21, 2023
9c52885
Fixed 2231: Move build script from prepublish -> prepublishOnly
akiran May 23, 2023
f3f3c3d
Merge pull request #2240 from akiran/fix-2221
akiran May 23, 2023
0d30a59
Merge pull request #2194 from pZacca/add-pzacca
akiran May 25, 2023
f880fba
wrote the tests of #1874 that came out to be successful
pratyushbh May 25, 2023
f5bb030
Converted the examples to Functional component and created new Slider…
pratyushbh May 30, 2023
882a01d
added node options to run docs
akiran Jun 5, 2023
e1e766f
remove other changes
akiran Jun 5, 2023
38f99c1
Merge branch 'master' into function-component-examples
akiran Jun 5, 2023
45e92f0
fixed some issues with component changes
akiran Jun 5, 2023
5558419
Merge pull request #2244 from akiran/function-component-examples
akiran Jun 5, 2023
76b833f
added an empty prettierrc file to use default prettier config
akiran Jan 19, 2024
bb355c2
added react-slick alias in webpack for examples
akiran Jan 19, 2024
d91bb58
running single demo on different port
akiran Jan 20, 2024
3669b0a
Fix: If the element (DOM element) and the value of 'slidesToShow' are…
rjsdnql123 Jan 24, 2024
15d93c5
Merge pull request #2329 from rjsdnql123/fix/element-slidesToShow-sam…
akiran Jan 24, 2024
5b2e405
added tests for #1813
akiran Jan 25, 2024
ff0cd50
release 0.30.0
akiran Jan 25, 2024
891f399
added node options to fix build issue
akiran Jan 25, 2024
358d8c0
created a generic slider component for tests
akiran Jan 25, 2024
dbae660
fixed #1874: slick-current is always on first slide despite initialSl…
akiran Jan 25, 2024
2420174
Merge pull request #2330 from akiran/fix-1874
akiran Jan 25, 2024
9d96291
Fixed #2315
akiran Jan 25, 2024
27870b7
Test for #2315
akiran Jan 26, 2024
8c9488f
check of NaN in props change detection
akiran Jan 26, 2024
02629d5
added tests for filterSettings util
akiran Jan 26, 2024
99adf6f
Merge pull request #2331 from akiran/fix-2315
akiran Jan 26, 2024
250f078
release 0.30.1
akiran Jan 26, 2024
0a66bd7
updated instructions for css loading
akiran Jan 26, 2024
1bd9c09
updated readme
akiran Jan 26, 2024
7710dc9
Move testing dependency to devDependencies
jorrit Feb 2, 2024
72ffb60
Merge pull request #2339 from jorrit/fixtestdep
akiran Feb 2, 2024
013f424
moved scripts from examples to docs
akiran Feb 3, 2024
5a99cd1
examples config to docs
akiran Feb 3, 2024
c0fde5e
cleanup examples
akiran Feb 3, 2024
e06967c
Added slider-container class to examples
akiran Feb 5, 2024
1a3f604
Replaced codesandbox with stackblitz playground link
akiran Feb 5, 2024
ec32089
Fixed #2076 click issue in Fade mode
akiran Feb 8, 2024
cf31307
Added regenerator-runtime for async jest tests
akiran Feb 9, 2024
372349a
updated jest config to run tests only with .test.js extension
akiran Feb 9, 2024
b9150c1
updated jest config to ignore playwright tests
akiran Feb 9, 2024
d4595b0
placeholder for test
akiran Feb 16, 2024
0f95c7a
Merge pull request #2343 from akiran/fix-2076
akiran Feb 16, 2024
23c6a47
add asNavFor for default prop
akiran Feb 17, 2024
9227178
remove empty test file
akiran Feb 17, 2024
5a7c0a8
Merge pull request #2349 from akiran/fix-2344
akiran Feb 17, 2024
5478d8d
released 0.30.2
akiran Feb 17, 2024
e0bd6b7
chore: sync upstream changes
afc163 Mar 26, 2024
de91e69
test: fix test case
afc163 Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
with:
node-version: '20.x'
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm test
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trailingComma: none
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
First, thank you for considering contributing to react-slick! It's people like you that make the open source community such a great community! 😊

We welcome any type of contribution, not only code. You can help with

- **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
- **Marketing**: writing blog posts, howto's, printing stickers, ...
- **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
Expand All @@ -13,7 +14,7 @@ We welcome any type of contribution, not only code. You can help with

## Your First Contribution

Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
Working on your first Pull Request? You can learn how from this _free_ series, [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).

## Submitting code

Expand Down Expand Up @@ -41,14 +42,12 @@ You can also reach us at hello@react-slick.opencollective.com.
Thank you to all the people who have already contributed to react-slick!
<a href="https://github.com/akiran/react-slick/graphs/contributors"><img src="https://opencollective.com/react-slick/contributors.svg?width=890" /></a>


### Backers

Thank you to all our backers! [[Become a backer](https://opencollective.com/react-slick#backer)]

<a href="https://opencollective.com/react-slick#backers" target="_blank"><img src="https://opencollective.com/react-slick/backers.svg?width=890"></a>


### Sponsors

Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/react-slick#sponsor))
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### react-slick
### @ant-design/react-slick

[![Backers on Open Collective](https://opencollective.com/react-slick/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/react-slick/sponsors/badge.svg)](#sponsors)

Expand All @@ -11,13 +11,13 @@
**npm**

```bash
npm install react-slick --save
npm install @ant-design/react-slick --save
```

**yarn**

```bash
yarn add react-slick
yarn add @ant-design/react-slick
```

**Also install slick-carousel for css and font**
Expand All @@ -37,22 +37,22 @@ or add cdn link in your html
rel="stylesheet"
type="text/css"
charset="UTF-8"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css"
/>
<link
rel="stylesheet"
type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css"
/>
```

### [PlayGround](https://codesandbox.io/s/ppwkk5l6xx)
### [PlayGround](https://stackblitz.com/edit/vitejs-vite-ownrun?file=src%2FImageSlider.jsx)

### Example

```js
import React from "react";
import Slider from "react-slick";
import Slider from "@ant-design/react-slick";

export default function SimpleSlider() {
var settings = {
Expand Down Expand Up @@ -100,7 +100,7 @@ For all available methods, go [here](https://react-slick.neostack.com/docs/api#m
Want to run demos locally

```bash
git clone https://github.com/akiran/react-slick
git clone https://github.com/ant-design/react-slick
cd react-slick
npm install
npm start
Expand All @@ -111,7 +111,6 @@ open http://localhost:8080

Join our [discord channel](https://discord.gg/z7stRE4Cyb) to discuss react-slick bugs and ask for help


## Contributing

Please see the [contributing guidelines](./CONTRIBUTING.md)
5 changes: 2 additions & 3 deletions __tests__/SimpleSlider.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// includes tests of
// SimpleSlider, MultipleItems
import { mount } from "enzyme";
import { testSlider } from "./testUtils";

describe("SimpleSlider with combinations of possibilities", function() {
describe("SimpleSlider with combinations of possibilities", function () {
// try around several possibilities
let _noOfSlides = [2, 5, 12];
let _slidesToShow = [2, 5, 10];
Expand Down Expand Up @@ -38,7 +37,7 @@ describe("SimpleSlider with combinations of possibilities", function() {
slidesToScroll,
useCSS: false
};
test(`Test with settings => noOfSlides: ${noOfSlides}, slidesToShow: ${slidesToShow}, slidesToScroll: ${slidesToScroll}`, function() {
test(`Test with settings => noOfSlides: ${noOfSlides}, slidesToShow: ${slidesToShow}, slidesToScroll: ${slidesToScroll}`, function () {
testSlider(settings1);
});
}
Expand Down
13 changes: 13 additions & 0 deletions __tests__/TestComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import Slider from "../src/index";

export function GenericSliderComponent({ slidesCount, settings }) {
const slides = [...Array(slidesCount).keys()].map((item) => (
<div key={item}>{item + 1}</div>
));
return <Slider {...settings}>{slides}</Slider>;
}

test("fake test", () => {
expect(1).toBe(1);
});
53 changes: 20 additions & 33 deletions __tests__/afterChange.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from "react";
import { mount } from "enzyme";
import { render, fireEvent } from "@testing-library/react";
import Slider from "../src/index";
import {
getActiveSlide,
clickNext,
clickPrevious,
getCurrentSlide
} from "../test-utils";

class SliderWithBeforeChange extends React.Component {
class SliderWithAfterChange extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand All @@ -29,39 +35,20 @@ class SliderWithBeforeChange extends React.Component {
}
}

describe("After change Slider", function() {
it("should render", function() {
const wrapper = mount(<SliderWithBeforeChange />);
expect(wrapper.state()).toEqual({ currentSlide: null });
wrapper.find(".slick-next").simulate("click");
describe("After change Slider", function () {
it("should render", function () {
const { container } = render(<SliderWithAfterChange />);
clickNext(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
wrapper.find(".slick-next").simulate("click");
expect(getActiveSlide(container).textContent).toEqual("slide2");
}, 1000);
clickNext(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide3");
expect(wrapper.state()).toEqual({ currentSlide: 2 });
}, 1);
wrapper.find(".slick-prev").simulate("click");
expect(getActiveSlide(container).textContent).toEqual("slide3");
}, 1000);
clickPrevious(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
expect(getActiveSlide(container).textContent).toEqual("slide2");
}, 1000);
});
});
68 changes: 36 additions & 32 deletions __tests__/arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sinon.stub(console, "error");

import { render, shallow } from "enzyme";
import { render } from "@testing-library/react";
import React from "react";
import sinon from "sinon";

Expand All @@ -22,48 +22,52 @@ function CustomArrow(props) {

describe("Previous arrows", () => {
it("should render arrow", () => {
const wrapper = shallow(<PrevArrow />);
expect(wrapper.find("button")).toHaveLength(1);
const { container } = render(<PrevArrow />);
expect(Array.from(container.getElementsByTagName("button"))).toHaveLength(
1
);
});

it("should not result in errors", () => {
shallow(<PrevArrow />);
render(<PrevArrow />);

expect(console.error.called).toBe(false);
});

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />
//
// const wrapper = render(<PrevArrow currentSlide={3} prevArrow={arr} slideCount={5} />);
//
// elAttributes = wrapper.find('.sample')[0].attribs;
// expect(elAttributes['data-currentslide']).toBe('3');
// expect(elAttributes['data-slidecount']).toBe('5');
// });
// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />

// const {container}= render(<PrevArrow currentSlide={3} prevArrow={arr} slideCount={5} />);

// elAttributes =x=> container.querySelectorAll('.sample')[0].getAttribute(x);
// expect(elAttributes('data-currentslide')).toBe('3');
// expect(elAttributes('data-slidecount')).toBe('5');
// });
});

describe("Next arrows", () => {
it("should render arrow", () => {
const wrapper = shallow(<NextArrow />);
expect(wrapper.find("button")).toHaveLength(1);
const { container } = render(<NextArrow />);
expect(Array.from(container.getElementsByTagName("button"))).toHaveLength(
1
);
});

// it('should not result in errors', () => {
// shallow(<NextArrow />);
//
// expect(console.error.called).toBe(false);
// });

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />
//
// const wrapper = render(<NextArrow currentSlide={6} nextArrow={arr} slideCount={9} />);
//
// elAttributes = wrapper.find('.sample')[0].attribs;
// expect(elAttributes['data-currentslide']).toBe('6');
// expect(elAttributes['data-slidecount']).toBe('9');
// });
// it('should not result in errors', () => {
// render(<NextArrow />);

// expect(console.error.called).toBe(false);
// });

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />

// const {container} = render(<NextArrow currentSlide={6} nextArrow={arr} slideCount={9} />);

// elAttributes =(x)=> container.querySelectorAll('.sample')[0].getAttribute(x);
// expect(elAttributes('data-currentslide')).toBe('6');
// expect(elAttributes('data-slidecount')).toBe('9');
// });
});
44 changes: 16 additions & 28 deletions __tests__/beforeChange.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from "react";
import { mount } from "enzyme";
import { render } from "@testing-library/react";
import Slider from "../src/index";
import {
getActiveSlide,
clickNext,
clickPrevious,
getCurrentSlide
} from "../test-utils";

class SliderWithBeforeChange extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -29,32 +35,14 @@ class SliderWithBeforeChange extends React.Component {
}
}

describe.skip("Slider", function() {
it("should render", function() {
const wrapper = mount(<SliderWithBeforeChange />);
wrapper.find(".slick-next").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 0, nextSlide: 1 });
wrapper.find(".slick-next").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide3");
expect(wrapper.state()).toEqual({ currentSlide: 1, nextSlide: 2 });
wrapper.find(".slick-prev").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 2, nextSlide: 1 });
describe("Slider", function () {
it("should render", function () {
const { container } = render(<SliderWithBeforeChange />);
clickNext(container);
expect(getActiveSlide(container).textContent).toEqual("slide2");
clickNext(container);
expect(getActiveSlide(container).textContent).toEqual("slide3");
clickPrevious(container);
expect(getActiveSlide(container).textContent).toEqual("slide2");
});
});
22 changes: 0 additions & 22 deletions __tests__/index.js

This file was deleted.