Skip to content

Commit 6c188cf

Browse files
yahtnifvouill
authored andcommitted
Update attr (#22)
* Update: .buttons and .tags group sizing (.are-small, .are-medium, .are-large) * Update test * Add snapshot test
1 parent d08749c commit 6c188cf

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

Diff for: src/plugin/helpers.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Created by Vouill on 23/07/17.
3+
*
4+
* By default, components are rendered as div. This is not useful for components such as input for example.
5+
* This map makes possible a custom default value for the following components.
6+
* Key: Bulma component name ; Value: default rendered html tag
37
*/
4-
/*
5-
* By default, components are rendered as div. This is not useful for components such as input for example.
6-
* This map makes possible a custom default value for the following components.
7-
* Key: Bulma component name ; Value: default rendered html tag
8-
*/
8+
99
export const vueBulmaDefaultRenderElement = new Map([
1010
['breadcrumb', 'nav'],
1111
['button', 'button'],
@@ -50,8 +50,8 @@ export const vueBulmaDefaultRenderElement = new Map([
5050
])
5151

5252
/*
53-
* This is the list of all available vue-bulma-components rendered when using Vue.use(). If one is missing, add it here.
54-
*/
53+
* This is the list of all available vue-bulma-components rendered when using Vue.use(). If one is missing, add it here.
54+
*/
5555
export const bulmaComponentList = [
5656
'box',
5757
'breadcrumb',
@@ -176,10 +176,11 @@ export const toPascalCase = str => {
176176

177177
// thanks the solution @israelroldan
178178
export const isBulmaAttribute = attr =>
179-
attr.trim() && /^(is|has|fa)-.+/.test(attr)
179+
attr.trim() && /^(is|are|has|fa)-.+/.test(attr)
180180

181181
const internalAttribute = ['outerElement', 'outer-element']
182-
export const isInternalAttribute = attr => attr.trim() && internalAttribute.indexOf(attr) > -1
182+
export const isInternalAttribute = attr =>
183+
attr.trim() && internalAttribute.indexOf(attr) > -1
183184

184185
export const getOutrEl = (outrEl, reqOutrEl, elName, defaultEl = 'div') =>
185186
outrEl || reqOutrEl || vueBulmaDefaultRenderElement.get(elName) || defaultEl

Diff for: test/unit/__snapshots__/plugin-component.spec.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Bulma component generator should create a basic bulma buttons component with set size 1`] = `"<div class=\\"buttons are-large\\"></div>"`;
4+
35
exports[`Bulma component generator should create a basic bulma component 1`] = `"<div class=\\"panel\\"></div>"`;
46
57
exports[`Bulma component generator should create a basic bulma component with modifiers 1`] = `"<span class=\\"box is-primary\\"></span>"`;

Diff for: test/unit/helpers.spec.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,32 @@ import {
55
} from 'src/plugin/helpers'
66

77
describe('Helpers', () => {
8-
it('should convert camel to dash case', () => {
9-
expect(camelCaseToDash('IsPrimary')).toEqual('is-primary')
10-
expect(camelCaseToDash('isPrimary')).toEqual('is-primary')
11-
expect(camelCaseToDash('Isprimary')).not.toEqual('is-primary')
12-
expect(camelCaseToDash('isprimary')).not.toEqual('is-primary')
13-
expect(camelCaseToDash('is-primary')).toEqual('is-primary')
14-
expect(camelCaseToDash('is-')).toEqual('is-')
15-
expect(camelCaseToDash('is2')).toEqual('is-2')
16-
expect(camelCaseToDash('Is2')).toEqual('is-2')
17-
expect(camelCaseToDash('is-128x128')).toEqual('is-128x128')
18-
})
19-
208
it('should find Bulma class', () => {
219
expect(isBulmaAttribute('is')).toEqual(false)
10+
expect(isBulmaAttribute('are')).toEqual(false)
2211
expect(isBulmaAttribute('has')).toEqual(false)
2312
expect(isBulmaAttribute('fa')).toEqual(false)
2413
expect(isBulmaAttribute('is-')).toEqual(false)
2514
expect(isBulmaAttribute('has-')).toEqual(false)
2615
expect(isBulmaAttribute('fa-')).toEqual(false)
2716
expect(isBulmaAttribute('is-primary')).toEqual(true)
17+
expect(isBulmaAttribute('are-large')).toEqual(true)
2818
expect(isBulmaAttribute('has-text-centered')).toEqual(true)
2919
expect(isBulmaAttribute('fa-home')).toEqual(true)
3020
})
3121

22+
it('should convert camel to dash case', () => {
23+
expect(camelCaseToDash('IsPrimary')).toEqual('is-primary')
24+
expect(camelCaseToDash('isPrimary')).toEqual('is-primary')
25+
expect(camelCaseToDash('Isprimary')).not.toEqual('is-primary')
26+
expect(camelCaseToDash('isprimary')).not.toEqual('is-primary')
27+
expect(camelCaseToDash('is-primary')).toEqual('is-primary')
28+
expect(camelCaseToDash('is-')).toEqual('is-')
29+
expect(camelCaseToDash('is2')).toEqual('is-2')
30+
expect(camelCaseToDash('Is2')).toEqual('is-2')
31+
expect(camelCaseToDash('is-128x128')).toEqual('is-128x128')
32+
})
33+
3234
it('should convert string to PascalCase', () => {
3335
expect(toPascalCase('string')).toEqual('String')
3436
expect(toPascalCase('camelCase')).toEqual('CamelCase')

Diff for: test/unit/plugin-component.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ describe('Bulma component generator ', () => {
5252
expect(wrapper.html()).toMatchSnapshot()
5353
})
5454

55+
it('should create a basic bulma buttons component with set size', () => {
56+
const wrapper = shallowMount(componentGenerator('buttons'), {
57+
context: {
58+
props: { 'are-large': true }
59+
}
60+
})
61+
expect(wrapper.html()).toMatchSnapshot()
62+
})
63+
5564
it('should create a basic bulma component with modifiers binded to false', () => {
5665
const wrapper = shallowMount(componentGenerator('box'), {
5766
context: {

0 commit comments

Comments
 (0)