Skip to content

Commit

Permalink
Pencils down turn in your tests (#61)
Browse files Browse the repository at this point in the history
* 🚨 added karma config

* add jQuery and jasmine jquery

* 🚨 add test packages, add test commands

* 🚧 stub in first tests WIP

still trying to get the HTML injected

* 📝 converted demos to CodePen, added demo section

* 📝 phrasing for better line break

* remove jQuery test resources

* create test

* convert all $q to native promises, add return to all resolve and rejects

$q promises were causing some odd issues with tests.

* 🚨 first passing test. create()

* create now uses the element ID if one exists and no custom ID was passed in

* 🚨 create() ID methods tested

* add method to get all instances

Helps with testing

* 🚨 test that destroy works correctly

* 🚨 test the new getAll method

* 🚨 test next()

* 🚨 test previous()

* 🚨 verify next() works with wrap

* 🚨 test previous() wrap

* 🚨 test select()

* 🚨 test cellSelect() with a selector string

* 🚨 selectedIndex()

* 🔥 remove unused instances, 🚨 spying on resize reposition and reloadCells

* 🚨 test get()

* 🚨 test getFirst

* 🚨 test getByElement

* 🚨 test prepend()

* 🚨 fix new image url, cleanup spacing, test append()

* 🚨 test insert()

* 👕 removed magic number

* 📚 Fixed incorrect copypasta method documentation

* 🚨 test getCellElements()

* 🚨 test remove()

* 🚨 test selectedElement()

* 🚨 test cells()

* 🚨 test _getFlickityIndex()

* 🚨 test _findObjectById, protect against missing element

* 💄 use template strings

* 👷 new build

* 🚨 set up coveralls

* 📝 add coveralls and circleci badges, add test docs

* ⬆️ upgrade eslint loader to play nice with latest eslint

* 🔥 remove unused globals

* 🚨 test instance destruction on directive destruction

* 💄 convert ' to ` for uniformity

* 🔥 removed imagesLoaded import

- it was not the correct lib
- it should be the responsibility of the consuming app to load
(otherwise it is loaded for everyone that doesn’t need it)

* 🔥 no longer bundling Flickity inside angular-flickity

* 👷 new build

* 🔧 no longer bundling Flickity

* 👷 new build

* 🚨 test rejection of duplicate IDs

* 🐛 fix bug if index not found, 💄 converted remaining ' to `

* 🚨 use custom IDs for easier debugging, test destroying missing instance

* 🔥 no longer setting a default value that Flickity doesn't also default to

* 💄 convert to template strings

* 🔥 remove unused reject

* ✨ fallback to true now that config may not have default

* 💄 use native promises

* 🔧 include nested spec files

* better checks for wrapAround

* 📝 change Int to number

* check for disable after service call, switch to template strings

* 🚨 test button disabling

* 👷 new build

* 🚨 better phrasing, cleanup

* 🚨 test next directive disabling

* 💄 simplified file names

* added returns to each resolve/reject

* 🚨 test previous ctrl ID setting

* 🔥 remove unused option

* 🚨 test next ctrl ID setting

* 👷 new build

* 🚨 test FlickityController

* 📝 better install docs, moved dependencies under installation, cleanup
  • Loading branch information
benjamincharity authored Nov 9, 2016
1 parent 45657e4 commit de9f32e
Show file tree
Hide file tree
Showing 23 changed files with 2,227 additions and 4,769 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repo_token: 8TGRfQtRhmmGtpTZqHYkCVIfvRn8QUrD7

89 changes: 67 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="http://cdn.benjamincharity.com/open_source/angular-flickity/mark.png" align="right" alt="angular-flickity">

[![MIT License][license_image]][license_url] [![NPM version][npm_version_image]][npm_url]
[![MIT License][license_image]][license_url] [![Coverage Status][coverage_image]][coverage_url] [![NPM version][npm_version_image]][npm_url] [![CircleCI][circle_badge]][circle_link]

An AngularJS module that exposes a directive and service to create and control multiple
[Flickity][flickity] instances.
Expand All @@ -16,7 +16,7 @@ _[Comments and pull requests welcome!][issues]_
## Contents

- [Installation](#installation)
- [Dependencies](#dependencies)
- [Dependencies](#dependencies)
- [Usage](#usage)
- [Options](#options)
- [ID](#id)
Expand Down Expand Up @@ -62,16 +62,52 @@ _[Comments and pull requests welcome!][issues]_

## Installation

#### Dependencies

- [AngularJS `(^1.4.0)`][angular]
- [Flickity `(^2.0.3)`][flickity_docs]
- [flickity-imagesloaded `(^2.0.0)`][flickity_imagesloaded] (if using the [imagesloaded option][flickity_options])


#### NPM

```bash
npm install flickity --save
npm install flickity-imagesloaded --save # if using the imagesloaded option
npm install angular-flickity --save
```

#### Bower

```bash
bower install flickity --save
bower install flickity-imagesloaded --save # if using the imagesloaded option
bower install angular-flickity --save
```

### Include the scripts

Include `Flickity` (and `flickity-imagesloaded` if needed):

#### Webpack

```
import Flickity from 'flickity';
import 'flickity-imagesloaded';
import 'angular-flickity';
angular.module('myProject', ['bc.Flickity']);
```

#### Manually

```
<!-- Include the module -->
<script src="path/to/lib/flickity.js"></script>
<script src="path/to/lib/flickity-imagesloaded.js"></script>
<script src="path/to/angular-flickity/dist/angular-flickity.js"></script>
```


##### Note when using Flickity via bower

Expand All @@ -97,12 +133,6 @@ The trick is to specify which files bower should use in your own `bower.json`.
```


## Dependencies

- [Flickity.js (^2.0.3)][flickity_docs]
- [Angular.js (^1.5.8)][angular]


## Usage

Include `bc.Flickity` as a dependency in your project.
Expand Down Expand Up @@ -226,29 +256,29 @@ pass the ID in directly as a string using `bc-flickity-id`.

This module exposes `FlickityConfigProvider` which can be used to set project-wide defaults for
Flickity. Simply set any options here using options that match the original [Flickity
Options](http://flickity.metafizzy.co/options.html).
options](http://flickity.metafizzy.co/options.html).

```javascript
// ES6 Config Example
export function config(FlickityConfigProvider) {
'ngInject';

FlickityConfigProvider.prevNextButtons = false;
FlickityConfigProvider.draggable = false;
FlickityConfigProvider.prevNextButtons = true;
FlickityConfigProvider.setGallerySize = false;

}
```

```javascript
// ES5 Config Example
angular.module('myModule')
.config((FlickityConfigProvider) => {
'ngInject';
.config((FlickityConfigProvider) => {
'ngInject';

FlickityConfigProvider.prevNextButtons = false;
FlickityConfigProvider.draggable = false;
FlickityConfigProvider.prevNextButtons = true;
FlickityConfigProvider.setGallerySize = false;

})
})
;
```

Expand Down Expand Up @@ -300,8 +330,8 @@ that the control should be linked to.

> _More on setting the ID using a [directive](#id) or [service](#initialize)._
If no ID is set, the directive will assume that only one instance exists and grab the first
instance.
If no ID is set, the directive will assume that only one instance exists and grab the ID from the
first instance.

#### Looping

Expand Down Expand Up @@ -346,8 +376,8 @@ that the control should be linked to.

> _More on setting the ID using a [directive](#id) or [service](#initialize)._
If no ID is set, the directive will assume that only one instance exists and grab the first
instance.
If no ID is set, the directive will assume that only one instance exists and grab the ID from the
first instance.

#### Looping

Expand Down Expand Up @@ -974,7 +1004,10 @@ The `$on` call should always be assigned to a variable. This allows it to be des
- Produces uncompressed (`.js`) and minified (`.min.js`) versions of the library under the `dist` folder.
* `npm run watch`
- Watches for changes inside `/src` and calls `npm run build` when changes are detected.

* `npm run test`
- Runs all tests.
* `npm run watch:tests`
- Watch for changes and re-run tests.

## About Flickity

Expand Down Expand Up @@ -1003,6 +1036,15 @@ Made by [Metafizzy][metafizzy] who make seriously [awesome][packery], [stuff][is
[isotope]: http://isotope.metafizzy.co/
[flickity_license]: http://flickity.metafizzy.co/license.html
[angular]: https://angularjs.org
[flickity_imagesloaded]: https://github.com/metafizzy/flickity-imagesloaded

[demo_collection]: http://codepen.io/collection/nNzQxk/
[demo_basic]: http://codepen.io/benjamincharity/pen/amxVaV?editors=1000
[demo_multiple_instances]: http://codepen.io/benjamincharity/pen/dpEqoj?editors=1000
[demo_events]: http://codepen.io/benjamincharity/pen/yaWxor?editors=0010
[demo_service_select]: http://codepen.io/benjamincharity/pen/KgLxRW?editors=0010
[demo_create_remote_docready]: http://codepen.io/benjamincharity/pen/NRVLEb?editors=0010
[demo_inject_slide]: http://codepen.io/benjamincharity/pen/qaGJmW?editors=0010

[demo_collection]: http://codepen.io/collection/nNzQxk/
[demo_basic]: http://codepen.io/benjamincharity/pen/amxVaV?editors=1000
Expand All @@ -1016,4 +1058,7 @@ Made by [Metafizzy][metafizzy] who make seriously [awesome][packery], [stuff][is
[license_url]: LICENSE
[npm_url]: https://npmjs.org/package/angular-flickity
[npm_version_image]: http://img.shields.io/npm/v/angular-flickity.svg

[coverage_image]: https://coveralls.io/repos/github/benjamincharity/angular-flickity/badge.svg
[coverage_url]: https://coveralls.io/github/benjamincharity/angular-flickity
[circle_badge]: https://circleci.com/gh/benjamincharity/angular-flickity/tree/master.svg?style=svg
[circle_link]: https://circleci.com/gh/benjamincharity/angular-flickity/tree/master
Loading

0 comments on commit de9f32e

Please sign in to comment.