-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
169 additions
and
31 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
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
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
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 |
---|---|---|
@@ -1,29 +1,43 @@ | ||
import {parseAttrsClass} from '../../src/transform/plugins/table/utils'; | ||
import {parseAttrs} from '../../src/transform/plugins/table/utils'; | ||
|
||
describe('parseAttrsClass', () => { | ||
it('should correctly parse a class in markdown attrs format', () => { | ||
expect(parseAttrsClass('{property=value .class}')).toEqual('class'); | ||
expect(parseAttrs('{property=value .class}')).toEqual({ | ||
'data-property': ['value'], | ||
class: ['class'], | ||
id: [], | ||
}); | ||
}); | ||
|
||
it('should correctly parse a class when its the only property', () => { | ||
expect(parseAttrsClass('{.class}')).toEqual('class'); | ||
expect(parseAttrs('{.class}')).toEqual({ | ||
class: ['class'], | ||
id: [], | ||
}); | ||
}); | ||
|
||
it('should require a whitespace if there are other properties', () => { | ||
expect(parseAttrsClass('{property=value.class}')).toEqual(null); | ||
expect(parseAttrs('{property=value.class}')).toEqual({ | ||
'data-property': ['value.class'], | ||
id: [], | ||
class: [], | ||
}); | ||
}); | ||
|
||
it('should bail if there are unexpected symbols', () => { | ||
expect(parseAttrsClass('{property="value" .class}')).toEqual(null); | ||
expect(parseAttrs('{property="value" .class}')).toEqual(null); | ||
}); | ||
|
||
it('should allow a dash in the class name', () => { | ||
expect(parseAttrsClass('{.cell-align-center}')).toEqual('cell-align-center'); | ||
expect(parseAttrs('{.cell-align-center}')).toEqual({ | ||
id: [], | ||
class: ['cell-align-center'], | ||
}); | ||
}); | ||
|
||
it('should not touch includes', () => { | ||
expect( | ||
parseAttrsClass('{% include <a href="./mocks/include.md">create-folder</a> %}'), | ||
).toEqual(null); | ||
expect(parseAttrs('{% include <a href="./mocks/include.md">create-folder</a> %}')).toEqual( | ||
null, | ||
); | ||
}); | ||
}); |