Skip to content

Conversation

@GianlucaGuarini
Copy link
Contributor

This is a big PR.
in a nutshell it improves the following things:

  • Add the Circle-ci integration
  • Add the Codeclimate Integration
  • Add the Coverall integration
  • Add unit tests for everything
  • Clean up the package dependencies
  • Add the initial interfaces folder

@nirazul @faebeee Please let me know if you have questions

@GianlucaGuarini
Copy link
Contributor Author

The coverace fails because actually I wasn't able to test completely the scroll-lock-helper mixin since the scroll vuex module is still missing in this repo

Copy link
Contributor

@nirazul nirazul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort, it's a very nice first step for a core component library!

A few questions:

  • Do we really need to check in the dist file dist/index.esm.js? Is there a reason?

The rest of the questions is inlined, feel free to ask, any time!


import { createLocalVue, shallowMount } from '@vue/test-utils';
import { expect } from 'chai';
import { Modal } from '../../../';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sort of an error to me? Is it like omitting index.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the node require algo will import always what we define in the main key of the package.json. Now if today we use main: "dist/index.cjs.js" and tomorrow main: "my-fancy-lib.js" we can avoid to rewrite all the paths in our unit test.

Sidenote: it's impossible to unit test vue components in node without bundling them

@@ -0,0 +1,67 @@
/* eslint-disable no-unused-expressions, max-nested-callbacks */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the unused expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use chaijs expectations you might want to write:

expect('Rouven').to.be.ok
expect(['Gian', 'Luc', 'a'].to.have.a.length

In this case eslint complains because these chains are not called explicitly :(

const vm = new localVue(getDummyComponentProps(bemMixin(ROOT_CLASS)));

expect(vm.bemFacets).to.be.an('array');
expect(vm.bemFacets).to.include(`${ ROOT_CLASS }${ DEFAULT_OPTIONS.bemModifierMarker }${ DEFAULT_OPTIONS.defaultFacet }`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd advise to expressively write down the expected result and avoid any kind of concat or logic within a test:
expect(vm.bemFacets).to.include('root__base');

This makes it much more readable and direct and avoids having subtle bugs within our unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense

@@ -0,0 +1,60 @@
import Vue from 'vue';
import { CLOSE_OVERLAY, MOUNT_OVERLAY, OPEN_OVERLAY, PREPARE_CLOSE_OVERLAY, UNMOUNT_OVERLAY } from '../mutation-types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, you wanted to write it expressively, rather than import * as types from '../mutation-types'? Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's just my personal preference

* Trigger close action for an overlay
* @param {Object} context - A vuex action context
* @param {Object} payload - A vuex action payload
* @return {Promise} promise resolved once the last overlay commit will be dispatched
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this should mean, what is the "last overlay commit"?
This text should describe what I get when I invoke the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly I am still not really happy with this reducer. It dispatches too many asynchronous commits. I guess we will need to refactor it anyways

@@ -0,0 +1,263 @@
/* eslint-disable max-nested-callbacks */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could disable max-nested-callbacks in the eslint config for all *.spec* files with the oerrides option:
https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah wow cool I didn't know it

@GianlucaGuarini GianlucaGuarini merged commit e6c630a into master Aug 22, 2018
@GianlucaGuarini GianlucaGuarini deleted the feature/unit-test branch August 22, 2018 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants