Skip to content

Commit

Permalink
Added more comprehensive tests for interleave and one that breaks add…
Browse files Browse the repository at this point in the history
  • Loading branch information
emilgoldsmith committed Jul 10, 2017
1 parent 4706de2 commit ccc1ed5
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions test/utils.test.js
Expand Up @@ -38,6 +38,128 @@ describe('utils', () => {
'\n display: block;\n color: $dummyValue;\n background: blue;\n'
)
})

it('converts interpolated expressions to dummy mixins', () => {
const quasis = [
{
value: {
raw: '\n display: block;\n '
}
},
{
value: {
raw: '\n background: blue;\n'
}
}
]
const expressions = [
{
name: undefined
}
]
expect(interleave(quasis, expressions)).toEqual(
'\n display: block;\n -styled-mixin0: dummyValue;\n background: blue;\n'
)
})

it('correctly converts several interpolations within a single property', () => {
const quasis = [
{
value: {
raw: '\n display: block;\n border: '
}
},
{
value: {
raw: ' '
}
},
{
value: {
raw: ' '
}
},
{
value: {
raw: ';\n background: blue;\n'
}
}
]
const expressions = [
{
name: 'borderWidth'
},
{
name: 'borderStyle'
},
{
name: 'color'
}
]
expect(interleave(quasis, expressions)).toEqual(
'\n display: block;\n border: $dummyValue $dummyValue $dummyValue;\n background: blue;\n'
)
})

it('correctly handles several interpolations in single line of css', () => {
const quasis1 = [
{
value: {
raw: '\n display: '
}
},
{
value: {
raw: '; background: '
}
},
{
value: {
raw: ';\n'
}
}
]
const expressions1 = [
{
name: 'display'
},
{
name: 'background'
}
]
expect(interleave(quasis1, expressions1)).toEqual(
'\n display: $dummyValue; background: $dummyValue;\n'
)

const quasis2 = [
{
value: {
raw: '\n display: '
}
},
{
value: {
raw: '; '
}
},
{
value: {
raw: '\n'
}
}
]
const expressions2 = [
{
name: 'display'
},
{
name: undefined
}
]
expect(interleave(quasis2, expressions2)).toEqual(
'\n display: $dummyValue; -styled-mixin0: dummyValue\n'
)
})
})

describe('isLastLineWhitespaceOnly', () => {
Expand Down

0 comments on commit ccc1ed5

Please sign in to comment.