Skip to content

Commit 6857e7d

Browse files
Vue2 - Adding Sharp Tests (#397)
* add sharp tests * PR review suggestion Co-authored-by: Rob Madole <[email protected]> Co-authored-by: Rob Madole <[email protected]>
1 parent 47e48d3 commit 6857e7d

File tree

4 files changed

+3329
-2630
lines changed

4 files changed

+3329
-2630
lines changed

src/components/__fixtures__/helpers.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ export function mountFromProps (propsData = {}) {
3030
}
3131

3232
export function coreHasFeature (feature) {
33-
if (feature === REFERENCE_ICON_BY_STYLE || feature === ICON_ALIASES || feature === REFERENCE_ICON_USING_STRING) {
33+
if (
34+
feature === REFERENCE_ICON_BY_STYLE
35+
|| feature === ICON_ALIASES
36+
|| feature === REFERENCE_ICON_USING_STRING
37+
|| feature === REFERENCE_ICON_USING_FAMILY
38+
) {
3439
return parse.icon
3540
}
3641
}
3742

3843
export const REFERENCE_ICON_BY_STYLE = 0x00
3944
export const ICON_ALIASES = 0x01
40-
export const REFERENCE_ICON_USING_STRING = 0x02
45+
export const REFERENCE_ICON_USING_STRING = 0x02
46+
export const REFERENCE_ICON_USING_FAMILY = 0x03

src/components/__fixtures__/icons.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,16 @@ export const faSpartan = {
3232
"f100",
3333
"..."
3434
]
35-
}
35+
}
36+
37+
export const faGlasses = {
38+
prefix: 'fass',
39+
iconName: 'glasses',
40+
icon: [
41+
640,
42+
512,
43+
[],
44+
"f200",
45+
"..."
46+
]
47+
}

src/components/__tests__/FontAwesomeIcon.test.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,50 @@ import Vue from 'vue/dist/vue'
66
import FontAwesomeIcon from '../FontAwesomeIcon'
77
import { library } from '@fortawesome/fontawesome-svg-core'
88
import { faClose, faUser } from '@fortawesome/free-solid-svg-icons'
9-
import { faCoffee, faCircle, faSpartan } from '../__fixtures__/icons'
10-
import { coreHasFeature, REFERENCE_ICON_USING_STRING, REFERENCE_ICON_BY_STYLE, ICON_ALIASES, compileAndMount, mountFromProps } from '../__fixtures__/helpers'
9+
import { faCoffee, faCircle, faSpartan, faGlasses } from '../__fixtures__/icons'
10+
import { coreHasFeature, compileAndMount, mountFromProps, REFERENCE_ICON_BY_STYLE, ICON_ALIASES, REFERENCE_ICON_USING_STRING, REFERENCE_ICON_USING_FAMILY } from '../__fixtures__/helpers'
1111

1212
beforeEach(() => {
13-
library.add(faCoffee, faCircle, faSpartan)
13+
library.add(faCoffee, faCircle, faSpartan, faGlasses)
1414
Vue.component('font-awesome-icon', FontAwesomeIcon)
1515
})
1616

1717
afterEach(() => {
1818
library.reset()
1919
})
2020

21+
describe('using a family', () => {
22+
if (coreHasFeature(REFERENCE_ICON_USING_FAMILY)) {
23+
test('will find a sharp-solid-svg-icon with array format', () => {
24+
const vm = mountFromProps({ icon: ['fass', 'glasses'] })
25+
26+
expect(vm.$el.tagName).toBe('svg')
27+
expect(vm.$el.classList.contains('fa-glasses')).toBeTruthy()
28+
})
29+
30+
test('will find a sharp solid icon using short prefix with string format', () => {
31+
const vm = mountFromProps({ icon: 'fass fa-glasses' })
32+
33+
expect(vm.$el.tagName).toBe('svg')
34+
expect(vm.$el.classList.contains('fa-glasses')).toBeTruthy()
35+
})
36+
37+
test('will find a sharp solid icon using long prefix with string format', () => {
38+
const vm = mountFromProps({ icon: 'fa-sharp fa-glasses' })
39+
40+
expect(vm.$el.tagName).toBe('svg')
41+
expect(vm.$el.classList.contains('fa-glasses')).toBeTruthy()
42+
})
43+
44+
test('will find a sharp solid icon using long prefix and style with string format', () => {
45+
const vm = mountFromProps({ icon: 'fa-sharp fa-solid fa-glasses' })
46+
47+
expect(vm.$el.tagName).toBe('svg')
48+
expect(vm.$el.classList.contains('fa-glasses')).toBeTruthy()
49+
})
50+
}
51+
})
52+
2153
test('using a FAT icon with array format', () => {
2254
const vm = mountFromProps({ icon: ['fat', 'spartan'] })
2355

0 commit comments

Comments
 (0)