Files
shields/frontend/components/badge-examples.spec.js
T
Marcin MielnickiandGitHub eeb78ccf15 Badge suggestion feature fix (#3331)
* Display suggested badges

* E2e test for badge suggestion

* Suggest resource returns example with pattern

* Do not require preview in MarkupModalContent

* Skip integration test for suggestion

* Unmodifiable path in customizer

* Use suggested link

* Allow to change suggested badges

* Enable skipped test

* Enable skipped test

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Unused code removed

* Unused code removed

* getExampleWithServiceByPattern helper added

* BadgeExamples uses examples instead of services definitions

* Revert "getExampleWithServiceByPattern helper added"

This reverts commit 80839fd705.

* style removed from example

* example.exact replaced with preview.buildFromExample

* keywords are required again

* Code refactoring

* More e2e tests for suggestion feature

* Code refactoring

* Build add with a base url

* showActualParams -> isPrefilled

* A new schema for BadgeExamples

* Link moved to queryParams

* Updated documentation for the suggest reponse format

* Link moved to queryParams - another test updated

* Revert "Link moved to queryParams - another test updated"

This reverts commit b5f811bb07.

* Revert "Link moved to queryParams"

This reverts commit 3b54c6d2b4.

* Disable changes in path in suggested badges

* 'link' element documentation restored
2019-04-29 18:38:27 +02:00

111 lines
2.1 KiB
JavaScript

import React from 'react'
import { shallow } from 'enzyme'
import BadgeExamples from './badge-examples'
import '../enzyme-conf.spec'
const exampleServiceDefinitions = [
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/d/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'downloads',
message: '12k',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/rating/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'rating',
message: '4/5',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/stars/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'stars',
message: '★★★★☆',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/users/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'users',
message: '750',
color: 'blue',
},
keywords: ['amo', 'firefox'],
},
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/v/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'mozilla add-on',
message: 'v2.1.0',
color: 'blue',
},
keywords: ['amo', 'firefox'],
},
]
describe('<BadgeExamples />', function() {
it('renders with no examples', function() {
shallow(
<BadgeExamples
baseUrl="https://example.shields.io"
examples={[]}
onClick={() => {}}
/>
)
})
it('renders an array of examples', function() {
shallow(
<BadgeExamples
baseUrl="https://example.shields.io"
examples={exampleServiceDefinitions}
onClick={() => {}}
/>
)
})
})