diff --git a/src/components/Settings/Tabs/BitTorrent.vue b/src/components/Settings/Tabs/BitTorrent.vue index 430d8e42..063ed544 100644 --- a/src/components/Settings/Tabs/BitTorrent.vue +++ b/src/components/Settings/Tabs/BitTorrent.vue @@ -170,6 +170,26 @@ + + + + + {{ $t('then') }} + + + + + + + @@ -178,6 +198,29 @@ import { SettingsTab, FullScreenModal } from '@/mixins' export default { name: 'BitTorrent', - mixins: [SettingsTab, FullScreenModal] + mixins: [SettingsTab, FullScreenModal], + data() { + return { + thenTypes: [ + { + value: 0, + text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioPauseTorrent') + }, + { + value: 1, + text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioRemoveTorrent') + }, + { + value: 3, + text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioRemoveTorrentAndFiles') + + }, + { + value: 2, + text: this.$i18n.t('modals.settings.pageBittorrent.maxRatioTorrentSuperseeding') + } + ] + } + } } diff --git a/src/lang/en.js b/src/lang/en.js index 2bb2c7e7..22897c66 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -42,6 +42,7 @@ const locale = { magnet: 'Magnet', feed: 'feed', rule: 'rule', + then: 'Then', /** Torrent */ torrent: { @@ -207,7 +208,11 @@ const locale = { torrentInactivityTimer: 'Torrent inactivity timer', subHeaderSeedLimits: 'Seed Limits', whenRatioReaches: 'When ratio reaches', - whenSeedingTimeReaches: 'When seeding time reaches' + whenSeedingTimeReaches: 'When seeding time reaches', + maxRatioPauseTorrent: 'Pause torrent', + maxRatioRemoveTorrent: 'Remove torrent', + maxRatioRemoveTorrentAndFiles: 'Remove torrent and files', + maxRatioTorrentSuperseeding: 'Enable torrent super seeding' }, pageRss: { tabName: { diff --git a/tests/unit/BitTorrent.spec.js b/tests/unit/BitTorrent.spec.js index f247f707..3697a8f0 100644 --- a/tests/unit/BitTorrent.spec.js +++ b/tests/unit/BitTorrent.spec.js @@ -4,118 +4,133 @@ import BitTorrent from '../../src/components/Settings/Tabs/BitTorrent.vue' let wrapper const getSettingsMockRes = { - dht:true, - pex:true, - lsd:true, - anonymous_mode:true, - queueing_enabled:true, - max_active_downloads:1, - max_active_uploads:'max_active_uploads', - max_active_torrents:6, - dont_count_slow_torrents:true, - slow_torrent_dl_rate_threshold:1, - slow_torrent_ul_rate_threshold:1, - slow_torrent_inactive_timer:1, - max_ratio_enabled:true, - max_ratio:1, - max_seeding_time_enabled:true, - max_seeding_time:1 + dht: true, + pex: true, + lsd: true, + anonymous_mode: true, + queueing_enabled: true, + max_active_downloads: 1, + max_active_uploads: 'max_active_uploads', + max_active_torrents: 6, + dont_count_slow_torrents: true, + slow_torrent_dl_rate_threshold: 1, + slow_torrent_ul_rate_threshold: 1, + slow_torrent_inactive_timer: 1, + max_ratio_enabled: true, + max_ratio: 1, + max_seeding_time_enabled: true, + max_seeding_time: 1 } -const getCustomWrapper = (getSettingsRes)=> { - return shallowMount(BitTorrent,{ mocks: { $t: (x) => x , $store: { - getters:{getSettings:()=>{ - return getSettingsRes - }}, - state: { } - } - } }) +const getCustomWrapper = getSettingsRes => { + return shallowMount(BitTorrent, { + mocks: { + $i18n: { + t: x => x + }, + $t: x => x, + $store: { + getters: { getSettings: () => { + return getSettingsRes + } }, + state: { } + } + } + + }) } describe('BitTorrent', () => { - beforeEach(() => { - wrapper = shallowMount(BitTorrent,{ mocks: { $t: (x) => x , $store: { - getters:{getSettings:()=>{ - return getSettingsMockRes - }}, - state: { } - } - } }) + beforeEach(() => { + wrapper = shallowMount(BitTorrent, { + mocks: { + $i18n: { + t: x => x + }, + $t: x => x, + $store: { + getters: { getSettings: () => { + return getSettingsMockRes + } }, + state: { } + } + } }) + }) - it('render correctly', () => { - expect(wrapper.html()).toMatchSnapshot() - }) + it('render correctly', () => { + expect(wrapper.html()).toMatchSnapshot() + }) - it('render correctly when anonymous_mode is false', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - anonymous_mode:false - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when anonymous_mode is false', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + anonymous_mode: false }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when queueing_enabled is false', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - queueing_enabled:false - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when queueing_enabled is false', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + queueing_enabled: false }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when dont_count_slow_torrents is false', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - dont_count_slow_torrents:false - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when dont_count_slow_torrents is false', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + dont_count_slow_torrents: false }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when max_ratio_enabled is false', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - max_ratio_enabled:false - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when max_ratio_enabled is false', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + max_ratio_enabled: false }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when max_seeding_time_enabled is false', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - max_seeding_time_enabled:false - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when max_seeding_time_enabled is false', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + max_seeding_time_enabled: false }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when max_active_downloads is 2', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - max_active_downloads:2 - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when max_active_downloads is 2', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + max_active_downloads: 2 }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when max_active_torrents is 3', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - max_active_torrents:3 - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when max_active_torrents is 3', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + max_active_torrents: 3 }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when slow_torrent_dl_rate_threshold is 25', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - slow_torrent_dl_rate_threshold:25 - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when slow_torrent_dl_rate_threshold is 25', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + slow_torrent_dl_rate_threshold: 25 }) + expect(customWrapper.html()).toMatchSnapshot() + }) - it('render correctly when slow_torrent_ul_rate_threshold is 24', () => { - const customerWarpper = getCustomWrapper({ - ...getSettingsMockRes, - slow_torrent_ul_rate_threshold:24 - }) - expect(customerWarpper.html()).toMatchSnapshot() + it('render correctly when slow_torrent_ul_rate_threshold is 24', () => { + const customWrapper = getCustomWrapper({ + ...getSettingsMockRes, + slow_torrent_ul_rate_threshold: 24 }) + expect(customWrapper.html()).toMatchSnapshot() + }) }) diff --git a/tests/unit/__snapshots__/BitTorrent.spec.js.snap b/tests/unit/__snapshots__/BitTorrent.spec.js.snap index 23411c4e..84db45a1 100644 --- a/tests/unit/__snapshots__/BitTorrent.spec.js.snap +++ b/tests/unit/__snapshots__/BitTorrent.spec.js.snap @@ -62,6 +62,18 @@ exports[`BitTorrent render correctly 1`] = ` + + + + + then + + + + + + + `; @@ -127,6 +139,18 @@ exports[`BitTorrent render correctly when anonymous_mode is false 1`] = ` + + + + + then + + + + + + + `; @@ -192,6 +216,18 @@ exports[`BitTorrent render correctly when dont_count_slow_torrents is false 1`] + + + + + then + + + + + + + `; @@ -257,6 +293,18 @@ exports[`BitTorrent render correctly when max_active_downloads is 2 1`] = ` + + + + + then + + + + + + + `; @@ -322,6 +370,18 @@ exports[`BitTorrent render correctly when max_active_torrents is 3 1`] = ` + + + + + then + + + + + + + `; @@ -387,6 +447,18 @@ exports[`BitTorrent render correctly when max_ratio_enabled is false 1`] = ` + + + + + then + + + + + + + `; @@ -452,6 +524,18 @@ exports[`BitTorrent render correctly when max_seeding_time_enabled is false 1`] + + + + + then + + + + + + + `; @@ -517,6 +601,18 @@ exports[`BitTorrent render correctly when queueing_enabled is false 1`] = ` + + + + + then + + + + + + + `; @@ -582,6 +678,18 @@ exports[`BitTorrent render correctly when slow_torrent_dl_rate_threshold is 25 1 + + + + + then + + + + + + + `; @@ -647,5 +755,17 @@ exports[`BitTorrent render correctly when slow_torrent_ul_rate_threshold is 24 1 + + + + + then + + + + + + + `;