|
|
|
@ -22,21 +22,44 @@ describe('CssRulesView', () => { |
|
|
|
widthMedia: '', |
|
|
|
}, |
|
|
|
]; |
|
|
|
const mobileFirstDevices = [ |
|
|
|
{ |
|
|
|
name: 'Mobile portrait', |
|
|
|
width: '', |
|
|
|
widthMedia: '', |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'Tablet', |
|
|
|
width: '768px', |
|
|
|
widthMedia: '992px', |
|
|
|
}, |
|
|
|
{ |
|
|
|
name: 'Desktop', |
|
|
|
width: '1024px', |
|
|
|
widthMedia: '1280px', |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
function buildEditor(editorOptions) { |
|
|
|
const col = new CssRules([]); |
|
|
|
obj = new CssRulesView({ |
|
|
|
const obj = new CssRulesView({ |
|
|
|
collection: col, |
|
|
|
config: { |
|
|
|
em: new Editor({ |
|
|
|
deviceManager: { |
|
|
|
devices, |
|
|
|
}, |
|
|
|
}), |
|
|
|
em: new Editor(editorOptions), |
|
|
|
}, |
|
|
|
}); |
|
|
|
document.body.innerHTML = '<div id="fixtures"></div>'; |
|
|
|
document.body.querySelector('#fixtures').appendChild(obj.render().el); |
|
|
|
|
|
|
|
return obj; |
|
|
|
} |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
obj = buildEditor({ |
|
|
|
deviceManager: { |
|
|
|
devices, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
@ -68,6 +91,35 @@ describe('CssRulesView', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Collection is empty. Styles structure with mobile first bootstraped', () => { |
|
|
|
obj = buildEditor({ |
|
|
|
mediaCondition: 'min-width', |
|
|
|
deviceManager: { |
|
|
|
devices: mobileFirstDevices, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
expect(obj.$el.html()).toBeTruthy(); |
|
|
|
const foundStylesContainers = obj.$el.find('div'); |
|
|
|
expect(foundStylesContainers.length).toEqual(mobileFirstDevices.length); |
|
|
|
|
|
|
|
foundStylesContainers.each((idx, e) => console.log(e.id)); |
|
|
|
|
|
|
|
const sortedDevicesWidthMedia = mobileFirstDevices |
|
|
|
.map(dvc => dvc.widthMedia) |
|
|
|
.sort((left, right) => { |
|
|
|
const a = (left && left.replace('px', '')) || Number.MIN_VALUE; |
|
|
|
const b = (right && right.replace('px', '')) || Number.MIN_VALUE; |
|
|
|
return a - b; |
|
|
|
}) |
|
|
|
.map(widthMedia => parseFloat(widthMedia)); |
|
|
|
|
|
|
|
foundStylesContainers.each((idx, $styleC) => { |
|
|
|
const width = sortedDevicesWidthMedia[idx]; |
|
|
|
expect($styleC.id).toEqual(`${prefix}${width ? `-${width}` : ''}`); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test('Add new rule', () => { |
|
|
|
sinon.stub(obj, 'addToCollection'); |
|
|
|
obj.collection.add({}); |
|
|
|
|