|
|
|
@ -9,14 +9,19 @@ module.exports = { |
|
|
|
const prefix = 'rules-'; |
|
|
|
const devices = [ |
|
|
|
{ |
|
|
|
name: 'Desktop', |
|
|
|
width: '', |
|
|
|
widthMedia: '' |
|
|
|
name: 'Mobile portrait', |
|
|
|
width: '320px', |
|
|
|
widthMedia: '480px' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'Tablet', |
|
|
|
width: '768px', |
|
|
|
widthMedia: '992px' |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'Desktop', |
|
|
|
width: '', |
|
|
|
widthMedia: '' |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
@ -48,8 +53,17 @@ module.exports = { |
|
|
|
expect(obj.$el.html()).toExist(); |
|
|
|
const foundStylesContainers = obj.$el.find('div'); |
|
|
|
expect(foundStylesContainers.length).toEqual(devices.length); |
|
|
|
|
|
|
|
const sortedDevicesWidthMedia = devices |
|
|
|
.map(dvc => dvc.widthMedia) |
|
|
|
.sort((left, right) => { |
|
|
|
return ( |
|
|
|
((right && right.replace('px', '')) || Number.MAX_VALUE) - |
|
|
|
((left && left.replace('px', '')) || Number.MAX_VALUE) |
|
|
|
); |
|
|
|
}); |
|
|
|
foundStylesContainers.each(function($styleC, idx) { |
|
|
|
expect($styleC.id).toEqual(prefix + devices[idx].widthMedia); |
|
|
|
expect($styleC.id).toEqual(prefix + sortedDevicesWidthMedia[idx]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -61,9 +75,7 @@ module.exports = { |
|
|
|
|
|
|
|
it('Render new rule', () => { |
|
|
|
obj.collection.add({}); |
|
|
|
expect( |
|
|
|
obj.$el.find(`#${prefix}${devices[0].widthMedia}`).html() |
|
|
|
).toExist(); |
|
|
|
expect(obj.$el.find(`#${prefix}`).html()).toExist(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|