Skip to content

Commit

Permalink
test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstinalin committed Dec 2, 2024
1 parent a6e2393 commit d826a12
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
6 changes: 3 additions & 3 deletions tests/unit/amo/components/TestAddonsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ describe(__filename, () => {
it('displays a promoted badge when an add-on is promoted', () => {
renderWithResult({
addonProps: {
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
},
});

Expand All @@ -651,7 +651,7 @@ describe(__filename, () => {
it('passes an onClick function which stops propagation to PromotedBadge', () => {
renderWithResult({
addonProps: {
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
},
});

Expand All @@ -669,7 +669,7 @@ describe(__filename, () => {
it('does not display a promoted badge when showPromotedBadge is false', () => {
renderWithResult({
addonProps: {
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
},
props: { showPromotedBadge: false },
});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/amo/components/TestAutoSearchInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ describe(__filename, () => {
describe('Tests for SearchSuggestion', () => {
it('displays a promoted icon when the add-on is promoted', async () => {
const result = createFakeAutocompleteResult({
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
});
render();

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/amo/components/TestInstallButtonWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,12 +1325,12 @@ describe(__filename, () => {
// An add-on which is promoted, but not for the current app.
{
...fakeAddon,
promoted: { apps: [CLIENT_APP_ANDROID], category: RECOMMENDED },
promoted: [{ apps: [CLIENT_APP_ANDROID], category: RECOMMENDED }],
},
// A non-extension which is promoted.
{
...fakeAddon,
promoted: { apps: [CLIENT_APP_FIREFOX], category: RECOMMENDED },
promoted: [{ apps: [CLIENT_APP_FIREFOX], category: RECOMMENDED }],
type: ADDON_TYPE_DICT,
},
])('tracks an untrusted addon install', async (addonOverride) => {
Expand Down Expand Up @@ -1378,7 +1378,7 @@ describe(__filename, () => {
const clientApp = CLIENT_APP_FIREFOX;
_dispatchClientMetadata({ clientApp });

addon.promoted = { apps: [clientApp], category };
addon.promoted = [{ apps: [clientApp], category }];

const fakeTracking = createFakeTracking();

Expand Down Expand Up @@ -1463,7 +1463,7 @@ describe(__filename, () => {
// A promoted theme.
{
...fakeAddon,
promoted: { apps: [CLIENT_APP_FIREFOX], category: RECOMMENDED },
promoted: [{ apps: [CLIENT_APP_FIREFOX], category: RECOMMENDED }],
},
])('tracks a static theme install', async (addonOverride) => {
addon = addonOverride;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/amo/pages/TestAddonVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ describe(__filename, () => {
addon: {
...fakeAddon,
slug: defaultSlug,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] }],
},
});

Expand All @@ -1067,7 +1067,7 @@ describe(__filename, () => {
addon: {
...fakeAddon,
slug: defaultSlug,
promoted: { category: STRATEGIC, apps: [CLIENT_APP_FIREFOX] },
promoted: [{ category: STRATEGIC, apps: [CLIENT_APP_FIREFOX] }],
},
});

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/amo/reducers/test_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe(__filename, () => {

it('sets the suggestion properties', () => {
const name = 'My addon';
const promoted = { category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] };
const promoted = [{ category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] }];
const result = createFakeAutocompleteResult({ promoted, name });
const results = [result];

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/amo/utils/test_addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ describe(__filename, () => {
it('returns the empty list if the addon is not promoted for the specified app', () => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
});
const suggestion = createInternalSuggestionWithLang(
createFakeAutocompleteResult({
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
}),
);

Expand All @@ -230,11 +230,11 @@ describe(__filename, () => {
const category = RECOMMENDED;
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category, apps: [CLIENT_APP_ANDROID] }],
});
const suggestion = createInternalSuggestionWithLang(
createFakeAutocompleteResult({
promoted: { category, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category, apps: [CLIENT_APP_ANDROID] }],
}),
);

Expand All @@ -255,7 +255,7 @@ describe(__filename, () => {
(category) => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category, apps: [CLIENT_APP_ANDROID] }],
});

expect(
Expand Down
20 changes: 11 additions & 9 deletions tests/unit/amo/utils/test_compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe(__filename, () => {
_isCompatibleWithUserAgent({
addon: createInternalAddonWithLang({
...fakeAddon,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
}),
userAgentInfo: UAParser(userAgent),
}),
Expand Down Expand Up @@ -321,7 +321,7 @@ describe(__filename, () => {
_isCompatibleWithUserAgent({
addon: createInternalAddonWithLang({
...fakeAddon,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
}),
currentVersion,
userAgentInfo: UAParser(userAgentsByPlatform.android.firefox40Mobile),
Expand Down Expand Up @@ -909,7 +909,7 @@ describe(__filename, () => {
it('returns true if the add-on is recommended on android', () => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
});

expect(isAndroidInstallable({ addon })).toEqual(true);
Expand All @@ -918,10 +918,12 @@ describe(__filename, () => {
it('returns true if the add-on is recommended on android and desktop', () => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: {
category: RECOMMENDED,
apps: [CLIENT_APP_ANDROID, CLIENT_APP_FIREFOX],
},
promoted: [
{
category: RECOMMENDED,
apps: [CLIENT_APP_ANDROID, CLIENT_APP_FIREFOX],
},
],
});

expect(isAndroidInstallable({ addon })).toEqual(true);
Expand All @@ -932,7 +934,7 @@ describe(__filename, () => {
(type) => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_ANDROID] }],
type,
});

Expand All @@ -945,7 +947,7 @@ describe(__filename, () => {
)('returns true when the add-on is %s on android', (category) => {
const addon = createInternalAddonWithLang({
...fakeAddon,
promoted: { category, apps: [CLIENT_APP_ANDROID] },
promoted: [{ category, apps: [CLIENT_APP_ANDROID] }],
});

expect(isAndroidInstallable({ addon })).toEqual(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/blog-utils/TestStaticAddonCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe(__filename, () => {
const addon = createInternalAddonWithLang({
...fakeAddon,
name: createLocalizedString(name),
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] },
promoted: [{ category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] }],
});

render({ addon });
Expand Down

0 comments on commit d826a12

Please sign in to comment.