Add unit test to Ratchet #774

Merged
merged 1 commit into from Jan 27, 2016

Projects

None yet

3 participants

@Johann-S
Contributor

Hi,

We talked about to add unit test to Ratchet (#723).
This is why I made this PR.

I chose to use Jasmine.
It's the beginning I'll add more unit tests if it's ok.

/CC @cvrebert

@cvrebert
Member
@cvrebert cvrebert added the js label May 13, 2015
@XhmikosR XhmikosR commented on the diff May 14, 2015
.gitignore
@@ -37,3 +37,4 @@ nbproject
# Folders to ignore
node_modules
bower_components
+.grunt
@XhmikosR
XhmikosR May 14, 2015 Member

What creates this folder?

@Johann-S
Johann-S May 14, 2015 Contributor

This folder is created by Jasmine and contain Jasmine dependencies.

@XhmikosR
Member

I think it's very nice work 👍 Sure, it doesn't cover all cases but it's a beginning.

I'm not sure if we should use mocha, qunit or jasmine, something else though.

@XhmikosR XhmikosR commented on an outdated diff May 14, 2015
js/tests/commonSpec.js
@@ -0,0 +1,20 @@
+describe('Common', function () {
+ it('RATCHET namespace is define', function () {
@XhmikosR XhmikosR commented on an outdated diff May 14, 2015
js/tests/commonSpec.js
@@ -0,0 +1,20 @@
+describe('Common', function () {
+ it('RATCHET namespace is define', function () {
+ expect(typeof RATCHET !== 'undefined').toBe(true);
+ });
+
+ it('window.CustomEvent exist', function () {
@XhmikosR XhmikosR and 1 other commented on an outdated diff May 14, 2015
js/tests/commonSpec.js
@@ -0,0 +1,20 @@
+describe('Common', function () {
+ it('RATCHET namespace is define', function () {
+ expect(typeof RATCHET !== 'undefined').toBe(true);
+ });
+
+ it('window.CustomEvent exist', function () {
+ expect(typeof window.CustomEvent !== 'undefined').toBe(true);
+ });
+
+ it('RATCHET.getBrowserCapabilities return an object', function () {
@Johann-S
Johann-S May 14, 2015 Contributor

Sorry for my bad English

@XhmikosR XhmikosR commented on an outdated diff May 14, 2015
js/tests/commonSpec.js
@@ -0,0 +1,20 @@
+describe('Common', function () {
+ it('RATCHET namespace is define', function () {
+ expect(typeof RATCHET !== 'undefined').toBe(true);
+ });
+
+ it('window.CustomEvent exist', function () {
+ expect(typeof window.CustomEvent !== 'undefined').toBe(true);
+ });
+
+ it('RATCHET.getBrowserCapabilities return an object', function () {
+ var result = RATCHET.getBrowserCapabilities;
+ expect(typeof result === 'object').toBe(true);
+ });
+
+ it('RATCHET.getTransitionEnd return string', function () {
@cvrebert
Member

Anyways, I'm not part of Team Ratchet and this PR is nontrivial, so I'm unsubscribing from this.

@XhmikosR XhmikosR added this to the 2.1.0 milestone May 14, 2015
@Johann-S
Contributor

I added a few unit tests for Modal and Slider.

And I made a little script which allow you to fake touch event
https://github.com/Johann-S/TouchFaker

I used my script to send a fake touchstart in the slider unit test.
Because it's not possible ta create a CustomEvent and add an array of touches this is why
I made this script.

Any feedbacks about this @XhmikosR ?

@XhmikosR
Member

For some reason I didn't get the last CC. I'll try to have a look in the next days and merge this. Should be good as a starting point.

@Johann-S
Contributor

Thank you 😄

@Johann-S
Contributor
Johann-S commented Jun 4, 2015

Sorry @XhmikosR but... PING 😄

@XhmikosR
Member

@Johann-S: this needs to be rebased.

@Johann-S
Contributor

Done @XhmikosR 😉

@XhmikosR
Member

@Johann-S: is it possible to show only the tick or X in test output instead of duplicating the test message? Now it's like Slider should fire slide event...✓ Slider should fire slide event

@Johann-S
Contributor

I can change the display to this by using display: 'short' in jasmine configuration

image

@XhmikosR
Member

@Johann-S: yes better use that.

@Johann-S
Contributor

Do you want I squash my commits @XhmikosR ?

@XhmikosR
Member

Yes, please.

@Johann-S
Contributor

Done 👍

@XhmikosR
Member

@Johann-S: What is the reason you didn't use https://github.com/hammerjs/touchemulator?

@Johann-S
Contributor

I fork touchemulator because touchemulator only allow you to fake touch events on mouse events and what I wanted to do it was to trigger fake touch event on unit tests so that's why I create touchfaker

EDIT : With touchemulator you cannot trigger fake touch events in your code you can only add touch events to desktop browsers and allow you to fake touch events when you press Shift on your keyboard. And sorry for my english

@XhmikosR XhmikosR merged commit 0867027 into twbs:master Jan 27, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Johann-S
Contributor

Thank you for your time and feedbacks @XhmikosR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment