Files
lucide/tests/replaceElement.spec.js
Eric Fennis 11c6a2e917 Featherity Npm package, reorganize scripting. (#52)
* New setup for new NPM package

* Add build scripts for dist

* Add introduction readme

* Refactor names

* update package.json

* remove log

* rename variable

* Factoring

* Improve optimize script

* Add eslint config

* Eslint fixes

* rename import

* Move packeges

* Setup rollup and build progress

* Refactor scripts

* fix lint error

* remove lint disabler

* Bring back old libraries

* add indentation

* reset packages directory

* remove vscode setting files

* 0.1.0-alpha.0

* new version

* 0.1.0-alpha.1

* Fix build process

* Add create element to the entry file

* update version number

* publish new alhpa version

* fixing bugs

* Add jest and tests

* replace with XML createElement

* set new version

* Fix svg generation

* Add tests for main library

* Update docs

* Adjust tests and selectors

* update the spec

* Update README.md

* Update README.md

* Update README.md

* update version

* Update README.md

* Move function to helpers file

* rename license, package and readme

* Fix build files

* rename packages

Co-authored-by: Eric Fennis <eric.fennis@endurance.com>
2020-10-06 20:23:26 +02:00

63 lines
1.5 KiB
JavaScript

import { getAttrs, getClassNames, combineClassNames } from '../src/replaceElement';
describe('getAtts', () => {
it('should returns attrbrutes of an element', () => {
const element = {
attributes: [
{
name: 'class',
value: 'item1 item2 item4',
},
{
name: 'date-name',
value: 'volume',
},
],
};
const attrs = getAttrs(element);
expect(attrs.class).toBe(element.attributes[0].value);
});
});
describe('getClassNames', () => {
it('should returns an array when giving class property of string', () => {
const elementAttrs = {
class: 'item1 item2 item3'
};
const attrs = getClassNames(elementAttrs);
expect(JSON.stringify(attrs)).toBe(JSON.stringify(['item1','item2','item3']));
});
it('should returns an array when givind class property with an array', () => {
const elementAttrs = {
class: ['item1','item2','item3']
};
const attrs = getClassNames(elementAttrs);
expect(JSON.stringify(attrs)).toBe(JSON.stringify(['item1','item2','item3']));
});
});
describe('combineClassNames', () => {
it('should retuns a string of classNames', () => {
const arrayOfClassnames = [
{
class: ['item1','item2','item3']
},
{
class: ['item4','item5','item6']
},
{
class: ['item7','item8','item9']
}
];
const combinedClassNames = combineClassNames(arrayOfClassnames);
expect(combinedClassNames).toMatchSnapshot();
});
});