Skip to content

Commit

Permalink
Added check for duplicate gradients. Closes #380 #329
Browse files Browse the repository at this point in the history
  • Loading branch information
ghosh committed May 19, 2018
1 parent 8bc6de6 commit 40947e4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 27 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ A few open source projects built with uiGradients
- [Uigradients iOS Viewer](https://github.com/thexande/uiGradients-Viewer-iOS) - Open source iOS app for viewing gradients
- [Potion](http://numberpicture.com/build) - React components for declaratively composing animated, interactive visualizations

 

## License

[MIT](https://github.com/ghosh/uiGradients/blob/master/LICENSE.md)
Expand Down
14 changes: 5 additions & 9 deletions gradients.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{
{
"name": "Blu",
"colors": ["#00416A", "#E4E5E6"]
},
Expand Down Expand Up @@ -813,7 +813,7 @@
"colors": ["#808080", "#3fada8"]
},
{
"name": "Dusk",
"name": "Jupiter",
"colors": ["#ffd89b", "#19547b"]
},
{
Expand Down Expand Up @@ -1107,10 +1107,6 @@
"name": "Digital Water",
"colors": ["#74ebd5","#ACB6E5"]
},
{
"name": "Velvet Sun",
"colors": ["#e1eec3", "#f05053"]
},
{
"name": "Orange Fun",
"colors": ["#fc4a1a", "#f7b733"]
Expand Down Expand Up @@ -1323,9 +1319,9 @@
{
"name": "JShine",
"colors": ["#12c2e9","#c471ed","#f64f59"]
},
{
},
{
"name": "Moonlit Asteroid",
"colors": ["#0F2027", "#203A43", "#2C5364"]
}
}
]
44 changes: 26 additions & 18 deletions test/unit/specs/Display.spec.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import { mount } from 'avoriaz';
import Display from '@/components/Display';
import Gradients from '../../../gradients.json';

const wrapper = mount(Display, {
propsData: {
direction: 'to left',
gradient: {
colors: ['#1FA2FF', '#21DCF6', '#A6FFCB'],
name: 'Stripe',
},
},
});
const findDuplicatesinArrayByKeyValue = (array, propertyName) => {
let seenDuplicate = false;
let testObject = {};
let dupes = [];

array.map((item) => {
var itemPropertyName = item[propertyName];
if (itemPropertyName in testObject) {
dupes.push(itemPropertyName);
testObject[itemPropertyName].duplicate = true;
item.duplicate = true;
seenDuplicate = true;
}
else {
testObject[itemPropertyName] = item;
delete item.duplicate;
}
})

return seenDuplicate;
}

describe('Display.vue', () => {
it('It renders element correctly', () => {
expect(wrapper.is('.display')).to.equal(true);
});

it('should have a gradient as background style', () => {
expect(wrapper.hasStyle('background', 'linear-gradient(to left, #1FA2FF,#21DCF6,#A6FFCB)'))
.to.equal(true);
describe('Duplicate gradients', () => {
it('Has no duplicate gradient names', () => {
const dupes = findDuplicatesinArrayByKeyValue(Gradients, 'name');
expect(dupes).to.equal(false);
});
});
23 changes: 23 additions & 0 deletions test/unit/specs/Gradients.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { mount } from 'avoriaz';
import Display from '@/components/Display';

const wrapper = mount(Display, {
propsData: {
direction: 'to left',
gradient: {
colors: ['#1FA2FF', '#21DCF6', '#A6FFCB'],
name: 'Stripe',
},
},
});

describe('Display.vue', () => {
it('It renders element correctly', () => {
expect(wrapper.is('.display')).to.equal(true);
});

it('should have a gradient as background style', () => {
expect(wrapper.hasStyle('background', 'linear-gradient(to left, #1FA2FF,#21DCF6,#A6FFCB)'))
.to.equal(true);
});
});

0 comments on commit 40947e4

Please sign in to comment.