Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
- Fixes the `important` prop of DeclarationProps, which should be optional.
- Adds a test for the `assign` method.
  • Loading branch information
jonathantneal authored and ai committed May 17, 2021
1 parent e344e79 commit 631cf49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/declaration.d.ts
Expand Up @@ -32,7 +32,7 @@ export interface DeclarationProps {
/** Value of the declaration. */
value: string
/** Whether the declaration has an `!important` annotation. */
important: boolean
important?: boolean
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
raws?: DeclarationRaws
}
Expand Down
12 changes: 12 additions & 0 deletions test/node.test.ts
Expand Up @@ -162,6 +162,18 @@ it('toString() accepts custom syntax', () => {
expect(new Rule({ selector: 'a' }).toString({ stringify })).toEqual('a')
})

it('assign() assigns to node', () => {
let decl = new Declaration({ prop: 'white-space', value: 'overflow-wrap' })

expect(decl.prop).toBe('white-space')
expect(decl.value).toBe('overflow-wrap')

decl.assign({ prop: 'word-wrap', value: 'break-word' })

expect(decl.prop).toBe('word-wrap')
expect(decl.value).toBe('break-word')
})

it('clone() clones nodes', () => {
let rule = new Rule({ selector: 'a' })
rule.append({ prop: 'color', value: '/**/black' })
Expand Down

0 comments on commit 631cf49

Please sign in to comment.