-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for string sheet semicolon parsing
- Loading branch information
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
const expect = require('chai').expect; | ||
const cytoscape = require('../src/test.js'); | ||
|
||
describe('String-sheet parsing', function(){ | ||
let cy; | ||
let consoleWarn; | ||
|
||
this.beforeAll(function() { | ||
consoleWarn = console.warn; | ||
console.warn = function() {}; | ||
}); | ||
|
||
this.afterAll(function() { | ||
console.warn = consoleWarn; | ||
}); | ||
|
||
beforeEach(function() { | ||
cy = cytoscape({ | ||
styleEnabled: true, | ||
elements: { | ||
nodes: [ | ||
{ data: { id: 'n1' } }, | ||
], | ||
}, | ||
}); | ||
}); | ||
|
||
afterEach(function(){ | ||
cy.destroy(); | ||
}); | ||
|
||
[ | ||
'#n1 { color: rgb(1,1,1); background-color: rgb(1,1,1); }', | ||
'#n1 { color: rgb(1,1,1); background-color: rgb(1,1,1) }', | ||
'#n1 {color: rgb(1,1,1);background-color: rgb(1,1,1);}', | ||
`#n1 {color: rgb(1,1,1); | ||
background-color: rgb(1,1,1);}`, | ||
] | ||
.forEach((stringSheet) => { | ||
it('style block applied when parsed with no validity errors', function(){ | ||
let style = cy.$('#n1').style(); | ||
expect( style ).to.have.property('color'); | ||
expect( style['color'] ).to.exist; | ||
expect( style['color'] ).not.to.equal('rgb(1,1,1)'); | ||
expect( style ).to.have.property('background-color'); | ||
expect( style['background-color'] ).to.exist; | ||
expect( style['background-color'] ).not.to.equal('rgb(1,1,1)'); | ||
|
||
cy.style().fromString(stringSheet); | ||
|
||
style = cy.$('#n1').style(); | ||
expect( style['color'] ).to.equal('rgb(1,1,1)'); | ||
expect( style['background-color'] ).to.equal('rgb(1,1,1)'); | ||
}); | ||
}); | ||
|
||
[ | ||
'#n1 { color: rgb(1,1,1) }', | ||
'#n1 { color: rgb(1,1,1); }', | ||
] | ||
.forEach((stringSheet) => { | ||
it('style block with one property applied when parsed with no validity errors', function(){ | ||
let style = cy.$('#n1').style(); | ||
expect( style ).to.have.property('color'); | ||
expect( style['color'] ).to.exist; | ||
expect( style['color'] ).not.to.equal('rgb(1,1,1)'); | ||
|
||
|
||
cy.style().fromString(stringSheet); | ||
|
||
style = cy.$('#n1').style(); | ||
expect( style['color'] ).to.equal('rgb(1,1,1)'); | ||
}); | ||
}); | ||
|
||
[ | ||
'#n1 { color: rgb(1,1,1) background-color: rgb(1,1,1) }', | ||
'#n1 { color: rgb(1,1,1) background-color: rgb(1,1,1); }', | ||
`#n1 {color: rgb(1,1,1) | ||
background-color: rgb(1,1,1);}`, | ||
] | ||
.forEach((stringSheet) => { | ||
it('style block ignored when parsed with validity error', function(){ | ||
let style = cy.$('#n1').style(); | ||
expect( style ).to.have.property('color'); | ||
expect( style['color'] ).to.exist; | ||
expect( style['color'] ).not.to.equal('rgb(1,1,1)'); | ||
expect( style ).to.have.property('background-color'); | ||
expect( style['background-color'] ).to.exist; | ||
expect( style['background-color'] ).not.to.equal('rgb(1,1,1)'); | ||
|
||
cy.style().fromString(stringSheet); | ||
|
||
style = cy.$('#n1').style(); | ||
expect( style['color'] ).not.to.equal('rgb(1,1,1)'); | ||
expect( style['background-color'] ).not.to.equal('rgb(1,1,1)'); | ||
}); | ||
}); | ||
|
||
}); |