Skip to content

Commit

Permalink
Merge pull request #5739 from owncloud/bump-filesize-dependency
Browse files Browse the repository at this point in the history
[unit-test-only] Bump filesize dependency
  • Loading branch information
Pascal Wengerter authored Aug 26, 2021
2 parents ac12835 + 6528b6e commit 8755c65
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Switch filesize calculation base

We've switched from base-2 to base-10 when calculating the displayed file-size
to align it better with user expectations.

https://github.com/owncloud/web/pull/5739
2 changes: 1 addition & 1 deletion packages/web-app-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "AGPL-3.0",
"devDependencies": {
"copy-to-clipboard": "^3.3.1",
"filesize": "^6.4.0",
"filesize": "^8.0.0",
"filter-obj": "^2.0.1",
"fuse.js": "^6.4.6",
"lodash-es": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import OcSwitch from '@/tests/unit/stubs/OcSwitch'

import ViewOptions from '@files/src/components/AppBar/ViewOptions.vue'

const OcTooltip = jest.fn()

describe('ViewOptions', () => {
let localVue, router, mutations, store

Expand All @@ -34,7 +36,13 @@ describe('ViewOptions', () => {
})

it('updates the files page limit when using page size component', () => {
const wrapper = shallowMount(ViewOptions, { store, router, localVue, stubs })
const wrapper = shallowMount(ViewOptions, {
store,
router,
localVue,
stubs,
directives: { OcTooltip }
})
const select = wrapper.find('[data-testid="files-pagination-size"]')

expect(select.exists()).toBe(true)
Expand All @@ -49,7 +57,13 @@ describe('ViewOptions', () => {
store,
router,
localVue,
stubs: { ...stubs, 'oc-page-size': OcPageSize(localVue) }
stubs: {
...stubs,
'oc-page-size': OcPageSize(localVue)
},
directives: {
OcTooltip
}
})

wrapper.vm.$router.replace({ query: { 'items-limit': 500 } }).catch(() => {})
Expand All @@ -65,7 +79,9 @@ describe('ViewOptions', () => {
...stubs,
'oc-switch': OcSwitch(localVue)
},
directives: { OcTooltip: jest.fn() },
directives: {
OcTooltip
},
router
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ describe('ListInfo', () => {
${0.1} | ${'0 B'}
${1} | ${'1 B'}
${100} | ${'100 B'}
${10000} | ${'10 KB'}
${10000000} | ${'9.5 MB'}
${10000000000} | ${'9.3 GB'}
${10000000000000} | ${'9.1 TB'}
${10000} | ${'10 kB'}
${10000000} | ${'10 MB'}
${10000000000} | ${'10 GB'}
${10000000000000} | ${'10 TB'}
`('should calculate size units', ({ size, expectedSize }) => {
const wrapper = getWrapper({ size: size })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const selectors = {
}

describe('Pagination', () => {
describe('pages', () => {
describe('when value is less than or equals one', () => {
describe('when amount of pages is', () => {
describe('less than or equals one', () => {
it.each([-1, 0, 1])('should not show wrapper', pages => {
const store = createStore(0, pages)
const wrapper = getWrapper(store)
Expand All @@ -29,7 +29,7 @@ describe('Pagination', () => {
})
})

describe('when value is greater than one', () => {
describe('greater than one', () => {
const wrapper = getWrapper(createStore(1, 2))

it('should show wrapper', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ describe('Details Multiple Selection SideBar Item', () => {
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 0')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 2')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 KB')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
it('should display information for two selected files', () => {
const wrapper = createWrapper([fileA, fileB])
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 2')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 0')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 KB')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
it('should display information for one selected file, one selected folder', () => {
const wrapper = createWrapper([fileA, folderA])
expect(wrapper.find(selectors.selectedFilesText).text()).toBe('2 items selected')
expect(wrapper.find(selectors.filesCount).text()).toBe('Files 1')
expect(wrapper.find(selectors.foldersCount).text()).toBe('Folders 1')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 KB')
expect(wrapper.find(selectors.size).text()).toBe('Size 1 kB')
})
})

Expand Down
6 changes: 3 additions & 3 deletions packages/web-app-files/tests/unit/mixins/resources.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ describe('resources', () => {
it.each([
{ size: '0', expectedSize: '0 B' },
{ size: '1', expectedSize: '1 B' },
{ size: '1024', expectedSize: '1 KB' },
{ size: '1024', expectedSize: '1 kB' },
{ size: '1048576', expectedSize: '1 MB' }
])('should return formatted size of given resource', sizeInput => {
expect(wrapper.vm.getResourceSize(sizeInput.size)).toEqual(sizeInput.expectedSize)
})

it('should not show round value for size less than a MB', () => {
expect(wrapper.vm.getResourceSize('4321')).toEqual('4 KB')
expect(wrapper.vm.getResourceSize('4321')).toEqual('4 kB')
})

it('should show single round value for size larger than a MB', () => {
expect(wrapper.vm.getResourceSize('4321000')).toEqual('4.1 MB')
expect(wrapper.vm.getResourceSize('4321000')).toEqual('4.3 MB')
})
})
})
2 changes: 1 addition & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"devDependencies": {
"@vue/test-utils": "^1.1.2",
"easygettext": "^2.16.1",
"filesize": "^6.4.0",
"filesize": "^8.0.0",
"focus-trap": "^6.4.0",
"focus-trap-vue": "^1.1.1",
"fuse.js": "^6.4.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ describe('Sidebar Quota component', () => {
translate: false
}
})
expect(wrapper.html()).toContain('1.2 GB of 2 GB')
expect(wrapper.html()).toContain('1.3 GB of 2 GB')
})
})
6 changes: 3 additions & 3 deletions packages/web-runtime/tests/unit/helpers/resource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ describe('getResourceSize', () => {
it.each`
size | result
${0} | ${'0 B'}
${1023} | ${'1023 B'}
${1024} | ${'1 KB'}
${1287654323} | ${'1.2 GB'}
${1023} | ${'1 kB'}
${1024} | ${'1 kB'}
${1287654323} | ${'1.3 GB'}
${-1} | ${'0 B'}
${'string'} | ${'?'}
`('converts the size integer to human readable format', ({ size, result }) => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4921,10 +4921,10 @@ filelist@^1.0.1:
dependencies:
minimatch "^3.0.4"

filesize@^6.4.0:
version "6.4.0"
resolved "https://registry.npmjs.org/filesize/-/filesize-6.4.0.tgz"
integrity sha512-mjFIpOHC4jbfcTfoh4rkWpI31mF7viw9ikj/JyLoKzqlwG/YsefKfvYlYhdYdg/9mtK2z1AzgN/0LvVQ3zdlSQ==
filesize@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-8.0.0.tgz#532db71cb8a04df7d403da054a28de1b648534e0"
integrity sha512-sb690gQx3y/5KZIztgWAKM/r4Hf1V3R8mkAE0OhasMw2FDYduFTYCji8YN9BVpsGoMxrHPFvia1BMxwfLHX+fQ==

fill-range@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 8755c65

Please sign in to comment.