Skip to content

Commit

Permalink
test: All nodes have a source property, not just Root
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Dec 8, 2020
1 parent b312eee commit ce355c3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/fromJSON.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ it('rehydrates a JSON AST', () => {
let cssWithMap = postcss().process(
'.foo { color: red; font-size: 12pt; } /* abc */ @media (width: 60em) { }',
{
from: undefined,
from: 'x.css',
map: {
inline: true
},
Expand All @@ -24,6 +24,17 @@ it('rehydrates a JSON AST', () => {
rehydrated.nodes[0].remove()

expect(rehydrated.nodes).toHaveLength(3)

expect(
postcss().process(rehydrated, {
from: undefined,
map: {
inline: true
},
stringifier: postcss.stringify
}).css
).toBe(`/* abc */ @media (width: 60em) { }
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInguY3NzIiwiPG5vIHNvdXJjZT4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQXNDLFNDQXRDLENEQWdELHdCQ0FoRCIsImZpbGUiOiJ0by5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIuZm9vIHsgY29sb3I6IHJlZDsgZm9udC1zaXplOiAxMnB0OyB9IC8qIGFiYyAqLyBAbWVkaWEgKHdpZHRoOiA2MGVtKSB7IH0iLG51bGxdfQ== */`)
})

it('throws when rehydrating an invalid JSON AST', () => {
Expand Down

0 comments on commit ce355c3

Please sign in to comment.